mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-04-08 15:22:54 +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/search.h"
|
||||||
#include "atari/osspec.h"
|
#include "atari/osspec.h"
|
||||||
|
|
||||||
|
|
||||||
bool cfg_rt_resize = false;
|
|
||||||
bool cfg_rt_move = false;
|
|
||||||
extern void * h_gem_rsrc;
|
extern void * h_gem_rsrc;
|
||||||
extern struct gui_window *input_window;
|
extern struct gui_window *input_window;
|
||||||
extern GEM_PLOTTER plotter;
|
extern GEM_PLOTTER plotter;
|
||||||
@ -228,6 +225,8 @@ static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !a ) {
|
if( !a ) {
|
||||||
|
if( prev_sb )
|
||||||
|
gw->root->statusbar->resize_init = true;
|
||||||
if( prev_url || prev_sb ) {
|
if( prev_url || prev_sb ) {
|
||||||
gem_set_cursor( &gem_cursors.arrow );
|
gem_set_cursor( &gem_cursors.arrow );
|
||||||
prev_url = false;
|
prev_url = false;
|
||||||
@ -306,12 +305,8 @@ int window_create( struct gui_window * gw, struct browser_window * bw, unsigned
|
|||||||
/* Event Handlers: */
|
/* Event Handlers: */
|
||||||
EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
|
EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
|
||||||
/* capture resize/move events so we can handle that manually */
|
/* capture resize/move events so we can handle that manually */
|
||||||
if( !cfg_rt_resize ) {
|
EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw );
|
||||||
EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw );
|
if( !option_atari_realtime_move ) {
|
||||||
} else {
|
|
||||||
EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
|
|
||||||
}
|
|
||||||
if( !cfg_rt_move ) {
|
|
||||||
EvntDataAttach( gw->root->handle, WM_MOVED, evnt_window_move, gw );
|
EvntDataAttach( gw->root->handle, WM_MOVED, evnt_window_move, gw );
|
||||||
} else {
|
} else {
|
||||||
EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
|
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)
|
void window_open( struct gui_window * gw)
|
||||||
{
|
{
|
||||||
LGRECT br;
|
LGRECT br;
|
||||||
|
GRECT dim;
|
||||||
WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
|
WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
|
||||||
WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
|
WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
|
||||||
/* apply focus to the root frame: */
|
/* 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 );
|
mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
|
||||||
/* recompute the nested component sizes and positions: */
|
/* recompute the nested component sizes and positions: */
|
||||||
browser_update_rects( gw );
|
browser_update_rects( gw );
|
||||||
|
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
|
||||||
browser_get_rect( gw, BR_CONTENT, &br );
|
browser_get_rect( gw, BR_CONTENT, &br );
|
||||||
plotter->move( plotter, br.g_x, br.g_y );
|
plotter->move( plotter, br.g_x, br.g_y );
|
||||||
plotter->resize( plotter, br.g_w, br.g_h );
|
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 wx, wy, wh, ww, nx, ny;
|
||||||
short r;
|
short r;
|
||||||
short xoff, yoff;
|
short xoff, yoff;
|
||||||
if( cfg_rt_move ) {
|
if( option_atari_realtime_move ) {
|
||||||
std_mvd( win, buff, &app );
|
std_mvd( win, buff, &app );
|
||||||
evnt_window_rt_resize( win, buff, data );
|
evnt_window_rt_resize( win, buff, data );
|
||||||
} else {
|
} 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 )
|
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 wx, wy, wh, ww, nw, nh;
|
||||||
short r;
|
short r;
|
||||||
graf_mkstate( &mx, &my, &mb, &ks );
|
|
||||||
if( cfg_rt_resize ) {
|
// graf_mkstate( &mx, &my, &mb, &ks );
|
||||||
std_szd( win, buff, &app );
|
wind_get( win->handle, WF_CURRXYWH, &wx, &wy, &ww, &wh );
|
||||||
evnt_window_rt_resize( win, buff, data );
|
r = graf_rubberbox(wx, wy, 20, 20, &nw, &nh);
|
||||||
} else {
|
if( nw < 40 && nw < 40 )
|
||||||
wind_get( win->handle, WF_CURRXYWH, &wx, &wy, &ww, &wh );
|
return;
|
||||||
r = graf_rubberbox(wx, wy, 20, 20, &nw, &nh);
|
buff[4] = wx;
|
||||||
if( nw < 40 && nw < 40 )
|
buff[5] = wy;
|
||||||
return;
|
buff[6] = nw;
|
||||||
buff[4] = wx;
|
buff[7] = nh;
|
||||||
buff[5] = wy;
|
std_szd( win, buff, &app );
|
||||||
buff[6] = nw;
|
evnt_window_rt_resize( win, buff, data );
|
||||||
buff[7] = nh;
|
|
||||||
std_szd( win, buff, &app );
|
|
||||||
evnt_window_rt_resize( win, buff, data );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* perform the actual resize */
|
/* 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;
|
short x,y,w,h;
|
||||||
struct gui_window * gw;
|
struct gui_window * gw;
|
||||||
LGRECT rect;
|
LGRECT rect;
|
||||||
bool resized;
|
|
||||||
bool moved;
|
|
||||||
|
|
||||||
if(buff[0] == WM_FORCE_MOVE ) {
|
if(buff[0] == WM_FORCE_MOVE ) {
|
||||||
std_mvd(win, buff, &app);
|
std_mvd(win, buff, &app);
|
||||||
std_szd(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;
|
gw = (struct gui_window *)data;
|
||||||
|
|
||||||
assert( gw != NULL );
|
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 ){
|
if(gw->root->loc.g_w != w || gw->root->loc.g_h != h ){
|
||||||
resized = true;
|
|
||||||
/* report resize to component interface: */
|
/* report resize to component interface: */
|
||||||
browser_update_rects( gw );
|
browser_update_rects( gw );
|
||||||
|
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
|
||||||
browser_get_rect( gw, BR_CONTENT, &rect );
|
browser_get_rect( gw, BR_CONTENT, &rect );
|
||||||
if( gw->browser->bw->current_content != NULL )
|
if( gw->browser->bw->current_content != NULL )
|
||||||
browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
|
browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
|
||||||
gw->root->toolbar->url.scrollx = 0;
|
gw->root->toolbar->url.scrollx = 0;
|
||||||
window_redraw_controls(gw, 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 void __CDECL evnt_sb_click( COMPONENT *c, long buff[8] )
|
||||||
{
|
{
|
||||||
|
static bool prevstate;
|
||||||
short sbuff[8], mx, my;
|
short sbuff[8], mx, my;
|
||||||
LGRECT work;
|
LGRECT work;
|
||||||
mt_CompGetLGrect(&app, c, WF_WORKXYWH, &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 &&
|
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 ) {
|
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;
|
struct gui_window * g;
|
||||||
for( g = window_list; g; g=g->next ) {
|
for( g = window_list; g; g=g->next ) {
|
||||||
if( g->root->statusbar->comp == c ) {
|
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[0] = WM_SIZED;
|
||||||
sbuff[1] = (short)buff[0];
|
sbuff[1] = (short)buff[0];
|
||||||
sbuff[2] = 0;
|
sbuff[2] = 0;
|
||||||
sbuff[3] = g->root->handle->handle;
|
sbuff[3] = g->root->handle->handle;
|
||||||
sbuff[4] = g->root->loc.g_x;
|
sbuff[4] = g->root->loc.g_x;
|
||||||
sbuff[5] = g->root->loc.g_y;
|
sbuff[5] = g->root->loc.g_y;
|
||||||
sbuff[6] = g->root->loc.g_w;
|
sbuff[6] = evnt.mx - sbuff[4] + g->root->statusbar->resize_delta_x;
|
||||||
sbuff[7] = g->root->loc.g_h;
|
sbuff[7] = evnt.my - sbuff[5] + g->root->statusbar->resize_delta_y;
|
||||||
evnt_window_resize( g->root->handle, sbuff, g );
|
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 sb_create( struct gui_window * gw )
|
||||||
{
|
{
|
||||||
CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
|
CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
|
||||||
|
s->resize_init = true;
|
||||||
s->attached = false;
|
s->attached = false;
|
||||||
s->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, STATUSBAR_HEIGHT, 0);
|
s->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, STATUSBAR_HEIGHT, 0);
|
||||||
s->comp->rect.g_h = STATUSBAR_HEIGHT;
|
s->comp->rect.g_h = STATUSBAR_HEIGHT;
|
||||||
|
@ -29,6 +29,9 @@ struct s_statusbar
|
|||||||
char text[STATUSBAR_MAX_SLEN+1];
|
char text[STATUSBAR_MAX_SLEN+1];
|
||||||
size_t textlen;
|
size_t textlen;
|
||||||
bool attached;
|
bool attached;
|
||||||
|
bool resize_init;
|
||||||
|
short resize_delta_x;
|
||||||
|
short resize_delta_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user