mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-03-20 14:03:06 +03:00
Improved accuracy for window resize.
svn path=/trunk/netsurf/; revision=12636
This commit is contained in:
parent
33aebf6fd1
commit
68b52a6023
@ -57,9 +57,6 @@
|
||||
#include "atari/search.h"
|
||||
#include "atari/osspec.h"
|
||||
|
||||
|
||||
bool cfg_rt_resize = false;
|
||||
bool cfg_rt_move = false;
|
||||
extern void * h_gem_rsrc;
|
||||
extern struct gui_window *input_window;
|
||||
extern GEM_PLOTTER plotter;
|
||||
@ -228,6 +225,8 @@ static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data)
|
||||
}
|
||||
}
|
||||
if( !a ) {
|
||||
if( prev_sb )
|
||||
gw->root->statusbar->resize_init = true;
|
||||
if( prev_url || prev_sb ) {
|
||||
gem_set_cursor( &gem_cursors.arrow );
|
||||
prev_url = false;
|
||||
@ -306,12 +305,8 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
|
||||
/* Event Handlers: */
|
||||
EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
|
||||
/* capture resize/move events so we can handle that manually */
|
||||
if( !cfg_rt_resize ) {
|
||||
EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw );
|
||||
} else {
|
||||
EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
|
||||
}
|
||||
if( !cfg_rt_move ) {
|
||||
EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw );
|
||||
if( !option_atari_realtime_move ) {
|
||||
EvntDataAttach( gw->root->handle, WM_MOVED, evnt_window_move, gw );
|
||||
} else {
|
||||
EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
|
||||
@ -385,6 +380,7 @@ int window_destroy( struct gui_window * gw)
|
||||
void window_open( struct gui_window * gw)
|
||||
{
|
||||
LGRECT br;
|
||||
GRECT dim;
|
||||
WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
|
||||
WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
|
||||
/* apply focus to the root frame: */
|
||||
@ -392,6 +388,7 @@ void window_open( struct gui_window * gw)
|
||||
mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
|
||||
/* recompute the nested component sizes and positions: */
|
||||
browser_update_rects( gw );
|
||||
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
|
||||
browser_get_rect( gw, BR_CONTENT, &br );
|
||||
plotter->move( plotter, br.g_x, br.g_y );
|
||||
plotter->resize( plotter, br.g_w, br.g_h );
|
||||
@ -694,7 +691,7 @@ static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data )
|
||||
short wx, wy, wh, ww, nx, ny;
|
||||
short r;
|
||||
short xoff, yoff;
|
||||
if( cfg_rt_move ) {
|
||||
if( option_atari_realtime_move ) {
|
||||
std_mvd( win, buff, &app );
|
||||
evnt_window_rt_resize( win, buff, data );
|
||||
} else {
|
||||
@ -712,25 +709,21 @@ static void __CDECL evnt_window_move( WINDOW *win, short buff[8], void * data )
|
||||
|
||||
void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data )
|
||||
{
|
||||
short mx,my, mb, ks;
|
||||
//short mx,my, mb, ks;
|
||||
short wx, wy, wh, ww, nw, nh;
|
||||
short r;
|
||||
graf_mkstate( &mx, &my, &mb, &ks );
|
||||
if( cfg_rt_resize ) {
|
||||
std_szd( win, buff, &app );
|
||||
evnt_window_rt_resize( win, buff, data );
|
||||
} else {
|
||||
wind_get( win->handle, WF_CURRXYWH, &wx, &wy, &ww, &wh );
|
||||
r = graf_rubberbox(wx, wy, 20, 20, &nw, &nh);
|
||||
if( nw < 40 && nw < 40 )
|
||||
return;
|
||||
buff[4] = wx;
|
||||
buff[5] = wy;
|
||||
buff[6] = nw;
|
||||
buff[7] = nh;
|
||||
std_szd( win, buff, &app );
|
||||
evnt_window_rt_resize( win, buff, data );
|
||||
}
|
||||
|
||||
// graf_mkstate( &mx, &my, &mb, &ks );
|
||||
wind_get( win->handle, WF_CURRXYWH, &wx, &wy, &ww, &wh );
|
||||
r = graf_rubberbox(wx, wy, 20, 20, &nw, &nh);
|
||||
if( nw < 40 && nw < 40 )
|
||||
return;
|
||||
buff[4] = wx;
|
||||
buff[5] = wy;
|
||||
buff[6] = nw;
|
||||
buff[7] = nh;
|
||||
std_szd( win, buff, &app );
|
||||
evnt_window_rt_resize( win, buff, data );
|
||||
}
|
||||
|
||||
/* perform the actual resize */
|
||||
@ -739,35 +732,30 @@ static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * da
|
||||
short x,y,w,h;
|
||||
struct gui_window * gw;
|
||||
LGRECT rect;
|
||||
bool resized;
|
||||
bool moved;
|
||||
|
||||
if(buff[0] == WM_FORCE_MOVE ) {
|
||||
std_mvd(win, buff, &app);
|
||||
std_szd(win, buff, &app);
|
||||
}
|
||||
|
||||
wind_get( win->handle, WF_WORKXYWH, &x, &y, &w, &h );
|
||||
wind_get( win->handle, WF_CURRXYWH, &x, &y, &w, &h );
|
||||
gw = (struct gui_window *)data;
|
||||
|
||||
assert( gw != NULL );
|
||||
|
||||
if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
|
||||
moved = true;
|
||||
gw->root->loc.g_x = x;
|
||||
gw->root->loc.g_y = y;
|
||||
browser_update_rects( gw );
|
||||
}
|
||||
|
||||
if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
|
||||
resized = true;
|
||||
/* report resize to component interface: */
|
||||
browser_update_rects( gw );
|
||||
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
|
||||
browser_get_rect( gw, BR_CONTENT, &rect );
|
||||
if( gw->browser->bw->current_content != NULL )
|
||||
browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
|
||||
gw->root->toolbar->url.scrollx = 0;
|
||||
window_redraw_controls(gw, 0);
|
||||
/* TODO: recalculate scroll position, istead of zeroing? */
|
||||
/* TODO: recalculate scroll position, instead of zeroing? */
|
||||
} else {
|
||||
if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
|
||||
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,23 +152,29 @@ void __CDECL evnt_sb_redraw( COMPONENT *c, long buff[8] )
|
||||
|
||||
static void __CDECL evnt_sb_click( COMPONENT *c, long buff[8] )
|
||||
{
|
||||
static bool prevstate;
|
||||
short sbuff[8], mx, my;
|
||||
LGRECT work;
|
||||
mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
|
||||
if( evnt.mx >= work.g_x + (work.g_w - MOVER_WH) && evnt.mx <= work.g_x + work.g_w &&
|
||||
evnt.my >= work.g_y + (work.g_h - MOVER_WH) && evnt.my <= work.g_y + work.g_h ) {
|
||||
/* click into the mover region */
|
||||
/* click into the resizer region */
|
||||
struct gui_window * g;
|
||||
for( g = window_list; g; g=g->next ) {
|
||||
if( g->root->statusbar->comp == c ) {
|
||||
if( g->root->statusbar->resize_init == true ){
|
||||
g->root->statusbar->resize_init = false;
|
||||
g->root->statusbar->resize_delta_x = g->root->loc.g_x+g->root->loc.g_w - evnt.mx;
|
||||
g->root->statusbar->resize_delta_y = g->root->loc.g_y+g->root->loc.g_h - evnt.my;
|
||||
}
|
||||
sbuff[0] = WM_SIZED;
|
||||
sbuff[1] = (short)buff[0];
|
||||
sbuff[2] = 0;
|
||||
sbuff[3] = g->root->handle->handle;
|
||||
sbuff[4] = g->root->loc.g_x;
|
||||
sbuff[5] = g->root->loc.g_y;
|
||||
sbuff[6] = g->root->loc.g_w;
|
||||
sbuff[7] = g->root->loc.g_h;
|
||||
sbuff[6] = evnt.mx - sbuff[4] + g->root->statusbar->resize_delta_x;
|
||||
sbuff[7] = evnt.my - sbuff[5] + g->root->statusbar->resize_delta_y;
|
||||
evnt_window_resize( g->root->handle, sbuff, g );
|
||||
}
|
||||
}
|
||||
@ -178,6 +184,7 @@ static void __CDECL evnt_sb_click( COMPONENT *c, long buff[8] )
|
||||
CMP_STATUSBAR sb_create( struct gui_window * gw )
|
||||
{
|
||||
CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
|
||||
s->resize_init = true;
|
||||
s->attached = false;
|
||||
s->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, STATUSBAR_HEIGHT, 0);
|
||||
s->comp->rect.g_h = STATUSBAR_HEIGHT;
|
||||
|
@ -29,6 +29,9 @@ struct s_statusbar
|
||||
char text[STATUSBAR_MAX_SLEN+1];
|
||||
size_t textlen;
|
||||
bool attached;
|
||||
bool resize_init;
|
||||
short resize_delta_x;
|
||||
short resize_delta_y;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user