annotate src/video/x11/SDL_x11events.c @ 5284:96a22141cf86 tip

Changed output directory of Universal libSDL.a for iOS to respect build configurations. Template generator was updated to reflect these changes as well.
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 12 Feb 2011 21:52:30 -0800
parents b530ef003506
children
rev   line source
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
5267
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
3 Copyright (C) 1997-2011 Sam Lantinga
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
2046
da8332c8f480 Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
24 #include <sys/types.h>
da8332c8f480 Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
25 #include <sys/time.h>
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
26 #include <signal.h>
2046
da8332c8f480 Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
27 #include <unistd.h>
4558
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
28 #include <limits.h> /* For INT_MAX */
2046
da8332c8f480 Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
29
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include "SDL_x11video.h"
4934
a5b86644c208 Fixed compiling X11 touch interface
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
31 #include "SDL_x11touch.h"
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "../../events/SDL_events_c.h"
2940
b93965a16fe0 Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
33 #include "../../events/SDL_mouse_c.h"
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
34 #include "../../events/SDL_touch_c.h"
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
36 #include "SDL_timer.h"
3241
08c5964f2a34 Fixed a few issues compiling with Mac OS X 10.6
Sam Lantinga <slouken@libsdl.org>
parents: 3195
diff changeset
37 #include "SDL_syswm.h"
08c5964f2a34 Fixed a few issues compiling with Mac OS X 10.6
Sam Lantinga <slouken@libsdl.org>
parents: 3195
diff changeset
38
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
39 #include <stdio.h>
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
40
4681
5378f2d0754f Fixed some Gesture bugs
Jim Grandpre <jim.tla@gmail.com>
parents: 4669
diff changeset
41 #ifdef SDL_INPUT_LINUXEV
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
42 //Touch Input/event* includes
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
43 #include <linux/input.h>
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
44 #include <fcntl.h>
4669
62e6a6e9720b Fixed x11 compile bugs.
jimtla
parents: 4661
diff changeset
45 #endif
4508
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
46 /*#define DEBUG_XEVENTS*/
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
47
4565
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
48 /* Check to see if this is a repeated key.
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
49 (idea shamelessly lifted from GII -- thanks guys! :)
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
50 */
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
51 static SDL_bool X11_KeyRepeat(Display *display, XEvent *event)
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
52 {
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
53 XEvent peekevent;
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
54
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
55 if (XPending(display)) {
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
56 XPeekEvent(display, &peekevent);
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
57 if ((peekevent.type == KeyPress) &&
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
58 (peekevent.xkey.keycode == event->xkey.keycode) &&
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
59 ((peekevent.xkey.time-event->xkey.time) < 2)) {
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
60 return SDL_TRUE;
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
61 }
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
62 }
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
63 return SDL_FALSE;
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
64 }
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
65
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 static void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 X11_DispatchEvent(_THIS)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
70 Display *display = videodata->display;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 SDL_WindowData *data;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 XEvent xevent;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 int i;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 SDL_zero(xevent); /* valgrind fix. --ryan. */
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
76 XNextEvent(display, &xevent);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
78 /* filter events catchs XIM events and sends them to the correct
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
79 handler */
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
80 if (XFilterEvent(&xevent, None) == True) {
2327
7b53a8401195 In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents: 2326
diff changeset
81 #if 0
2328
91e601d9df8b re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents: 2327
diff changeset
82 printf("Filtered event type = %d display = %d window = %d\n",
91e601d9df8b re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents: 2327
diff changeset
83 xevent.type, xevent.xany.display, xevent.xany.window);
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
84 #endif
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
85 return;
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
86 }
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
87
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 /* Send a SDL_SYSWMEVENT if the application wants them */
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
89 if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 SDL_SysWMmsg wmmsg;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 SDL_VERSION(&wmmsg.version);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 wmmsg.subsystem = SDL_SYSWM_X11;
5056
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 4934
diff changeset
94 wmmsg.msg.x11.event = xevent;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 SDL_SendSysWMEvent(&wmmsg);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 data = NULL;
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
99 if (videodata && videodata->windowlist) {
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
100 for (i = 0; i < videodata->numwindows; ++i) {
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
101 if ((videodata->windowlist[i] != NULL) &&
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
102 (videodata->windowlist[i]->xwindow == xevent.xany.window)) {
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
103 data = videodata->windowlist[i];
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
104 break;
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
105 }
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 if (!data) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 return;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 }
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
111
2327
7b53a8401195 In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents: 2326
diff changeset
112 #if 0
2328
91e601d9df8b re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents: 2327
diff changeset
113 printf("type = %d display = %d window = %d\n",
91e601d9df8b re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents: 2327
diff changeset
114 xevent.type, xevent.xany.display, xevent.xany.window);
2327
7b53a8401195 In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents: 2326
diff changeset
115 #endif
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 switch (xevent.type) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 /* Gaining mouse coverage? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 case EnterNotify:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 #ifdef DEBUG_XEVENTS
3195
08747e24a50f Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents: 3188
diff changeset
121 printf("EnterNotify! (%d,%d,%d)\n",
4558
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
122 xevent.xcrossing.x,
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
123 xevent.xcrossing.y,
3195
08747e24a50f Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents: 3188
diff changeset
124 xevent.xcrossing.mode);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 if (xevent.xcrossing.mode == NotifyGrab)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 printf("Mode: NotifyGrab\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 if (xevent.xcrossing.mode == NotifyUngrab)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 printf("Mode: NotifyUngrab\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 #endif
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
130 SDL_SetMouseFocus(data->window);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 /* Losing mouse coverage? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 case LeaveNotify:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 #ifdef DEBUG_XEVENTS
3195
08747e24a50f Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents: 3188
diff changeset
136 printf("LeaveNotify! (%d,%d,%d)\n",
4558
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
137 xevent.xcrossing.x,
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
138 xevent.xcrossing.y,
3195
08747e24a50f Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents: 3188
diff changeset
139 xevent.xcrossing.mode);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 if (xevent.xcrossing.mode == NotifyGrab)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 printf("Mode: NotifyGrab\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 if (xevent.xcrossing.mode == NotifyUngrab)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 printf("Mode: NotifyUngrab\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 #endif
4558
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
145 if (xevent.xcrossing.mode != NotifyGrab &&
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
146 xevent.xcrossing.mode != NotifyUngrab &&
4d95152d9e39 Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents: 4556
diff changeset
147 xevent.xcrossing.detail != NotifyInferior) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
148 SDL_SetMouseFocus(NULL);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 /* Gaining input focus? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 case FocusIn:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 printf("FocusIn!\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 #endif
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
158 SDL_SetKeyboardFocus(data->window);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 #ifdef X_HAVE_UTF8_STRING
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 if (data->ic) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 XSetICFocus(data->ic);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 /* Losing input focus? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 case FocusOut:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 printf("FocusOut!\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 #endif
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
172 SDL_SetKeyboardFocus(NULL);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 #ifdef X_HAVE_UTF8_STRING
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 if (data->ic) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 XUnsetICFocus(data->ic);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 /* Generated upon EnterWindow and FocusIn */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 case KeymapNotify:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 printf("KeymapNotify!\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 /* FIXME:
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
192 /* Has the keyboard layout changed? */
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
193 case MappingNotify:{
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
194 #ifdef DEBUG_XEVENTS
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
195 printf("MappingNotify!\n");
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
196 #endif
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2305
diff changeset
197 X11_UpdateKeymap(_this);
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
198 }
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
199 break;
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
200
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 /* Key press? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 case KeyPress:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 KeyCode keycode = xevent.xkey.keycode;
2300
c97ad1abe05b Minimal implementation of textinput events for x11. It only works for latin-1.
Bob Pendleton <bob@pendleton.com>
parents: 2299
diff changeset
204 KeySym keysym = NoSymbol;
5223
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5083
diff changeset
205 SDL_Scancode scancode;
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2305
diff changeset
206 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
207 Status status = 0;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 #endif
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
212 SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
4535
ce811c9247da Added back in a little more debugging for the X11 keyboard code
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
213 #if 1
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
214 if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
215 int min_keycode, max_keycode;
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
216 XDisplayKeycodes(display, &min_keycode, &max_keycode);
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
217 keysym = XKeycodeToKeysym(display, keycode, 0);
2299
a7cbc25071b6 Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
Bob Pendleton <bob@pendleton.com>
parents: 2295
diff changeset
218 fprintf(stderr,
4556
cc06f306c053 Fixed X error when showing debug info about a deleted property
Sam Lantinga <slouken@libsdl.org>
parents: 4535
diff changeset
219 "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%lX (%s).\n",
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
220 keycode, keycode - min_keycode, keysym,
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
221 XKeysymToString(keysym));
2299
a7cbc25071b6 Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
Bob Pendleton <bob@pendleton.com>
parents: 2295
diff changeset
222 }
2295
dbc6d1893869 Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents: 2046
diff changeset
223 #endif
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
224 /* */
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
225 SDL_zero(text);
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
226 #ifdef X_HAVE_UTF8_STRING
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
227 if (data->ic) {
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
228 Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
2738
79c1bd651f04 Fixed a bunch of compile warnings on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
229 &keysym, &status);
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
230 }
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
231 #else
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2305
diff changeset
232 XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL);
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2324
diff changeset
233 #endif
2305
fbe8ff44c519 First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2300
diff changeset
234 if (*text) {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
235 SDL_SendKeyboardText(text);
2300
c97ad1abe05b Minimal implementation of textinput events for x11. It only works for latin-1.
Bob Pendleton <bob@pendleton.com>
parents: 2299
diff changeset
236 }
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 /* Key release? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 case KeyRelease:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 KeyCode keycode = xevent.xkey.keycode;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 #endif
4565
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
247 if (X11_KeyRepeat(display, &xevent)) {
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
248 /* We're about to get a repeated key down, ignore the key up */
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
249 break;
e2d46c5c7483 Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents: 4560
diff changeset
250 }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
251 SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 /* Have we been iconified? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 case UnmapNotify:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 printf("UnmapNotify!\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 #endif
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
260 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
261 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 /* Have we been restored? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 case MapNotify:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 printf("MapNotify!\n");
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 #endif
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
270 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
271 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 /* Have we been resized or moved? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 case ConfigureNotify:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 printf("ConfigureNotify! (resize: %dx%d)\n",
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 xevent.xconfigure.width, xevent.xconfigure.height);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 #endif
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
281 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED,
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 xevent.xconfigure.x, xevent.xconfigure.y);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
283 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED,
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 xevent.xconfigure.width,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 xevent.xconfigure.height);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 /* Have we been requested to quit (or another client message?) */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 case ClientMessage:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 if ((xevent.xclient.format == 32) &&
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
294 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 /* Do we need to refresh ourselves? */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 case Expose:{
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 #ifdef DEBUG_XEVENTS
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 printf("Expose (count = %d)\n", xevent.xexpose.count);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 #endif
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3322
diff changeset
304 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
308 case MotionNotify:{
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
309 #ifdef DEBUG_MOTION
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
310 printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
311 #endif
4484
9322f7db8603 Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event.
Sam Lantinga <slouken@libsdl.org>
parents: 4472
diff changeset
312 SDL_SendMouseMotion(data->window, 0, xevent.xmotion.x, xevent.xmotion.y);
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
313 }
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
314 break;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
315
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
316 case ButtonPress:{
4484
9322f7db8603 Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event.
Sam Lantinga <slouken@libsdl.org>
parents: 4472
diff changeset
317 SDL_SendMouseButton(data->window, SDL_PRESSED, xevent.xbutton.button);
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
318 }
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
319 break;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
320
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
321 case ButtonRelease:{
4484
9322f7db8603 Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event.
Sam Lantinga <slouken@libsdl.org>
parents: 4472
diff changeset
322 SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button);
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
323 }
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
324 break;
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
325
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
326 case PropertyNotify:{
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
327 #ifdef DEBUG_XEVENTS
4520
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
328 unsigned char *propdata;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
329 int status, real_format;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
330 Atom real_type;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
331 unsigned long items_read, items_left, i;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
332
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
333 char *name = XGetAtomName(display, xevent.xproperty.atom);
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
334 if (name) {
4556
cc06f306c053 Fixed X error when showing debug info about a deleted property
Sam Lantinga <slouken@libsdl.org>
parents: 4535
diff changeset
335 printf("PropertyNotify: %s %s\n", name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
336 XFree(name);
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
337 }
4520
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
338
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
339 status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
4556
cc06f306c053 Fixed X error when showing debug info about a deleted property
Sam Lantinga <slouken@libsdl.org>
parents: 4535
diff changeset
340 if (status == Success && items_read > 0) {
4520
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
341 if (real_type == XA_INTEGER) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
342 int *values = (int *)propdata;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
343
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
344 printf("{");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
345 for (i = 0; i < items_read; i++) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
346 printf(" %d", values[i]);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
347 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
348 printf(" }\n");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
349 } else if (real_type == XA_CARDINAL) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
350 if (real_format == 32) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
351 Uint32 *values = (Uint32 *)propdata;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
352
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
353 printf("{");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
354 for (i = 0; i < items_read; i++) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
355 printf(" %d", values[i]);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
356 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
357 printf(" }\n");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
358 } else if (real_format == 16) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
359 Uint16 *values = (Uint16 *)propdata;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
360
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
361 printf("{");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
362 for (i = 0; i < items_read; i++) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
363 printf(" %d", values[i]);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
364 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
365 printf(" }\n");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
366 } else if (real_format == 8) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
367 Uint8 *values = (Uint8 *)propdata;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
368
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
369 printf("{");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
370 for (i = 0; i < items_read; i++) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
371 printf(" %d", values[i]);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
372 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
373 printf(" }\n");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
374 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
375 } else if (real_type == XA_STRING ||
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
376 real_type == videodata->UTF8_STRING) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
377 printf("{ \"%s\" }\n", propdata);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
378 } else if (real_type == XA_ATOM) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
379 Atom *atoms = (Atom *)propdata;
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
380
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
381 printf("{");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
382 for (i = 0; i < items_read; i++) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
383 char *name = XGetAtomName(display, atoms[i]);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
384 if (name) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
385 printf(" %s", name);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
386 XFree(name);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
387 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
388 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
389 printf(" }\n");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
390 } else {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
391 char *name = XGetAtomName(display, real_type);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
392 printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
393 if (name) {
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
394 XFree(name);
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
395 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
396 }
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
397 }
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
398 #endif
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
399 }
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
400 break;
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4508
diff changeset
401
4508
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
402 /* Copy the selection from XA_CUT_BUFFER0 to the requested property */
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
403 case SelectionRequest: {
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
404 XSelectionRequestEvent *req;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
405 XEvent sevent;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
406 int seln_format;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
407 unsigned long nbytes;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
408 unsigned long overflow;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
409 unsigned char *seln_data;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
410
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
411 req = &xevent.xselectionrequest;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
412 #ifdef DEBUG_XEVENTS
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
413 printf("SelectionRequest (requestor = %ld, target = %ld)\n",
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
414 req->requestor, req->target);
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
415 #endif
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
416
4524
a256e1dadf3f Zero any fields not explicitly filled in.
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
417 SDL_zero(sevent);
4520
0c67c4328678 Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents: 4519
diff changeset
418 sevent.xany.type = SelectionNotify;
4508
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
419 sevent.xselection.selection = req->selection;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
420 sevent.xselection.target = None;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
421 sevent.xselection.property = None;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
422 sevent.xselection.requestor = req->requestor;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
423 sevent.xselection.time = req->time;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
424 if (XGetWindowProperty(display, DefaultRootWindow(display),
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
425 XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
426 &sevent.xselection.target, &seln_format, &nbytes,
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
427 &overflow, &seln_data) == Success) {
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
428 if (sevent.xselection.target == req->target) {
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
429 XChangeProperty(display, req->requestor, req->property,
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
430 sevent.xselection.target, seln_format, PropModeReplace,
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
431 seln_data, nbytes);
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
432 sevent.xselection.property = req->property;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
433 }
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
434 XFree(seln_data);
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
435 }
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
436 XSendEvent(display, req->requestor, False, 0, &sevent);
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
437 XSync(display, False);
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
438 }
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
439 break;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
440
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
441 case SelectionNotify: {
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
442 #ifdef DEBUG_XEVENTS
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
443 printf("SelectionNotify (requestor = %ld, target = %ld)\n",
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
444 xevent.xselection.requestor, xevent.xselection.target);
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
445 #endif
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
446 videodata->selection_waiting = SDL_FALSE;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
447 }
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
448 break;
15d2c6f40c48 Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents: 4484
diff changeset
449
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
450 default:{
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 #ifdef DEBUG_XEVENTS
2940
b93965a16fe0 Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
452 printf("Unhandled event %d\n", xevent.type);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 break;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 /* Ack! XPending() actually performs a blocking read if no events available */
4472
791b3256fb22 Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
460 static int
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 X11_Pending(Display * display)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 /* Flush the display connection and look to see if events are queued */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 XFlush(display);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 if (XEventsQueued(display, QueuedAlready)) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 return (1);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 /* More drastic measures are required -- see if X is ready to talk */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 static struct timeval zero_time; /* static == 0 */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 int x11_fd;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 fd_set fdset;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 x11_fd = ConnectionNumber(display);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 FD_ZERO(&fdset);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 FD_SET(x11_fd, &fdset);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 return (XPending(display));
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 /* Oh well, nothing is ready .. */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 return (0);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 X11_PumpEvents(_THIS)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491
3025
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
492 /* Update activity every 30 seconds to prevent screensaver */
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
493 if (_this->suspend_screensaver) {
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
494 Uint32 now = SDL_GetTicks();
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
495 if (!data->screensaver_activity ||
3040
Sam Lantinga <slouken@libsdl.org>
parents: 3031
diff changeset
496 (int) (now - data->screensaver_activity) >= 30000) {
3025
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
497 XResetScreenSaver(data->display);
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
498 data->screensaver_activity = now;
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
499 }
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
500 }
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
501
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 /* Keep processing pending events */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 while (X11_Pending(data->display)) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 X11_DispatchEvent(_this);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 }
4640
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4429
diff changeset
506
4681
5378f2d0754f Fixed some Gesture bugs
Jim Grandpre <jim.tla@gmail.com>
parents: 4669
diff changeset
507 #ifdef SDL_INPUT_LINUXEV
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
508 /* Process Touch events - TODO When X gets touch support, use that instead*/
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
509 int i = 0,rd;
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
510 char name[256];
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
511 struct input_event ev[64];
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
512 int size = sizeof (struct input_event);
4645
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents: 4644
diff changeset
513
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
514 for(i = 0;i < SDL_GetNumTouch();++i) {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
515 SDL_Touch* touch = SDL_GetTouchIndex(i);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
516 if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
517 EventTouchData* data;
4645
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents: 4644
diff changeset
518 data = (EventTouchData*)(touch->driverdata);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents: 4644
diff changeset
519 if(data == NULL) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents: 4644
diff changeset
520 printf("No driver data\n");
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents: 4644
diff changeset
521 continue;
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
522 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
523 if(data->eventStream <= 0)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
524 printf("Error: Couldn't open stream\n");
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
525 rd = read(data->eventStream, ev, size * 64);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
526 //printf("Got %i/%i bytes\n",rd,size);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
527 if(rd >= size) {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
528 for (i = 0; i < rd / sizeof(struct input_event); i++) {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
529 switch (ev[i].type) {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
530 case EV_ABS:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
531 //printf("Got position x: %i!\n",data->x);
4644
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
532 switch (ev[i].code) {
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
533 case ABS_X:
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
534 data->x = ev[i].value;
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
535 break;
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
536 case ABS_Y:
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
537 data->y = ev[i].value;
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
538 break;
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
539 case ABS_PRESSURE:
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
540 data->pressure = ev[i].value;
4646
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
541 if(data->pressure < 0) data->pressure = 0;
4644
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
542 break;
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
543 case ABS_MISC:
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
544 if(ev[i].value == 0)
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
545 data->up = SDL_TRUE;
4644
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
546 break;
fb500b3e1717 Added pressure support for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4643
diff changeset
547 }
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
548 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
549 case EV_MSC:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
550 if(ev[i].code == MSC_SERIAL)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
551 data->finger = ev[i].value;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
552 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
553 case EV_SYN:
4646
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
554 //printf("Id: %i\n",touch->id);
4655
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
555 if(data->up) {
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
556 SDL_SendFingerDown(touch->id,data->finger,
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
557 SDL_FALSE,data->x,data->y,
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
558 data->pressure);
4655
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
559 }
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
560 else if(data->x >= 0 || data->y >= 0)
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
561 SDL_SendTouchMotion(touch->id,data->finger,
4655
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
562 SDL_FALSE,data->x,data->y,
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
563 data->pressure);
4655
4c94f2023d62 Fixed bugs in input, cleaned up $1
Jim Grandpre <jim.tla@gmail.com>
parents: 4646
diff changeset
564
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
565 //printf("Synched: %i tx: %i, ty: %i\n",
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
566 // data->finger,data->x,data->y);
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
567 data->x = -1;
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
568 data->y = -1;
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
569 data->pressure = -1;
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
570 data->finger = 0;
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
571 data->up = SDL_FALSE;
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
572
4683
15dfe42edbfd Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents: 4681
diff changeset
573 break;
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
574 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
575 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
576 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
577 }
4669
62e6a6e9720b Fixed x11 compile bugs.
jimtla
parents: 4661
diff changeset
578 #endif
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
581 /* This is so wrong it hurts */
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
582 #define GNOME_SCREENSAVER_HACK
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
583 #ifdef GNOME_SCREENSAVER_HACK
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
584 #include <unistd.h>
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
585 static pid_t screensaver_inhibit_pid;
3040
Sam Lantinga <slouken@libsdl.org>
parents: 3031
diff changeset
586 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3031
diff changeset
587 gnome_screensaver_disable()
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
588 {
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
589 screensaver_inhibit_pid = fork();
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
590 if (screensaver_inhibit_pid == 0) {
3031
86918831452f Don't complain when the GNOME screensaver isn't running (or available)
Sam Lantinga <slouken@libsdl.org>
parents: 3030
diff changeset
591 close(0);
86918831452f Don't complain when the GNOME screensaver isn't running (or available)
Sam Lantinga <slouken@libsdl.org>
parents: 3030
diff changeset
592 close(1);
86918831452f Don't complain when the GNOME screensaver isn't running (or available)
Sam Lantinga <slouken@libsdl.org>
parents: 3030
diff changeset
593 close(2);
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
594 execl("/usr/bin/gnome-screensaver-command",
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
595 "gnome-screensaver-command",
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
596 "--inhibit",
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
597 "--reason",
3040
Sam Lantinga <slouken@libsdl.org>
parents: 3031
diff changeset
598 "GNOME screensaver doesn't respect MIT-SCREEN-SAVER", NULL);
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
599 exit(2);
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
600 }
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
601 }
3040
Sam Lantinga <slouken@libsdl.org>
parents: 3031
diff changeset
602 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3031
diff changeset
603 gnome_screensaver_enable()
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
604 {
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
605 kill(screensaver_inhibit_pid, 15);
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
606 }
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
607 #endif
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
608
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 void
3025
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
610 X11_SuspendScreenSaver(_THIS)
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 {
3025
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
612 #if SDL_VIDEO_DRIVER_X11_SCRNSAVER
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
613 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
614 int dummy;
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
615 int major_version, minor_version;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
617 if (SDL_X11_HAVE_XSS) {
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
618 /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
619 if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
620 !XScreenSaverQueryVersion(data->display,
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
621 &major_version, &minor_version) ||
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
622 major_version < 1 || (major_version == 1 && minor_version < 1)) {
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
623 return;
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
624 }
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
626 XScreenSaverSuspend(data->display, _this->suspend_screensaver);
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
627 XResetScreenSaver(data->display);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 }
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
629 #endif
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630
3030
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
631 #ifdef GNOME_SCREENSAVER_HACK
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
632 if (_this->suspend_screensaver) {
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
633 gnome_screensaver_disable();
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
634 } else {
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
635 gnome_screensaver_enable();
f13ad181f5b2 This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
636 }
3025
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 3015
diff changeset
637 #endif
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 /* vi: set ts=4 sw=4 expandtab: */