Keep Mouse tracking limited to input_window.

svn path=/trunk/netsurf/; revision=12783
This commit is contained in:
Ole Loots 2011-09-09 22:18:49 +00:00
parent 6cde3888af
commit cbeffd4c5f
5 changed files with 53 additions and 7 deletions

View File

@ -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;

View File

@ -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 );

View File

@ -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;

View File

@ -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 )
{

View File

@ -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 );