comparison src/video/x11/SDL_x11events.c @ 82:2bddc38a9f5d

When the mouse is grabbed, send the application the motion associated with the enter/leave notify events.
author Sam Lantinga <slouken@lokigames.com>
date Tue, 26 Jun 2001 17:40:59 +0000
parents b0ae59d0f3ee
children 4c8b9babaae4
comparison
equal deleted inserted replaced
81:1a2723474f12 82:2bddc38a9f5d
56 #include "SDL_x11events_c.h" 56 #include "SDL_x11events_c.h"
57 57
58 58
59 /* Define this if you want to debug X11 events */ 59 /* Define this if you want to debug X11 events */
60 /*#define DEBUG_XEVENTS*/ 60 /*#define DEBUG_XEVENTS*/
61 #define DEBUG_XEVENTS
61 62
62 /* The translation tables from an X11 keysym to a SDL keysym */ 63 /* The translation tables from an X11 keysym to a SDL keysym */
63 static SDLKey ODD_keymap[256]; 64 static SDLKey ODD_keymap[256];
64 static SDLKey MISC_keymap[256]; 65 static SDLKey MISC_keymap[256];
65 SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc, 66 SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
165 switch (xevent.type) { 166 switch (xevent.type) {
166 167
167 /* Gaining mouse coverage? */ 168 /* Gaining mouse coverage? */
168 case EnterNotify: { 169 case EnterNotify: {
169 #ifdef DEBUG_XEVENTS 170 #ifdef DEBUG_XEVENTS
170 printf("EnterNotify!\n"); 171 printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y);
171 if ( xevent.xcrossing.mode == NotifyGrab ) 172 if ( xevent.xcrossing.mode == NotifyGrab )
172 printf("Mode: NotifyGrab\n"); 173 printf("Mode: NotifyGrab\n");
173 if ( xevent.xcrossing.mode == NotifyUngrab ) 174 if ( xevent.xcrossing.mode == NotifyUngrab )
174 printf("Mode: NotifyUngrab\n"); 175 printf("Mode: NotifyUngrab\n");
175 #endif 176 #endif
176 if ( (xevent.xcrossing.mode != NotifyGrab) && 177 if ( (xevent.xcrossing.mode != NotifyGrab) &&
177 (xevent.xcrossing.mode != NotifyUngrab) ) { 178 (xevent.xcrossing.mode != NotifyUngrab) ) {
178 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); 179 if ( this->input_grab == SDL_GRAB_OFF ) {
180 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
181 } else {
182 posted = SDL_PrivateMouseMotion(0, 0,
183 xevent.xcrossing.x,
184 xevent.xcrossing.y);
185 }
179 } 186 }
180 } 187 }
181 break; 188 break;
182 189
183 /* Losing mouse coverage? */ 190 /* Losing mouse coverage? */
184 case LeaveNotify: { 191 case LeaveNotify: {
185 #ifdef DEBUG_XEVENTS 192 #ifdef DEBUG_XEVENTS
186 printf("LeaveNotify!\n"); 193 printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y);
187 if ( xevent.xcrossing.mode == NotifyGrab ) 194 if ( xevent.xcrossing.mode == NotifyGrab )
188 printf("Mode: NotifyGrab\n"); 195 printf("Mode: NotifyGrab\n");
189 if ( xevent.xcrossing.mode == NotifyUngrab ) 196 if ( xevent.xcrossing.mode == NotifyUngrab )
190 printf("Mode: NotifyUngrab\n"); 197 printf("Mode: NotifyUngrab\n");
191 #endif 198 #endif
192 if ( (xevent.xcrossing.mode != NotifyGrab) && 199 if ( (xevent.xcrossing.mode != NotifyGrab) &&
193 (xevent.xcrossing.mode != NotifyUngrab) ) { 200 (xevent.xcrossing.mode != NotifyUngrab) ) {
194 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); 201 if ( this->input_grab == SDL_GRAB_OFF ) {
202 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
203 } else {
204 posted = SDL_PrivateMouseMotion(0, 0,
205 xevent.xcrossing.x,
206 xevent.xcrossing.y);
207 }
195 } 208 }
196 } 209 }
197 break; 210 break;
198 211
199 /* Gaining input focus? */ 212 /* Gaining input focus? */
244 xevent.xmotion.y_root); 257 xevent.xmotion.y_root);
245 } else { 258 } else {
246 posted = X11_WarpedMotion(this,&xevent); 259 posted = X11_WarpedMotion(this,&xevent);
247 } 260 }
248 } else { 261 } else {
262 #ifdef DEBUG_MOTION
263 printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
264 #endif
249 posted = SDL_PrivateMouseMotion(0, 0, 265 posted = SDL_PrivateMouseMotion(0, 0,
250 xevent.xmotion.x, 266 xevent.xmotion.x,
251 xevent.xmotion.y); 267 xevent.xmotion.y);
252 } 268 }
253 } 269 }