Better mouse lose/gain focus
authorPatrice Mandin <patmandin@gmail.com>
Fri, 03 Jun 2005 08:18:55 +0000
changeset 1067f73b199bcd75
parent 1066 671bbd773c8a
child 1068 adb547913775
Better mouse lose/gain focus
src/video/gem/SDL_gemevents.c
     1.1 --- a/src/video/gem/SDL_gemevents.c	Thu Jun 02 22:02:18 2005 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Fri Jun 03 08:18:55 2005 +0000
     1.3 @@ -140,14 +140,23 @@
     1.4  	{
     1.5  		int quit, resultat;
     1.6  		short buffer[8], kc;
     1.7 +		short x2,y2,w2,h2;
     1.8  
     1.9  		quit = 0;
    1.10  
    1.11 +		event_mask = MU_MESAG|MU_TIMER|MU_KEYBD;
    1.12 +		if (!GEM_fullscreen && (GEM_handle>=0)) {
    1.13 +			wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.14 +			event_mask |= MU_M1|MU_M2;
    1.15 +		} else {
    1.16 +			x2=y2=w2=h2=0;
    1.17 +		}
    1.18 +
    1.19  		resultat = evnt_multi(
    1.20 -			MU_MESAG|MU_TIMER|MU_KEYBD,
    1.21 +			event_mask,
    1.22  			0,0,0,
    1.23 -			0,0,0,0,0,
    1.24 -			0,0,0,0,0,
    1.25 +			MO_ENTER,x2,y2,w2,h2,
    1.26 +			MO_LEAVE,x2,y2,w2,h2,
    1.27  			buffer,
    1.28  			10,
    1.29  			&dummy,&dummy,&dummy,&kstate,&kc,&dummy
    1.30 @@ -167,6 +176,18 @@
    1.31  			}
    1.32  		}
    1.33  
    1.34 +		/* Mouse entering/leaving window */
    1.35 +		if (resultat & MU_M1) {
    1.36 +			if (this->input_grab == SDL_GRAB_OFF) {
    1.37 +				SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.38 +			}
    1.39 +		}
    1.40 +		if (resultat & MU_M2) {
    1.41 +			if (this->input_grab == SDL_GRAB_OFF) {
    1.42 +				SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.43 +			}
    1.44 +		}
    1.45 +
    1.46  		/* Timer event ? */
    1.47  		if ((resultat & MU_TIMER) || quit)
    1.48  			break;
    1.49 @@ -224,9 +245,6 @@
    1.50  		case WM_TOPPED:
    1.51  			wind_set(message[3],WF_TOP,message[4],0,0,0);
    1.52  			SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
    1.53 -			if (this->input_grab == SDL_GRAB_OFF) {
    1.54 -				SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.55 -			}
    1.56  			break;
    1.57  		case WM_REDRAW:
    1.58  			if (!GEM_lock_redraw) {
    1.59 @@ -289,9 +307,6 @@
    1.60  		case WM_BOTTOMED:
    1.61  		case WM_UNTOPPED:
    1.62  			SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
    1.63 -			if (this->input_grab == SDL_GRAB_OFF) {
    1.64 -				SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.65 -			}
    1.66  			break;
    1.67  	}
    1.68  	
    1.69 @@ -326,6 +341,11 @@
    1.70  	static short prevmousex=0, prevmousey=0, prevmouseb=0;
    1.71  	short x2, y2, w2, h2;
    1.72  
    1.73 +	/* Don't return mouse events if out of window */
    1.74 +	if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0) {
    1.75 +		return;
    1.76 +	}
    1.77 +
    1.78  	/* Retrieve window coords, and generate mouse events accordingly */
    1.79  	x2 = y2 = 0;
    1.80  	w2 = VDI_w;