From cbeffd4c5f4ac2ecbb2cfc97a705441a20ec8f23 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Fri, 9 Sep 2011 22:18:49 +0000 Subject: Keep Mouse tracking limited to input_window. svn path=/trunk/netsurf/; revision=12783 --- atari/browser.c | 14 ++++++++++++-- atari/browser_win.c | 7 +++++-- atari/gui.c | 21 ++++++++++++++++++--- atari/misc.c | 17 +++++++++++++++++ atari/misc.h | 1 + 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/atari/browser.c b/atari/browser.c index 6c8f6429e..c193f2ddb 100755 --- a/atari/browser.c +++ b/atari/browser.c @@ -242,6 +242,10 @@ static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * dat int value = BROWSER_SCROLL_SVAL; struct gui_window * gw = data; LGRECT cwork; + + if( input_window == NULL || input_window != gw ) { + return; + } browser_get_rect( gw, BR_CONTENT, &cwork ); switch( buff[4] ) { @@ -265,11 +269,15 @@ void __CDECL browser_evnt_slider( WINDOW *win, short buff[8], void * data) { int dx = buff[4]; int dy = buff[5]; - struct gui_window * gw = data; GRECT work, screen; + struct gui_window * gw = data; if (!dx && !dy) return; + if( input_window == NULL || input_window != gw ) { + return; + } + /* update the sliders _before_ we call redraw (which might depend on the slider possitions) */ mt_WindSlider( &app, win, (dx?HSLIDER:0) | (dy?VSLIDER:0) ); @@ -291,7 +299,9 @@ static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data uint32_t tnow = clock()*1000 / CLOCKS_PER_SEC; LGRECT cwork; struct gui_window * gw = data; - input_window = gw; + if( input_window != gw ) { + return; + } window_set_focus( gw, BROWSER, (void*)gw->browser ); browser_get_rect( gw, BR_CONTENT, &cwork ); mx = evnt.mx - cwork.g_x; diff --git a/atari/browser_win.c b/atari/browser_win.c index 572e3be5c..427ddedad 100755 --- a/atari/browser_win.c +++ b/atari/browser_win.c @@ -105,7 +105,7 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data } /* - this gets called at end of gui poll to track the mouse state and + track the mouse state and finally checks for released buttons. */ static void window_track_mouse_state( LGRECT * bwrect, bool within, short mx, short my, short mbut, short mkstate ){ @@ -150,7 +150,6 @@ static void window_track_mouse_state( LGRECT * bwrect, bool within, short mx, sh if( !(mbut & i) ) { if( mouse_hold_start[i-1] > 0 ) { mouse_hold_start[i-1] = 0; - /* TODO: not just use the input window browser, find the right one by component! */ if( i==1 ) { LOG(("Drag for %d ended", i)); bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 ) ; @@ -192,6 +191,10 @@ static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data) if( gw == NULL) return; + if( gw != input_window ){ + return; + } + graf_mkstate(&mx, &my, &mbut, &mkstate); browser_get_rect( gw, BR_CONTENT, &bwbox ); diff --git a/atari/gui.c b/atari/gui.c index cbcedac7d..da5953997 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -136,11 +136,27 @@ void gui_poll(bool active) /* this can be improved a lot under XaAES - there is an event for mouse move */ if( mx >= winloc[0] && mx <= winloc[0] + winloc[2] && my >= winloc[1] && my <= winloc[1] + winloc[3] ){ + /* Mouse is within the top window area */ evnt.m1_flag = MO_LEAVE; evnt.m1_w = evnt.m1_h = 1; evnt.m1_x = mx; evnt.m1_y = my; } else { + /* Mouse is outside of top window area. */ + if( evnt.m1_flag == MO_LEAVE ) { + /* Previous move was inside the top window area */ + struct gui_window * gw = input_window; + if(gw != NULL && gw->browser != NULL && gw->browser->bw != NULL ){ + /* reset mouse state */ + /* you could also track further, without reset, but */ + /* when the mouse moves into native scroller area, the mouse is */ + /* the native scroll bar code gets in between.. */ + mouse_hold_start[0] = 0; + mouse_hold_start[1] = 0; + bmstate = 0; + browser_window_mouse_track( gw->browser->bw, bmstate, mx, my ); + } + } evnt.m1_flag = MO_ENTER; evnt.m1_w = winloc[2]; evnt.m1_h = winloc[3]; @@ -149,8 +165,7 @@ void gui_poll(bool active) } } - /*printf("time: %d, active: %d, pending: %d\n", evnt.timer, - active, browser_reformat_pending );*/ + /*printf("time: %d, active: %d\n", evnt.timer, active );*/ if( active ) { if( clock() >= next_poll ) { evnt.timer = 0; @@ -160,7 +175,7 @@ void gui_poll(bool active) } } else { flags |= MU_TIMER; - EvntWindom( flags ); + EvntWindom( flags ); } struct gui_window * g; diff --git a/atari/misc.c b/atari/misc.c index fc1d6a661..18130e3b9 100755 --- a/atari/misc.c +++ b/atari/misc.c @@ -100,6 +100,23 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } +struct gui_window * find_gui_window( WINDOW * win ){ + + struct gui_window * gw; + gw = window_list; + + if( win == NULL ) + return( NULL ); + + while( gw != NULL) { + if( gw->root->handle == win ) { + return( gw ); + } + else + gw = gw->next; + } + return( NULL ); +} struct gui_window * find_cmp_window( COMPONENT * c ) { diff --git a/atari/misc.h b/atari/misc.h index 216ab17b0..2642b395f 100755 --- a/atari/misc.h +++ b/atari/misc.h @@ -30,6 +30,7 @@ lbuf[7] = (long)sbuf[7]; +struct gui_window * find_gui_window( WINDOW * win ); struct gui_window * find_cmp_window( COMPONENT * c ); OBJECT *get_tree( int idx ); char *get_rsc_string( int idx ); -- cgit v1.2.3