Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11events.c @ 4518:a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Unfortunately, this doesn't work. I also noticed that maximizing doesn't work as well. Also xprop hangs when trying to list properties of SDL windows.... ???
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 13 Jul 2010 23:11:10 -0700 |
parents | 15d2c6f40c48 |
children | 62d693e01a24 |
comparison
equal
deleted
inserted
replaced
4517:7b5e4396bcaa | 4518:a956a315fe67 |
---|---|
32 #include "../../events/SDL_mouse_c.h" | 32 #include "../../events/SDL_mouse_c.h" |
33 | 33 |
34 #include "SDL_timer.h" | 34 #include "SDL_timer.h" |
35 #include "SDL_syswm.h" | 35 #include "SDL_syswm.h" |
36 | 36 |
37 /*#define DEBUG_XEVENTS*/ | 37 #define DEBUG_XEVENTS |
38 | 38 |
39 static void | 39 static void |
40 X11_DispatchEvent(_THIS) | 40 X11_DispatchEvent(_THIS) |
41 { | 41 { |
42 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; | 42 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
43 Display *display = videodata->display; | |
43 SDL_WindowData *data; | 44 SDL_WindowData *data; |
44 XEvent xevent; | 45 XEvent xevent; |
45 int i; | 46 int i; |
46 | 47 |
47 SDL_zero(xevent); /* valgrind fix. --ryan. */ | 48 SDL_zero(xevent); /* valgrind fix. --ryan. */ |
48 XNextEvent(videodata->display, &xevent); | 49 XNextEvent(display, &xevent); |
49 | 50 |
50 /* filter events catchs XIM events and sends them to the correct | 51 /* filter events catchs XIM events and sends them to the correct |
51 handler */ | 52 handler */ |
52 if (XFilterEvent(&xevent, None) == True) { | 53 if (XFilterEvent(&xevent, None) == True) { |
53 #if 0 | 54 #if 0 |
78 } | 79 } |
79 } | 80 } |
80 if (!data) { | 81 if (!data) { |
81 return; | 82 return; |
82 } | 83 } |
84 | |
83 #if 0 | 85 #if 0 |
84 printf("type = %d display = %d window = %d\n", | 86 printf("type = %d display = %d window = %d\n", |
85 xevent.type, xevent.xany.display, xevent.xany.window); | 87 xevent.type, xevent.xany.display, xevent.xany.window); |
86 #endif | 88 #endif |
87 switch (xevent.type) { | 89 switch (xevent.type) { |
180 #endif | 182 #endif |
181 SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); | 183 SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); |
182 #if 0 | 184 #if 0 |
183 if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { | 185 if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { |
184 int min_keycode, max_keycode; | 186 int min_keycode, max_keycode; |
185 XDisplayKeycodes(videodata->display, &min_keycode, | 187 XDisplayKeycodes(display, &min_keycode, &max_keycode); |
186 &max_keycode); | 188 keysym = XKeycodeToKeysym(display, keycode, 0); |
187 keysym = XKeycodeToKeysym(videodata->display, keycode, 0); | |
188 fprintf(stderr, | 189 fprintf(stderr, |
189 "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n", | 190 "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n", |
190 keycode, keycode - min_keycode, keysym, | 191 keycode, keycode - min_keycode, keysym, |
191 XKeysymToString(keysym)); | 192 XKeysymToString(keysym)); |
192 } | 193 } |
287 case ButtonRelease:{ | 288 case ButtonRelease:{ |
288 SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button); | 289 SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button); |
289 } | 290 } |
290 break; | 291 break; |
291 | 292 |
293 case PropertyNotify:{ | |
294 #ifdef DEBUG_XEVENTS | |
295 char *name = XGetAtomName(display, xevent.xproperty.atom); | |
296 printf("PropertyNotify (atom = %s)\n", name ? name : "NULL"); | |
297 if (name) { | |
298 XFree(name); | |
299 } | |
300 #endif | |
301 if (xevent.xproperty.atom == videodata->_NET_WM_STATE) { | |
302 unsigned char *propdata; | |
303 int status, real_format; | |
304 Atom real_type; | |
305 unsigned long items_read, items_left, i; | |
306 | |
307 #ifdef DEBUG_XEVENTS | |
308 printf("_NET_WM_STATE: {"); | |
309 #endif | |
310 status = XGetWindowProperty(display, data->xwindow, videodata->_NET_WM_STATE, 0L, 8192L, False, XA_ATOM, &real_type, &real_format, &items_read, &items_left, &propdata); | |
311 if (status == Success) { | |
312 Atom *atoms = (Atom *)propdata; | |
313 for (i = 0; i < items_read; i++) { | |
314 if (atoms[i] == videodata->_NET_WM_STATE_HIDDEN) { | |
315 #ifdef DEBUG_XEVENTS | |
316 printf(" _NET_WM_STATE_HIDDEN"); | |
317 #endif | |
318 } | |
319 if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_HORZ) { | |
320 #ifdef DEBUG_XEVENTS | |
321 printf(" _NET_WM_STATE_MAXIMIZED_HORZ"); | |
322 #endif | |
323 } | |
324 if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_VERT) { | |
325 #ifdef DEBUG_XEVENTS | |
326 printf(" _NET_WM_STATE_MAXIMIZED_VERT"); | |
327 #endif | |
328 } | |
329 if (atoms[i] == videodata->_NET_WM_STATE_FULLSCREEN) { | |
330 #ifdef DEBUG_XEVENTS | |
331 printf(" _NET_WM_STATE_FULLSCREEN"); | |
332 #endif | |
333 } | |
334 } | |
335 } | |
336 #ifdef DEBUG_XEVENTS | |
337 printf(" }\n"); | |
338 #endif | |
339 } | |
340 } | |
341 break; | |
342 | |
292 /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ | 343 /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ |
293 case SelectionRequest: { | 344 case SelectionRequest: { |
294 Display *display = videodata->display; | |
295 XSelectionRequestEvent *req; | 345 XSelectionRequestEvent *req; |
296 XEvent sevent; | 346 XEvent sevent; |
297 int seln_format; | 347 int seln_format; |
298 unsigned long nbytes; | 348 unsigned long nbytes; |
299 unsigned long overflow; | 349 unsigned long overflow; |