src/video/gem/SDL_gemevents.c
branchSDL-1.2
changeset 4060 0b4ebec67cad
parent 4059 57b017e6aebf
child 4159 a1b03ba2fcd0
     1.1 --- a/src/video/gem/SDL_gemevents.c	Fri Jul 13 16:09:16 2007 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Fri Jul 13 18:44:43 2007 +0000
     1.3 @@ -89,11 +89,8 @@
     1.4  		if (!GEM_fullscreen && (GEM_handle>=0)) {
     1.5  			wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
     1.6  			event_mask |= MU_M1;
     1.7 -			if ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
     1.8 -				mouse_event = MO_LEAVE;				
     1.9 -			} else {
    1.10 -				mouse_event = MO_ENTER;				
    1.11 -			}
    1.12 +			mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
    1.13 +				== SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER;
    1.14  		}
    1.15  
    1.16  		resultat = evnt_multi(
    1.17 @@ -123,22 +120,11 @@
    1.18  		/* Mouse entering/leaving window */
    1.19  		if (resultat & MU_M1) {
    1.20  			if (this->input_grab == SDL_GRAB_OFF) {
    1.21 -				if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
    1.22 -					SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.23 -					if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
    1.24 -						graf_mouse(ARROW, NULL);
    1.25 -					}
    1.26 -				} else {
    1.27 -					SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.28 -					if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
    1.29 -						if (GEM_cursor == (void *) -1) {
    1.30 -							graf_mouse(M_OFF, NULL);
    1.31 -						} else if (GEM_cursor) {
    1.32 -							graf_mouse(USER_DEF, GEM_cursor->mform_p);
    1.33 -						}
    1.34 -					}
    1.35 -				}
    1.36 +				/* Switch mouse focus state */
    1.37 +				SDL_PrivateAppActive((mouse_event == MO_ENTER),
    1.38 +					SDL_APPMOUSEFOCUS);
    1.39  			}
    1.40 +			GEM_CheckMouseMode(this);
    1.41  		}
    1.42  
    1.43  		/* Timer event ? */
    1.44 @@ -182,10 +168,10 @@
    1.45  
    1.46  static int do_messages(_THIS, short *message)
    1.47  {
    1.48 -	int quit, posted;
    1.49 +	int quit, posted, check_mouse_mode;
    1.50  	short x2,y2,w2,h2;
    1.51  
    1.52 -	quit=0;
    1.53 +	quit = check_mouse_mode = 0;
    1.54  	switch (message[0]) {
    1.55  		case WM_CLOSED:
    1.56  		case AP_TERM:    
    1.57 @@ -203,6 +189,7 @@
    1.58  			if (VDI_setpalette) {
    1.59  				VDI_setpalette(this, VDI_curpalette);
    1.60  			}
    1.61 +			check_mouse_mode = 1;
    1.62  			break;
    1.63  		case WM_REDRAW:
    1.64  			if (!GEM_lock_redraw) {
    1.65 @@ -222,6 +209,7 @@
    1.66  				wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0);
    1.67  				GEM_refresh_name = SDL_FALSE;
    1.68  			}
    1.69 +			check_mouse_mode = 1;
    1.70  			break;
    1.71  		case WM_UNICONIFY:
    1.72  			wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
    1.73 @@ -234,6 +222,7 @@
    1.74  				wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
    1.75  				GEM_refresh_name = SDL_FALSE;
    1.76  			}
    1.77 +			check_mouse_mode = 1;
    1.78  			break;
    1.79  		case WM_SIZED:
    1.80  			wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
    1.81 @@ -270,8 +259,13 @@
    1.82  			if (VDI_setpalette) {
    1.83  				VDI_setpalette(this, VDI_oldpalette);
    1.84  			}
    1.85 +			check_mouse_mode = 1;
    1.86  			break;
    1.87  	}
    1.88 +
    1.89 +	if (check_mouse_mode) {
    1.90 +		GEM_CheckMouseMode(this);
    1.91 +	}
    1.92  	
    1.93  	return quit;
    1.94  }