When the mouse is grabbed, send the application the motion associated with
authorSam Lantinga <slouken@lokigames.com>
Tue, 26 Jun 2001 17:40:59 +0000
changeset 822bddc38a9f5d
parent 81 1a2723474f12
child 83 4c8b9babaae4
When the mouse is grabbed, send the application the motion associated with
the enter/leave notify events.
src/video/x11/SDL_x11events.c
     1.1 --- a/src/video/x11/SDL_x11events.c	Mon Jun 25 22:16:44 2001 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Tue Jun 26 17:40:59 2001 +0000
     1.3 @@ -58,6 +58,7 @@
     1.4  
     1.5  /* Define this if you want to debug X11 events */
     1.6  /*#define DEBUG_XEVENTS*/
     1.7 +#define DEBUG_XEVENTS
     1.8  
     1.9  /* The translation tables from an X11 keysym to a SDL keysym */
    1.10  static SDLKey ODD_keymap[256];
    1.11 @@ -167,7 +168,7 @@
    1.12  	    /* Gaining mouse coverage? */
    1.13  	    case EnterNotify: {
    1.14  #ifdef DEBUG_XEVENTS
    1.15 -printf("EnterNotify!\n");
    1.16 +printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y);
    1.17  if ( xevent.xcrossing.mode == NotifyGrab )
    1.18  printf("Mode: NotifyGrab\n");
    1.19  if ( xevent.xcrossing.mode == NotifyUngrab )
    1.20 @@ -175,7 +176,13 @@
    1.21  #endif
    1.22  		if ( (xevent.xcrossing.mode != NotifyGrab) &&
    1.23  		     (xevent.xcrossing.mode != NotifyUngrab) ) {
    1.24 -			posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.25 +			if ( this->input_grab == SDL_GRAB_OFF ) {
    1.26 +				posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.27 +			} else {
    1.28 +				posted = SDL_PrivateMouseMotion(0, 0,
    1.29 +						xevent.xcrossing.x,
    1.30 +						xevent.xcrossing.y);
    1.31 +			}
    1.32  		}
    1.33  	    }
    1.34  	    break;
    1.35 @@ -183,7 +190,7 @@
    1.36  	    /* Losing mouse coverage? */
    1.37  	    case LeaveNotify: {
    1.38  #ifdef DEBUG_XEVENTS
    1.39 -printf("LeaveNotify!\n");
    1.40 +printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y);
    1.41  if ( xevent.xcrossing.mode == NotifyGrab )
    1.42  printf("Mode: NotifyGrab\n");
    1.43  if ( xevent.xcrossing.mode == NotifyUngrab )
    1.44 @@ -191,7 +198,13 @@
    1.45  #endif
    1.46  		if ( (xevent.xcrossing.mode != NotifyGrab) &&
    1.47  		     (xevent.xcrossing.mode != NotifyUngrab) ) {
    1.48 -			posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.49 +			if ( this->input_grab == SDL_GRAB_OFF ) {
    1.50 +				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.51 +			} else {
    1.52 +				posted = SDL_PrivateMouseMotion(0, 0,
    1.53 +						xevent.xcrossing.x,
    1.54 +						xevent.xcrossing.y);
    1.55 +			}
    1.56  		}
    1.57  	    }
    1.58  	    break;
    1.59 @@ -246,6 +259,9 @@
    1.60  					posted = X11_WarpedMotion(this,&xevent);
    1.61  				}
    1.62  			} else {
    1.63 +#ifdef DEBUG_MOTION
    1.64 +  printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
    1.65 +#endif
    1.66  				posted = SDL_PrivateMouseMotion(0, 0,
    1.67  						xevent.xmotion.x,
    1.68  						xevent.xmotion.y);