Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11events.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 409974dedf2e |
children |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
53 /*#define DEBUG_XEVENTS*/ | 53 /*#define DEBUG_XEVENTS*/ |
54 | 54 |
55 /* The translation tables from an X11 keysym to a SDL keysym */ | 55 /* The translation tables from an X11 keysym to a SDL keysym */ |
56 static SDLKey ODD_keymap[256]; | 56 static SDLKey ODD_keymap[256]; |
57 static SDLKey MISC_keymap[256]; | 57 static SDLKey MISC_keymap[256]; |
58 SDLKey X11_TranslateKeycode(Display *display, KeyCode kc); | 58 SDLKey X11_TranslateKeycode(Display * display, KeyCode kc); |
59 | 59 |
60 | 60 |
61 #ifdef X_HAVE_UTF8_STRING | 61 #ifdef X_HAVE_UTF8_STRING |
62 Uint32 Utf8ToUcs4(const Uint8 *utf8) | 62 Uint32 |
63 { | 63 Utf8ToUcs4(const Uint8 * utf8) |
64 Uint32 c; | 64 { |
65 int i = 1; | 65 Uint32 c; |
66 int noOctets = 0; | 66 int i = 1; |
67 int firstOctetMask = 0; | 67 int noOctets = 0; |
68 unsigned char firstOctet = utf8[0]; | 68 int firstOctetMask = 0; |
69 if (firstOctet < 0x80) { | 69 unsigned char firstOctet = utf8[0]; |
70 /* | 70 if (firstOctet < 0x80) { |
71 Characters in the range: | 71 /* |
72 00000000 to 01111111 (ASCII Range) | 72 Characters in the range: |
73 are stored in one octet: | 73 00000000 to 01111111 (ASCII Range) |
74 0xxxxxxx (The same as its ASCII representation) | 74 are stored in one octet: |
75 The least 6 significant bits of the first octet is the most 6 significant nonzero bits | 75 0xxxxxxx (The same as its ASCII representation) |
76 of the UCS4 representation. | 76 The least 6 significant bits of the first octet is the most 6 significant nonzero bits |
77 */ | 77 of the UCS4 representation. |
78 noOctets = 1; | 78 */ |
79 firstOctetMask = 0x7F; /* 0(1111111) - The most significant bit is ignored */ | 79 noOctets = 1; |
80 } else if ((firstOctet & 0xE0) /* get the most 3 significant bits by AND'ing with 11100000 */ | 80 firstOctetMask = 0x7F; /* 0(1111111) - The most significant bit is ignored */ |
81 == 0xC0 ) { /* see if those 3 bits are 110. If so, the char is in this range */ | 81 } else if ((firstOctet & 0xE0) /* get the most 3 significant bits by AND'ing with 11100000 */ |
82 /* | 82 == 0xC0) { /* see if those 3 bits are 110. If so, the char is in this range */ |
83 Characters in the range: | 83 /* |
84 00000000 10000000 to 00000111 11111111 | 84 Characters in the range: |
85 are stored in two octets: | 85 00000000 10000000 to 00000111 11111111 |
86 110xxxxx 10xxxxxx | 86 are stored in two octets: |
87 The least 5 significant bits of the first octet is the most 5 significant nonzero bits | 87 110xxxxx 10xxxxxx |
88 of the UCS4 representation. | 88 The least 5 significant bits of the first octet is the most 5 significant nonzero bits |
89 */ | 89 of the UCS4 representation. |
90 noOctets = 2; | 90 */ |
91 firstOctetMask = 0x1F; /* 000(11111) - The most 3 significant bits are ignored */ | 91 noOctets = 2; |
92 } else if ((firstOctet & 0xF0) /* get the most 4 significant bits by AND'ing with 11110000 */ | 92 firstOctetMask = 0x1F; /* 000(11111) - The most 3 significant bits are ignored */ |
93 == 0xE0) { /* see if those 4 bits are 1110. If so, the char is in this range */ | 93 } else if ((firstOctet & 0xF0) /* get the most 4 significant bits by AND'ing with 11110000 */ |
94 /* | 94 == 0xE0) { /* see if those 4 bits are 1110. If so, the char is in this range */ |
95 Characters in the range: | 95 /* |
96 00001000 00000000 to 11111111 11111111 | 96 Characters in the range: |
97 are stored in three octets: | 97 00001000 00000000 to 11111111 11111111 |
98 1110xxxx 10xxxxxx 10xxxxxx | 98 are stored in three octets: |
99 The least 4 significant bits of the first octet is the most 4 significant nonzero bits | 99 1110xxxx 10xxxxxx 10xxxxxx |
100 of the UCS4 representation. | 100 The least 4 significant bits of the first octet is the most 4 significant nonzero bits |
101 */ | 101 of the UCS4 representation. |
102 noOctets = 3; | 102 */ |
103 firstOctetMask = 0x0F; /* 0000(1111) - The most 4 significant bits are ignored */ | 103 noOctets = 3; |
104 } else if ((firstOctet & 0xF8) /* get the most 5 significant bits by AND'ing with 11111000 */ | 104 firstOctetMask = 0x0F; /* 0000(1111) - The most 4 significant bits are ignored */ |
105 == 0xF0) { /* see if those 5 bits are 11110. If so, the char is in this range */ | 105 } else if ((firstOctet & 0xF8) /* get the most 5 significant bits by AND'ing with 11111000 */ |
106 /* | 106 == 0xF0) { /* see if those 5 bits are 11110. If so, the char is in this range */ |
107 Characters in the range: | 107 /* |
108 00000001 00000000 00000000 to 00011111 11111111 11111111 | 108 Characters in the range: |
109 are stored in four octets: | 109 00000001 00000000 00000000 to 00011111 11111111 11111111 |
110 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx | 110 are stored in four octets: |
111 The least 3 significant bits of the first octet is the most 3 significant nonzero bits | 111 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx |
112 of the UCS4 representation. | 112 The least 3 significant bits of the first octet is the most 3 significant nonzero bits |
113 */ | 113 of the UCS4 representation. |
114 noOctets = 4; | 114 */ |
115 firstOctetMask = 0x07; /* 11110(111) - The most 5 significant bits are ignored */ | 115 noOctets = 4; |
116 } else if ((firstOctet & 0xFC) /* get the most 6 significant bits by AND'ing with 11111100 */ | 116 firstOctetMask = 0x07; /* 11110(111) - The most 5 significant bits are ignored */ |
117 == 0xF8) { /* see if those 6 bits are 111110. If so, the char is in this range */ | 117 } else if ((firstOctet & 0xFC) /* get the most 6 significant bits by AND'ing with 11111100 */ |
118 /* | 118 == 0xF8) { /* see if those 6 bits are 111110. If so, the char is in this range */ |
119 Characters in the range: | 119 /* |
120 00000000 00100000 00000000 00000000 to | 120 Characters in the range: |
121 00000011 11111111 11111111 11111111 | 121 00000000 00100000 00000000 00000000 to |
122 are stored in five octets: | 122 00000011 11111111 11111111 11111111 |
123 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx | 123 are stored in five octets: |
124 The least 2 significant bits of the first octet is the most 2 significant nonzero bits | 124 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
125 of the UCS4 representation. | 125 The least 2 significant bits of the first octet is the most 2 significant nonzero bits |
126 */ | 126 of the UCS4 representation. |
127 noOctets = 5; | 127 */ |
128 firstOctetMask = 0x03; /* 111110(11) - The most 6 significant bits are ignored */ | 128 noOctets = 5; |
129 } else if ((firstOctet & 0xFE) /* get the most 7 significant bits by AND'ing with 11111110 */ | 129 firstOctetMask = 0x03; /* 111110(11) - The most 6 significant bits are ignored */ |
130 == 0xFC) { /* see if those 7 bits are 1111110. If so, the char is in this range */ | 130 } else if ((firstOctet & 0xFE) /* get the most 7 significant bits by AND'ing with 11111110 */ |
131 /* | 131 == 0xFC) { /* see if those 7 bits are 1111110. If so, the char is in this range */ |
132 Characters in the range: | 132 /* |
133 00000100 00000000 00000000 00000000 to | 133 Characters in the range: |
134 01111111 11111111 11111111 11111111 | 134 00000100 00000000 00000000 00000000 to |
135 are stored in six octets: | 135 01111111 11111111 11111111 11111111 |
136 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx | 136 are stored in six octets: |
137 The least significant bit of the first octet is the most significant nonzero bit | 137 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
138 of the UCS4 representation. | 138 The least significant bit of the first octet is the most significant nonzero bit |
139 */ | 139 of the UCS4 representation. |
140 noOctets = 6; | 140 */ |
141 firstOctetMask = 0x01; /* 1111110(1) - The most 7 significant bits are ignored */ | 141 noOctets = 6; |
142 } else | 142 firstOctetMask = 0x01; /* 1111110(1) - The most 7 significant bits are ignored */ |
143 return 0; /* The given chunk is not a valid UTF-8 encoded Unicode character */ | 143 } else |
144 | 144 return 0; /* The given chunk is not a valid UTF-8 encoded Unicode character */ |
145 /* | 145 |
146 The least noOctets significant bits of the first octet is the most 2 significant nonzero bits | 146 /* |
147 of the UCS4 representation. | 147 The least noOctets significant bits of the first octet is the most 2 significant nonzero bits |
148 The first 6 bits of the UCS4 representation is the least 8-noOctets-1 significant bits of | 148 of the UCS4 representation. |
149 firstOctet if the character is not ASCII. If so, it's the least 7 significant bits of firstOctet. | 149 The first 6 bits of the UCS4 representation is the least 8-noOctets-1 significant bits of |
150 This done by AND'ing firstOctet with its mask to trim the bits used for identifying the | 150 firstOctet if the character is not ASCII. If so, it's the least 7 significant bits of firstOctet. |
151 number of continuing octets (if any) and leave only the free bits (the x's) | 151 This done by AND'ing firstOctet with its mask to trim the bits used for identifying the |
152 Sample: | 152 number of continuing octets (if any) and leave only the free bits (the x's) |
153 1-octet: 0xxxxxxx & 01111111 = 0xxxxxxx | 153 Sample: |
154 2-octets: 110xxxxx & 00011111 = 000xxxxx | 154 1-octet: 0xxxxxxx & 01111111 = 0xxxxxxx |
155 */ | 155 2-octets: 110xxxxx & 00011111 = 000xxxxx |
156 c = firstOctet & firstOctetMask; | 156 */ |
157 | 157 c = firstOctet & firstOctetMask; |
158 /* Now, start filling c.ucs4 with the bits from the continuing octets from utf8. */ | 158 |
159 for (i = 1; i < noOctets; i++) { | 159 /* Now, start filling c.ucs4 with the bits from the continuing octets from utf8. */ |
160 /* A valid continuing octet is of the form 10xxxxxx */ | 160 for (i = 1; i < noOctets; i++) { |
161 if ((utf8[i] & 0xC0) /* get the most 2 significant bits by AND'ing with 11000000 */ | 161 /* A valid continuing octet is of the form 10xxxxxx */ |
162 != 0x80) /* see if those 2 bits are 10. If not, the is a malformed sequence. */ | 162 if ((utf8[i] & 0xC0) /* get the most 2 significant bits by AND'ing with 11000000 */ |
163 /*The given chunk is a partial sequence at the end of a string that could | 163 !=0x80) |
164 begin a valid character */ | 164 /* see if those 2 bits are 10. If not, the is a malformed sequence. */ |
165 return 0; | 165 /*The given chunk is a partial sequence at the end of a string that could |
166 | 166 begin a valid character */ |
167 /* Make room for the next 6-bits */ | 167 return 0; |
168 c <<= 6; | 168 |
169 | 169 /* Make room for the next 6-bits */ |
170 /* | 170 c <<= 6; |
171 Take only the least 6 significance bits of the current octet (utf8[i]) and fill the created room | 171 |
172 of c.ucs4 with them. | 172 /* |
173 This done by AND'ing utf8[i] with 00111111 and the OR'ing the result with c.ucs4. | 173 Take only the least 6 significance bits of the current octet (utf8[i]) and fill the created room |
174 */ | 174 of c.ucs4 with them. |
175 c |= utf8[i] & 0x3F; | 175 This done by AND'ing utf8[i] with 00111111 and the OR'ing the result with c.ucs4. |
176 } | 176 */ |
177 return c; | 177 c |= utf8[i] & 0x3F; |
178 } | |
179 return c; | |
178 } | 180 } |
179 #endif | 181 #endif |
180 | 182 |
181 /* Check to see if this is a repeated key. | 183 /* Check to see if this is a repeated key. |
182 (idea shamelessly lifted from GII -- thanks guys! :) | 184 (idea shamelessly lifted from GII -- thanks guys! :) |
183 */ | 185 */ |
184 static int X11_KeyRepeat(Display *display, XEvent *event) | 186 static int |
185 { | 187 X11_KeyRepeat(Display * display, XEvent * event) |
186 XEvent peekevent; | 188 { |
187 int repeated; | 189 XEvent peekevent; |
188 | 190 int repeated; |
189 repeated = 0; | 191 |
190 if ( XPending(display) ) { | 192 repeated = 0; |
191 XPeekEvent(display, &peekevent); | 193 if (XPending(display)) { |
192 if ( (peekevent.type == KeyPress) && | 194 XPeekEvent(display, &peekevent); |
193 (peekevent.xkey.keycode == event->xkey.keycode) && | 195 if ((peekevent.type == KeyPress) && |
194 ((peekevent.xkey.time-event->xkey.time) < 2) ) { | 196 (peekevent.xkey.keycode == event->xkey.keycode) && |
195 repeated = 1; | 197 ((peekevent.xkey.time - event->xkey.time) < 2)) { |
196 XNextEvent(display, &peekevent); | 198 repeated = 1; |
197 } | 199 XNextEvent(display, &peekevent); |
198 } | 200 } |
199 return(repeated); | 201 } |
202 return (repeated); | |
200 } | 203 } |
201 | 204 |
202 /* Note: The X server buffers and accumulates mouse motion events, so | 205 /* Note: The X server buffers and accumulates mouse motion events, so |
203 the motion event generated by the warp may not appear exactly as we | 206 the motion event generated by the warp may not appear exactly as we |
204 expect it to. We work around this (and improve performance) by only | 207 expect it to. We work around this (and improve performance) by only |
205 warping the pointer when it reaches the edge, and then wait for it. | 208 warping the pointer when it reaches the edge, and then wait for it. |
206 */ | 209 */ |
207 #define MOUSE_FUDGE_FACTOR 8 | 210 #define MOUSE_FUDGE_FACTOR 8 |
208 | 211 |
209 static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent) | 212 static __inline__ int |
210 { | 213 X11_WarpedMotion(_THIS, XEvent * xevent) |
211 int w, h, i; | 214 { |
212 int deltax, deltay; | 215 int w, h, i; |
213 int posted; | 216 int deltax, deltay; |
214 | 217 int posted; |
215 w = SDL_VideoSurface->w; | 218 |
216 h = SDL_VideoSurface->h; | 219 w = SDL_VideoSurface->w; |
217 deltax = xevent->xmotion.x - mouse_last.x; | 220 h = SDL_VideoSurface->h; |
218 deltay = xevent->xmotion.y - mouse_last.y; | 221 deltax = xevent->xmotion.x - mouse_last.x; |
222 deltay = xevent->xmotion.y - mouse_last.y; | |
219 #ifdef DEBUG_MOTION | 223 #ifdef DEBUG_MOTION |
220 printf("Warped mouse motion: %d,%d\n", deltax, deltay); | 224 printf("Warped mouse motion: %d,%d\n", deltax, deltay); |
221 #endif | 225 #endif |
222 mouse_last.x = xevent->xmotion.x; | 226 mouse_last.x = xevent->xmotion.x; |
223 mouse_last.y = xevent->xmotion.y; | 227 mouse_last.y = xevent->xmotion.y; |
224 posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); | 228 posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); |
225 | 229 |
226 if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || | 230 if ((xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || |
227 (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) || | 231 (xevent->xmotion.x > (w - MOUSE_FUDGE_FACTOR)) || |
228 (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || | 232 (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || |
229 (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) { | 233 (xevent->xmotion.y > (h - MOUSE_FUDGE_FACTOR))) { |
230 /* Get the events that have accumulated */ | 234 /* Get the events that have accumulated */ |
231 while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) { | 235 while (XCheckTypedEvent(SDL_Display, MotionNotify, xevent)) { |
232 deltax = xevent->xmotion.x - mouse_last.x; | 236 deltax = xevent->xmotion.x - mouse_last.x; |
233 deltay = xevent->xmotion.y - mouse_last.y; | 237 deltay = xevent->xmotion.y - mouse_last.y; |
234 #ifdef DEBUG_MOTION | 238 #ifdef DEBUG_MOTION |
235 printf("Extra mouse motion: %d,%d\n", deltax, deltay); | 239 printf("Extra mouse motion: %d,%d\n", deltax, deltay); |
236 #endif | 240 #endif |
237 mouse_last.x = xevent->xmotion.x; | 241 mouse_last.x = xevent->xmotion.x; |
238 mouse_last.y = xevent->xmotion.y; | 242 mouse_last.y = xevent->xmotion.y; |
239 posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); | 243 posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); |
240 } | 244 } |
241 mouse_last.x = w/2; | 245 mouse_last.x = w / 2; |
242 mouse_last.y = h/2; | 246 mouse_last.y = h / 2; |
243 XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, | 247 XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, |
244 mouse_last.x, mouse_last.y); | 248 mouse_last.x, mouse_last.y); |
245 for ( i=0; i<10; ++i ) { | 249 for (i = 0; i < 10; ++i) { |
246 XMaskEvent(SDL_Display, PointerMotionMask, xevent); | 250 XMaskEvent(SDL_Display, PointerMotionMask, xevent); |
247 if ( (xevent->xmotion.x > | 251 if ((xevent->xmotion.x > |
248 (mouse_last.x-MOUSE_FUDGE_FACTOR)) && | 252 (mouse_last.x - MOUSE_FUDGE_FACTOR)) && |
249 (xevent->xmotion.x < | 253 (xevent->xmotion.x < |
250 (mouse_last.x+MOUSE_FUDGE_FACTOR)) && | 254 (mouse_last.x + MOUSE_FUDGE_FACTOR)) && |
251 (xevent->xmotion.y > | 255 (xevent->xmotion.y > |
252 (mouse_last.y-MOUSE_FUDGE_FACTOR)) && | 256 (mouse_last.y - MOUSE_FUDGE_FACTOR)) && |
253 (xevent->xmotion.y < | 257 (xevent->xmotion.y < (mouse_last.y + MOUSE_FUDGE_FACTOR))) { |
254 (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) { | 258 break; |
255 break; | 259 } |
256 } | 260 #ifdef DEBUG_XEVENTS |
257 #ifdef DEBUG_XEVENTS | 261 printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, |
258 printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y); | 262 xevent->xmotion.y); |
259 #endif | 263 #endif |
260 } | 264 } |
261 #ifdef DEBUG_XEVENTS | 265 #ifdef DEBUG_XEVENTS |
262 if ( i == 10 ) { | 266 if (i == 10) { |
263 printf("Warning: didn't detect mouse warp motion\n"); | 267 printf("Warning: didn't detect mouse warp motion\n"); |
264 } | 268 } |
265 #endif | 269 #endif |
266 } | 270 } |
267 return(posted); | 271 return (posted); |
268 } | 272 } |
269 | 273 |
270 static int X11_DispatchEvent(_THIS) | 274 static int |
271 { | 275 X11_DispatchEvent(_THIS) |
272 int posted; | 276 { |
273 XEvent xevent; | 277 int posted; |
274 | 278 XEvent xevent; |
275 SDL_memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */ | 279 |
276 XNextEvent(SDL_Display, &xevent); | 280 SDL_memset(&xevent, '\0', sizeof(XEvent)); /* valgrind fix. --ryan. */ |
277 | 281 XNextEvent(SDL_Display, &xevent); |
278 posted = 0; | 282 |
279 switch (xevent.type) { | 283 posted = 0; |
280 | 284 switch (xevent.type) { |
281 /* Gaining mouse coverage? */ | 285 |
282 case EnterNotify: { | 286 /* Gaining mouse coverage? */ |
283 #ifdef DEBUG_XEVENTS | 287 case EnterNotify: |
284 printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y); | 288 { |
285 if ( xevent.xcrossing.mode == NotifyGrab ) | 289 #ifdef DEBUG_XEVENTS |
286 printf("Mode: NotifyGrab\n"); | 290 printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, |
287 if ( xevent.xcrossing.mode == NotifyUngrab ) | 291 xevent.xcrossing.y); |
288 printf("Mode: NotifyUngrab\n"); | 292 if (xevent.xcrossing.mode == NotifyGrab) |
289 #endif | 293 printf("Mode: NotifyGrab\n"); |
290 if ( (xevent.xcrossing.mode != NotifyGrab) && | 294 if (xevent.xcrossing.mode == NotifyUngrab) |
291 (xevent.xcrossing.mode != NotifyUngrab) ) { | 295 printf("Mode: NotifyUngrab\n"); |
292 if ( this->input_grab == SDL_GRAB_OFF ) { | 296 #endif |
293 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 297 if ((xevent.xcrossing.mode != NotifyGrab) && |
294 } | 298 (xevent.xcrossing.mode != NotifyUngrab)) { |
295 posted = SDL_PrivateMouseMotion(0, 0, | 299 if (SDL_CurrentWindow.input_grab == SDL_GRAB_OFF) { |
296 xevent.xcrossing.x, | 300 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
297 xevent.xcrossing.y); | 301 } |
298 } | 302 posted = SDL_PrivateMouseMotion(0, 0, |
299 } | 303 xevent.xcrossing.x, |
300 break; | 304 xevent.xcrossing.y); |
301 | 305 } |
302 /* Losing mouse coverage? */ | 306 } |
303 case LeaveNotify: { | 307 break; |
304 #ifdef DEBUG_XEVENTS | 308 |
305 printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, xevent.xcrossing.y); | 309 /* Losing mouse coverage? */ |
306 if ( xevent.xcrossing.mode == NotifyGrab ) | 310 case LeaveNotify: |
307 printf("Mode: NotifyGrab\n"); | 311 { |
308 if ( xevent.xcrossing.mode == NotifyUngrab ) | 312 #ifdef DEBUG_XEVENTS |
309 printf("Mode: NotifyUngrab\n"); | 313 printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, |
310 #endif | 314 xevent.xcrossing.y); |
311 if ( (xevent.xcrossing.mode != NotifyGrab) && | 315 if (xevent.xcrossing.mode == NotifyGrab) |
312 (xevent.xcrossing.mode != NotifyUngrab) && | 316 printf("Mode: NotifyGrab\n"); |
313 (xevent.xcrossing.detail != NotifyInferior) ) { | 317 if (xevent.xcrossing.mode == NotifyUngrab) |
314 if ( this->input_grab == SDL_GRAB_OFF ) { | 318 printf("Mode: NotifyUngrab\n"); |
315 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | 319 #endif |
316 } else { | 320 if ((xevent.xcrossing.mode != NotifyGrab) && |
317 posted = SDL_PrivateMouseMotion(0, 0, | 321 (xevent.xcrossing.mode != NotifyUngrab) && |
318 xevent.xcrossing.x, | 322 (xevent.xcrossing.detail != NotifyInferior)) { |
319 xevent.xcrossing.y); | 323 if (SDL_CurrentWindow.input_grab == SDL_GRAB_OFF) { |
320 } | 324 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
321 } | 325 } else { |
322 } | 326 posted = SDL_PrivateMouseMotion(0, 0, |
323 break; | 327 xevent.xcrossing.x, |
324 | 328 xevent.xcrossing.y); |
325 /* Gaining input focus? */ | 329 } |
326 case FocusIn: { | 330 } |
327 #ifdef DEBUG_XEVENTS | 331 } |
328 printf("FocusIn!\n"); | 332 break; |
329 #endif | 333 |
330 posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); | 334 /* Gaining input focus? */ |
335 case FocusIn: | |
336 { | |
337 #ifdef DEBUG_XEVENTS | |
338 printf("FocusIn!\n"); | |
339 #endif | |
340 posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); | |
331 | 341 |
332 #ifdef X_HAVE_UTF8_STRING | 342 #ifdef X_HAVE_UTF8_STRING |
333 if ( SDL_IC != NULL ) { | 343 if (SDL_IC != NULL) { |
334 XSetICFocus(SDL_IC); | 344 XSetICFocus(SDL_IC); |
335 } | 345 } |
336 #endif | 346 #endif |
337 /* Queue entry into fullscreen mode */ | 347 /* Queue entry into fullscreen mode */ |
338 switch_waiting = 0x01 | SDL_FULLSCREEN; | 348 switch_waiting = 0x01 | SDL_FULLSCREEN; |
339 switch_time = SDL_GetTicks() + 1500; | 349 switch_time = SDL_GetTicks() + 1500; |
340 } | 350 } |
341 break; | 351 break; |
342 | 352 |
343 /* Losing input focus? */ | 353 /* Losing input focus? */ |
344 case FocusOut: { | 354 case FocusOut: |
345 #ifdef DEBUG_XEVENTS | 355 { |
346 printf("FocusOut!\n"); | 356 #ifdef DEBUG_XEVENTS |
347 #endif | 357 printf("FocusOut!\n"); |
348 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); | 358 #endif |
359 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); | |
349 | 360 |
350 #ifdef X_HAVE_UTF8_STRING | 361 #ifdef X_HAVE_UTF8_STRING |
351 if ( SDL_IC != NULL ) { | 362 if (SDL_IC != NULL) { |
352 XUnsetICFocus(SDL_IC); | 363 XUnsetICFocus(SDL_IC); |
353 } | 364 } |
354 #endif | 365 #endif |
355 /* Queue leaving fullscreen mode */ | 366 /* Queue leaving fullscreen mode */ |
356 switch_waiting = 0x01; | 367 switch_waiting = 0x01; |
357 switch_time = SDL_GetTicks() + 200; | 368 switch_time = SDL_GetTicks() + 200; |
358 } | 369 } |
359 break; | 370 break; |
360 | 371 |
361 /* Generated upon EnterWindow and FocusIn */ | 372 /* Generated upon EnterWindow and FocusIn */ |
362 case KeymapNotify: { | 373 case KeymapNotify: |
363 #ifdef DEBUG_XEVENTS | 374 { |
364 printf("KeymapNotify!\n"); | 375 #ifdef DEBUG_XEVENTS |
365 #endif | 376 printf("KeymapNotify!\n"); |
366 X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector); | 377 #endif |
367 } | 378 X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector); |
368 break; | 379 } |
369 | 380 break; |
370 /* Mouse motion? */ | 381 |
371 case MotionNotify: { | 382 /* Mouse motion? */ |
372 if ( SDL_VideoSurface ) { | 383 case MotionNotify: |
373 if ( mouse_relative ) { | 384 { |
374 if ( using_dga & DGA_MOUSE ) { | 385 if (SDL_VideoSurface) { |
386 if (mouse_relative) { | |
387 if (using_dga & DGA_MOUSE) { | |
375 #ifdef DEBUG_MOTION | 388 #ifdef DEBUG_MOTION |
376 printf("DGA motion: %d,%d\n", xevent.xmotion.x_root, xevent.xmotion.y_root); | 389 printf("DGA motion: %d,%d\n", |
377 #endif | 390 xevent.xmotion.x_root, xevent.xmotion.y_root); |
378 posted = SDL_PrivateMouseMotion(0, 1, | 391 #endif |
379 xevent.xmotion.x_root, | 392 posted = SDL_PrivateMouseMotion(0, 1, |
380 xevent.xmotion.y_root); | 393 xevent. |
381 } else { | 394 xmotion. |
382 posted = X11_WarpedMotion(this,&xevent); | 395 x_root, |
383 } | 396 xevent. |
384 } else { | 397 xmotion.y_root); |
398 } else { | |
399 posted = X11_WarpedMotion(_this, &xevent); | |
400 } | |
401 } else { | |
385 #ifdef DEBUG_MOTION | 402 #ifdef DEBUG_MOTION |
386 printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); | 403 printf("X11 motion: %d,%d\n", xevent.xmotion.x, |
387 #endif | 404 xevent.xmotion.y); |
388 posted = SDL_PrivateMouseMotion(0, 0, | 405 #endif |
389 xevent.xmotion.x, | 406 posted = SDL_PrivateMouseMotion(0, 0, |
390 xevent.xmotion.y); | 407 xevent.xmotion.x, |
391 } | 408 xevent.xmotion.y); |
392 } | 409 } |
393 } | 410 } |
394 break; | 411 } |
395 | 412 break; |
396 /* Mouse button press? */ | 413 |
397 case ButtonPress: { | 414 /* Mouse button press? */ |
398 posted = SDL_PrivateMouseButton(SDL_PRESSED, | 415 case ButtonPress: |
399 xevent.xbutton.button, 0, 0); | 416 { |
400 } | 417 posted = SDL_PrivateMouseButton(SDL_PRESSED, |
401 break; | 418 xevent.xbutton.button, 0, 0); |
402 | 419 } |
403 /* Mouse button release? */ | 420 break; |
404 case ButtonRelease: { | 421 |
405 posted = SDL_PrivateMouseButton(SDL_RELEASED, | 422 /* Mouse button release? */ |
406 xevent.xbutton.button, 0, 0); | 423 case ButtonRelease: |
407 } | 424 { |
408 break; | 425 posted = SDL_PrivateMouseButton(SDL_RELEASED, |
409 | 426 xevent.xbutton.button, 0, 0); |
410 /* Key press? */ | 427 } |
411 case KeyPress: { | 428 break; |
412 static SDL_keysym saved_keysym; | 429 |
413 SDL_keysym keysym; | 430 /* Key press? */ |
414 KeyCode keycode = xevent.xkey.keycode; | 431 case KeyPress: |
415 | 432 { |
416 #ifdef DEBUG_XEVENTS | 433 static SDL_keysym saved_keysym; |
417 printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); | 434 SDL_keysym keysym; |
418 #endif | 435 KeyCode keycode = xevent.xkey.keycode; |
419 /* Get the translated SDL virtual keysym */ | 436 |
420 if ( keycode ) { | 437 #ifdef DEBUG_XEVENTS |
421 keysym.scancode = keycode; | 438 printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); |
422 keysym.sym = X11_TranslateKeycode(SDL_Display, keycode); | 439 #endif |
423 keysym.mod = KMOD_NONE; | 440 /* Get the translated SDL virtual keysym */ |
424 keysym.unicode = 0; | 441 if (keycode) { |
425 } else { | 442 keysym.scancode = keycode; |
426 keysym = saved_keysym; | 443 keysym.sym = X11_TranslateKeycode(SDL_Display, keycode); |
427 } | 444 keysym.mod = KMOD_NONE; |
428 | 445 keysym.unicode = 0; |
429 /* If we're not doing translation, we're done! */ | 446 } else { |
430 if ( !SDL_TranslateUNICODE ) { | 447 keysym = saved_keysym; |
431 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); | 448 } |
432 break; | 449 |
433 } | 450 /* If we're not doing translation, we're done! */ |
434 | 451 if (!SDL_TranslateUNICODE) { |
435 if ( XFilterEvent(&xevent, None) ) { | 452 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
436 if ( xevent.xkey.keycode ) { | 453 break; |
437 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); | 454 } |
438 } else { | 455 |
439 /* Save event to be associated with IM text | 456 if (XFilterEvent(&xevent, None)) { |
440 In 1.3 we'll have a text event instead.. */ | 457 if (xevent.xkey.keycode) { |
441 saved_keysym = keysym; | 458 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
442 } | 459 } else { |
443 break; | 460 /* Save event to be associated with IM text |
444 } | 461 In 1.3 we'll have a text event instead.. */ |
445 | 462 saved_keysym = keysym; |
446 /* Look up the translated value for the key event */ | 463 } |
464 break; | |
465 } | |
466 | |
467 /* Look up the translated value for the key event */ | |
447 #ifdef X_HAVE_UTF8_STRING | 468 #ifdef X_HAVE_UTF8_STRING |
448 if ( SDL_IC != NULL ) { | 469 if (SDL_IC != NULL) { |
449 static Status state; | 470 static Status state; |
450 /* A UTF-8 character can be at most 6 bytes */ | 471 /* A UTF-8 character can be at most 6 bytes */ |
451 char keybuf[6]; | 472 char keybuf[6]; |
452 if ( Xutf8LookupString(SDL_IC, &xevent.xkey, | 473 if (Xutf8LookupString(SDL_IC, &xevent.xkey, |
453 keybuf, sizeof(keybuf), | 474 keybuf, sizeof(keybuf), NULL, &state)) { |
454 NULL, &state) ) { | 475 keysym.unicode = Utf8ToUcs4((Uint8 *) keybuf); |
455 keysym.unicode = Utf8ToUcs4((Uint8*)keybuf); | 476 } |
456 } | 477 } else |
457 } | 478 #endif |
458 else | 479 { |
459 #endif | 480 static XComposeStatus state; |
460 { | 481 char keybuf[32]; |
461 static XComposeStatus state; | 482 |
462 char keybuf[32]; | 483 if (XLookupString(&xevent.xkey, |
463 | 484 keybuf, sizeof(keybuf), NULL, &state)) { |
464 if ( XLookupString(&xevent.xkey, | 485 /* |
465 keybuf, sizeof(keybuf), | 486 * FIXME: XLookupString() may yield more than one |
466 NULL, &state) ) { | 487 * character, so we need a mechanism to allow for |
467 /* | 488 * this (perhaps null keypress events with a |
468 * FIXME: XLookupString() may yield more than one | 489 * unicode value) |
469 * character, so we need a mechanism to allow for | 490 */ |
470 * this (perhaps null keypress events with a | 491 keysym.unicode = (Uint8) keybuf[0]; |
471 * unicode value) | 492 } |
472 */ | 493 } |
473 keysym.unicode = (Uint8)keybuf[0]; | 494 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
474 } | 495 } |
475 } | 496 break; |
476 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); | 497 |
477 } | 498 /* Key release? */ |
478 break; | 499 case KeyRelease: |
479 | 500 { |
480 /* Key release? */ | 501 SDL_keysym keysym; |
481 case KeyRelease: { | 502 KeyCode keycode = xevent.xkey.keycode; |
482 SDL_keysym keysym; | 503 |
483 KeyCode keycode = xevent.xkey.keycode; | 504 #ifdef DEBUG_XEVENTS |
484 | 505 printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); |
485 #ifdef DEBUG_XEVENTS | 506 #endif |
486 printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); | 507 /* Check to see if this is a repeated key */ |
487 #endif | 508 if (X11_KeyRepeat(SDL_Display, &xevent)) { |
488 /* Check to see if this is a repeated key */ | 509 break; |
489 if ( X11_KeyRepeat(SDL_Display, &xevent) ) { | 510 } |
490 break; | 511 |
491 } | 512 /* Get the translated SDL virtual keysym */ |
492 | 513 keysym.scancode = keycode; |
493 /* Get the translated SDL virtual keysym */ | 514 keysym.sym = X11_TranslateKeycode(SDL_Display, keycode); |
494 keysym.scancode = keycode; | 515 keysym.mod = KMOD_NONE; |
495 keysym.sym = X11_TranslateKeycode(SDL_Display, keycode); | 516 keysym.unicode = 0; |
496 keysym.mod = KMOD_NONE; | 517 |
497 keysym.unicode = 0; | 518 posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); |
498 | 519 } |
499 posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); | 520 break; |
500 } | 521 |
501 break; | 522 /* Have we been iconified? */ |
502 | 523 case UnmapNotify: |
503 /* Have we been iconified? */ | 524 { |
504 case UnmapNotify: { | 525 #ifdef DEBUG_XEVENTS |
505 #ifdef DEBUG_XEVENTS | 526 printf("UnmapNotify!\n"); |
506 printf("UnmapNotify!\n"); | 527 #endif |
507 #endif | 528 /* If we're active, make ourselves inactive */ |
508 /* If we're active, make ourselves inactive */ | 529 if (SDL_GetAppState() & SDL_APPACTIVE) { |
509 if ( SDL_GetAppState() & SDL_APPACTIVE ) { | 530 /* Swap out the gamma before we go inactive */ |
510 /* Swap out the gamma before we go inactive */ | 531 X11_SwapVidModeGamma(_this); |
511 X11_SwapVidModeGamma(this); | 532 |
512 | 533 /* Send an internal deactivate event */ |
513 /* Send an internal deactivate event */ | 534 posted = SDL_PrivateAppActive(0, |
514 posted = SDL_PrivateAppActive(0, | 535 SDL_APPACTIVE | |
515 SDL_APPACTIVE|SDL_APPINPUTFOCUS); | 536 SDL_APPINPUTFOCUS); |
516 } | 537 } |
517 } | 538 } |
518 break; | 539 break; |
519 | 540 |
520 /* Have we been restored? */ | 541 /* Have we been restored? */ |
521 case MapNotify: { | 542 case MapNotify: |
522 #ifdef DEBUG_XEVENTS | 543 { |
523 printf("MapNotify!\n"); | 544 #ifdef DEBUG_XEVENTS |
524 #endif | 545 printf("MapNotify!\n"); |
525 /* If we're not active, make ourselves active */ | 546 #endif |
526 if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) { | 547 /* If we're not active, make ourselves active */ |
527 /* Send an internal activate event */ | 548 if (!(SDL_GetAppState() & SDL_APPACTIVE)) { |
528 posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); | 549 /* Send an internal activate event */ |
529 | 550 posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); |
530 /* Now that we're active, swap the gamma back */ | 551 |
531 X11_SwapVidModeGamma(this); | 552 /* Now that we're active, swap the gamma back */ |
532 } | 553 X11_SwapVidModeGamma(_this); |
533 | 554 } |
534 if ( SDL_VideoSurface && | 555 |
535 (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) { | 556 if (SDL_VideoSurface && |
536 X11_EnterFullScreen(this); | 557 (SDL_VideoSurface->flags & SDL_FULLSCREEN)) { |
537 } else { | 558 X11_EnterFullScreen(_this); |
538 X11_GrabInputNoLock(this, this->input_grab); | 559 } else { |
539 } | 560 X11_GrabInputNoLock(_this, SDL_CurrentWindow.input_grab); |
540 X11_CheckMouseModeNoLock(this); | 561 } |
541 | 562 X11_CheckMouseModeNoLock(_this); |
542 if ( SDL_VideoSurface ) { | 563 |
543 X11_RefreshDisplay(this); | 564 if (SDL_VideoSurface) { |
544 } | 565 X11_RefreshDisplay(_this); |
545 } | 566 } |
546 break; | 567 } |
547 | 568 break; |
548 /* Have we been resized or moved? */ | 569 |
549 case ConfigureNotify: { | 570 /* Have we been resized or moved? */ |
550 #ifdef DEBUG_XEVENTS | 571 case ConfigureNotify: |
551 printf("ConfigureNotify! (resize: %dx%d)\n", xevent.xconfigure.width, xevent.xconfigure.height); | 572 { |
552 #endif | 573 #ifdef DEBUG_XEVENTS |
553 if ( SDL_VideoSurface ) { | 574 printf("ConfigureNotify! (resize: %dx%d)\n", |
554 if ((xevent.xconfigure.width != SDL_VideoSurface->w) || | 575 xevent.xconfigure.width, xevent.xconfigure.height); |
555 (xevent.xconfigure.height != SDL_VideoSurface->h)) { | 576 #endif |
556 /* FIXME: Find a better fix for the bug with KDE 1.2 */ | 577 if (SDL_VideoSurface) { |
557 if ( ! ((xevent.xconfigure.width == 32) && | 578 if ((xevent.xconfigure.width != SDL_VideoSurface->w) || |
558 (xevent.xconfigure.height == 32)) ) { | 579 (xevent.xconfigure.height != SDL_VideoSurface->h)) { |
559 SDL_PrivateResize(xevent.xconfigure.width, | 580 /* FIXME: Find a better fix for the bug with KDE 1.2 */ |
560 xevent.xconfigure.height); | 581 if (!((xevent.xconfigure.width == 32) && |
561 } | 582 (xevent.xconfigure.height == 32))) { |
562 } else { | 583 SDL_PrivateResize(xevent.xconfigure.width, |
563 /* OpenGL windows need to know about the change */ | 584 xevent.xconfigure.height); |
564 if ( SDL_VideoSurface->flags & SDL_OPENGL ) { | 585 } |
565 SDL_PrivateExpose(); | 586 } else { |
566 } | 587 /* OpenGL windows need to know about the change */ |
567 } | 588 if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) { |
568 } | 589 SDL_PrivateExpose(); |
569 } | 590 } |
570 break; | 591 } |
571 | 592 } |
572 /* Have we been requested to quit (or another client message?) */ | 593 } |
573 case ClientMessage: { | 594 break; |
574 if ( (xevent.xclient.format == 32) && | 595 |
575 (xevent.xclient.data.l[0] == WM_DELETE_WINDOW) ) | 596 /* Have we been requested to quit (or another client message?) */ |
576 { | 597 case ClientMessage: |
577 posted = SDL_PrivateQuit(); | 598 { |
578 } else | 599 if ((xevent.xclient.format == 32) && |
579 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | 600 (xevent.xclient.data.l[0] == WM_DELETE_WINDOW)) { |
580 SDL_SysWMmsg wmmsg; | 601 posted = SDL_PrivateQuit(); |
581 | 602 } else if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { |
582 SDL_VERSION(&wmmsg.version); | 603 SDL_SysWMmsg wmmsg; |
583 wmmsg.subsystem = SDL_SYSWM_X11; | 604 |
584 wmmsg.event.xevent = xevent; | 605 SDL_VERSION(&wmmsg.version); |
585 posted = SDL_PrivateSysWMEvent(&wmmsg); | 606 wmmsg.subsystem = SDL_SYSWM_X11; |
586 } | 607 wmmsg.event.xevent = xevent; |
587 } | 608 posted = SDL_PrivateSysWMEvent(&wmmsg); |
588 break; | 609 } |
589 | 610 } |
590 /* Do we need to refresh ourselves? */ | 611 break; |
591 case Expose: { | 612 |
592 #ifdef DEBUG_XEVENTS | 613 /* Do we need to refresh ourselves? */ |
593 printf("Expose (count = %d)\n", xevent.xexpose.count); | 614 case Expose: |
594 #endif | 615 { |
595 if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) { | 616 #ifdef DEBUG_XEVENTS |
596 X11_RefreshDisplay(this); | 617 printf("Expose (count = %d)\n", xevent.xexpose.count); |
597 } | 618 #endif |
598 } | 619 if (SDL_VideoSurface && (xevent.xexpose.count == 0)) { |
599 break; | 620 X11_RefreshDisplay(_this); |
600 | 621 } |
601 default: { | 622 } |
602 #ifdef DEBUG_XEVENTS | 623 break; |
603 printf("Unhandled event %d\n", xevent.type); | 624 |
604 #endif | 625 default: |
605 /* Only post the event if we're watching for it */ | 626 { |
606 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | 627 #ifdef DEBUG_XEVENTS |
607 SDL_SysWMmsg wmmsg; | 628 printf("Unhandled event %d\n", xevent.type); |
608 | 629 #endif |
609 SDL_VERSION(&wmmsg.version); | 630 /* Only post the event if we're watching for it */ |
610 wmmsg.subsystem = SDL_SYSWM_X11; | 631 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { |
611 wmmsg.event.xevent = xevent; | 632 SDL_SysWMmsg wmmsg; |
612 posted = SDL_PrivateSysWMEvent(&wmmsg); | 633 |
613 } | 634 SDL_VERSION(&wmmsg.version); |
614 } | 635 wmmsg.subsystem = SDL_SYSWM_X11; |
615 break; | 636 wmmsg.event.xevent = xevent; |
616 } | 637 posted = SDL_PrivateSysWMEvent(&wmmsg); |
617 return(posted); | 638 } |
639 } | |
640 break; | |
641 } | |
642 return (posted); | |
618 } | 643 } |
619 | 644 |
620 /* Ack! XPending() actually performs a blocking read if no events available */ | 645 /* Ack! XPending() actually performs a blocking read if no events available */ |
621 int X11_Pending(Display *display) | 646 int |
622 { | 647 X11_Pending(Display * display) |
623 /* Flush the display connection and look to see if events are queued */ | 648 { |
624 XFlush(display); | 649 /* Flush the display connection and look to see if events are queued */ |
625 if ( XEventsQueued(display, QueuedAlready) ) { | 650 XFlush(display); |
626 return(1); | 651 if (XEventsQueued(display, QueuedAlready)) { |
627 } | 652 return (1); |
628 | 653 } |
629 /* More drastic measures are required -- see if X is ready to talk */ | 654 |
630 { | 655 /* More drastic measures are required -- see if X is ready to talk */ |
631 static struct timeval zero_time; /* static == 0 */ | 656 { |
632 int x11_fd; | 657 static struct timeval zero_time; /* static == 0 */ |
633 fd_set fdset; | 658 int x11_fd; |
634 | 659 fd_set fdset; |
635 x11_fd = ConnectionNumber(display); | 660 |
636 FD_ZERO(&fdset); | 661 x11_fd = ConnectionNumber(display); |
637 FD_SET(x11_fd, &fdset); | 662 FD_ZERO(&fdset); |
638 if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) { | 663 FD_SET(x11_fd, &fdset); |
639 return(XPending(display)); | 664 if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) { |
640 } | 665 return (XPending(display)); |
641 } | 666 } |
642 | 667 } |
643 /* Oh well, nothing is ready .. */ | 668 |
644 return(0); | 669 /* Oh well, nothing is ready .. */ |
645 } | 670 return (0); |
646 | 671 } |
647 void X11_PumpEvents(_THIS) | 672 |
648 { | 673 void |
649 int pending; | 674 X11_PumpEvents(_THIS) |
650 | 675 { |
651 /* Keep processing pending events */ | 676 int pending; |
652 pending = 0; | 677 |
653 while ( X11_Pending(SDL_Display) ) { | 678 /* Keep processing pending events */ |
654 X11_DispatchEvent(this); | 679 pending = 0; |
655 ++pending; | 680 while (X11_Pending(SDL_Display)) { |
656 } | 681 X11_DispatchEvent(_this); |
657 if ( switch_waiting ) { | 682 ++pending; |
658 Uint32 now; | 683 } |
659 | 684 if (switch_waiting) { |
660 now = SDL_GetTicks(); | 685 Uint32 now; |
661 if ( pending || !SDL_VideoSurface ) { | 686 |
662 /* Try again later... */ | 687 now = SDL_GetTicks(); |
663 if ( switch_waiting & SDL_FULLSCREEN ) { | 688 if (pending || !SDL_VideoSurface) { |
664 switch_time = now + 1500; | 689 /* Try again later... */ |
665 } else { | 690 if (switch_waiting & SDL_FULLSCREEN) { |
666 switch_time = now + 200; | 691 switch_time = now + 1500; |
667 } | 692 } else { |
668 } else if ( (int)(switch_time-now) <= 0 ) { | 693 switch_time = now + 200; |
669 Uint32 go_fullscreen; | 694 } |
670 | 695 } else if ((int) (switch_time - now) <= 0) { |
671 go_fullscreen = switch_waiting & SDL_FULLSCREEN; | 696 Uint32 go_fullscreen; |
672 switch_waiting = 0; | 697 |
673 if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) { | 698 go_fullscreen = switch_waiting & SDL_FULLSCREEN; |
674 if ( go_fullscreen ) { | 699 switch_waiting = 0; |
675 X11_EnterFullScreen(this); | 700 if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { |
676 } else { | 701 if (go_fullscreen) { |
677 X11_LeaveFullScreen(this); | 702 X11_EnterFullScreen(_this); |
678 } | 703 } else { |
679 } | 704 X11_LeaveFullScreen(_this); |
680 /* Handle focus in/out when grabbed */ | 705 } |
681 if ( go_fullscreen ) { | 706 } |
682 X11_GrabInputNoLock(this, this->input_grab); | 707 /* Handle focus in/out when grabbed */ |
683 } else { | 708 if (go_fullscreen) { |
684 X11_GrabInputNoLock(this, SDL_GRAB_OFF); | 709 X11_GrabInputNoLock(_this, SDL_CurrentWindow.input_grab); |
685 } | 710 } else { |
686 X11_CheckMouseModeNoLock(this); | 711 X11_GrabInputNoLock(_this, SDL_GRAB_OFF); |
687 } | 712 } |
688 } | 713 X11_CheckMouseModeNoLock(_this); |
689 } | 714 } |
690 | 715 } |
691 void X11_InitKeymap(void) | 716 } |
692 { | 717 |
693 int i; | 718 void |
694 | 719 X11_InitKeymap(void) |
695 /* Odd keys used in international keyboards */ | 720 { |
696 for ( i=0; i<SDL_arraysize(ODD_keymap); ++i ) | 721 int i; |
697 ODD_keymap[i] = SDLK_UNKNOWN; | 722 |
698 | 723 /* Odd keys used in international keyboards */ |
699 /* Some of these might be mappable to an existing SDLK_ code */ | 724 for (i = 0; i < SDL_arraysize(ODD_keymap); ++i) |
700 ODD_keymap[XK_dead_grave&0xFF] = SDLK_COMPOSE; | 725 ODD_keymap[i] = SDLK_UNKNOWN; |
701 ODD_keymap[XK_dead_acute&0xFF] = SDLK_COMPOSE; | 726 |
702 ODD_keymap[XK_dead_tilde&0xFF] = SDLK_COMPOSE; | 727 /* Some of these might be mappable to an existing SDLK_ code */ |
703 ODD_keymap[XK_dead_macron&0xFF] = SDLK_COMPOSE; | 728 ODD_keymap[XK_dead_grave & 0xFF] = SDLK_COMPOSE; |
704 ODD_keymap[XK_dead_breve&0xFF] = SDLK_COMPOSE; | 729 ODD_keymap[XK_dead_acute & 0xFF] = SDLK_COMPOSE; |
705 ODD_keymap[XK_dead_abovedot&0xFF] = SDLK_COMPOSE; | 730 ODD_keymap[XK_dead_tilde & 0xFF] = SDLK_COMPOSE; |
706 ODD_keymap[XK_dead_diaeresis&0xFF] = SDLK_COMPOSE; | 731 ODD_keymap[XK_dead_macron & 0xFF] = SDLK_COMPOSE; |
707 ODD_keymap[XK_dead_abovering&0xFF] = SDLK_COMPOSE; | 732 ODD_keymap[XK_dead_breve & 0xFF] = SDLK_COMPOSE; |
708 ODD_keymap[XK_dead_doubleacute&0xFF] = SDLK_COMPOSE; | 733 ODD_keymap[XK_dead_abovedot & 0xFF] = SDLK_COMPOSE; |
709 ODD_keymap[XK_dead_caron&0xFF] = SDLK_COMPOSE; | 734 ODD_keymap[XK_dead_diaeresis & 0xFF] = SDLK_COMPOSE; |
710 ODD_keymap[XK_dead_cedilla&0xFF] = SDLK_COMPOSE; | 735 ODD_keymap[XK_dead_abovering & 0xFF] = SDLK_COMPOSE; |
711 ODD_keymap[XK_dead_ogonek&0xFF] = SDLK_COMPOSE; | 736 ODD_keymap[XK_dead_doubleacute & 0xFF] = SDLK_COMPOSE; |
712 ODD_keymap[XK_dead_iota&0xFF] = SDLK_COMPOSE; | 737 ODD_keymap[XK_dead_caron & 0xFF] = SDLK_COMPOSE; |
713 ODD_keymap[XK_dead_voiced_sound&0xFF] = SDLK_COMPOSE; | 738 ODD_keymap[XK_dead_cedilla & 0xFF] = SDLK_COMPOSE; |
714 ODD_keymap[XK_dead_semivoiced_sound&0xFF] = SDLK_COMPOSE; | 739 ODD_keymap[XK_dead_ogonek & 0xFF] = SDLK_COMPOSE; |
715 ODD_keymap[XK_dead_belowdot&0xFF] = SDLK_COMPOSE; | 740 ODD_keymap[XK_dead_iota & 0xFF] = SDLK_COMPOSE; |
741 ODD_keymap[XK_dead_voiced_sound & 0xFF] = SDLK_COMPOSE; | |
742 ODD_keymap[XK_dead_semivoiced_sound & 0xFF] = SDLK_COMPOSE; | |
743 ODD_keymap[XK_dead_belowdot & 0xFF] = SDLK_COMPOSE; | |
716 #ifdef XK_dead_hook | 744 #ifdef XK_dead_hook |
717 ODD_keymap[XK_dead_hook&0xFF] = SDLK_COMPOSE; | 745 ODD_keymap[XK_dead_hook & 0xFF] = SDLK_COMPOSE; |
718 #endif | 746 #endif |
719 #ifdef XK_dead_horn | 747 #ifdef XK_dead_horn |
720 ODD_keymap[XK_dead_horn&0xFF] = SDLK_COMPOSE; | 748 ODD_keymap[XK_dead_horn & 0xFF] = SDLK_COMPOSE; |
721 #endif | 749 #endif |
722 | 750 |
723 #ifdef XK_dead_circumflex | 751 #ifdef XK_dead_circumflex |
724 /* These X keysyms have 0xFE as the high byte */ | 752 /* These X keysyms have 0xFE as the high byte */ |
725 ODD_keymap[XK_dead_circumflex&0xFF] = SDLK_CARET; | 753 ODD_keymap[XK_dead_circumflex & 0xFF] = SDLK_CARET; |
726 #endif | 754 #endif |
727 #ifdef XK_ISO_Level3_Shift | 755 #ifdef XK_ISO_Level3_Shift |
728 ODD_keymap[XK_ISO_Level3_Shift&0xFF] = SDLK_MODE; /* "Alt Gr" key */ | 756 ODD_keymap[XK_ISO_Level3_Shift & 0xFF] = SDLK_MODE; /* "Alt Gr" key */ |
729 #endif | 757 #endif |
730 | 758 |
731 /* Map the miscellaneous keys */ | 759 /* Map the miscellaneous keys */ |
732 for ( i=0; i<SDL_arraysize(MISC_keymap); ++i ) | 760 for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) |
733 MISC_keymap[i] = SDLK_UNKNOWN; | 761 MISC_keymap[i] = SDLK_UNKNOWN; |
734 | 762 |
735 /* These X keysyms have 0xFF as the high byte */ | 763 /* These X keysyms have 0xFF as the high byte */ |
736 MISC_keymap[XK_BackSpace&0xFF] = SDLK_BACKSPACE; | 764 MISC_keymap[XK_BackSpace & 0xFF] = SDLK_BACKSPACE; |
737 MISC_keymap[XK_Tab&0xFF] = SDLK_TAB; | 765 MISC_keymap[XK_Tab & 0xFF] = SDLK_TAB; |
738 MISC_keymap[XK_Clear&0xFF] = SDLK_CLEAR; | 766 MISC_keymap[XK_Clear & 0xFF] = SDLK_CLEAR; |
739 MISC_keymap[XK_Return&0xFF] = SDLK_RETURN; | 767 MISC_keymap[XK_Return & 0xFF] = SDLK_RETURN; |
740 MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE; | 768 MISC_keymap[XK_Pause & 0xFF] = SDLK_PAUSE; |
741 MISC_keymap[XK_Escape&0xFF] = SDLK_ESCAPE; | 769 MISC_keymap[XK_Escape & 0xFF] = SDLK_ESCAPE; |
742 MISC_keymap[XK_Delete&0xFF] = SDLK_DELETE; | 770 MISC_keymap[XK_Delete & 0xFF] = SDLK_DELETE; |
743 | 771 |
744 MISC_keymap[XK_KP_0&0xFF] = SDLK_KP0; /* Keypad 0-9 */ | 772 MISC_keymap[XK_KP_0 & 0xFF] = SDLK_KP0; /* Keypad 0-9 */ |
745 MISC_keymap[XK_KP_1&0xFF] = SDLK_KP1; | 773 MISC_keymap[XK_KP_1 & 0xFF] = SDLK_KP1; |
746 MISC_keymap[XK_KP_2&0xFF] = SDLK_KP2; | 774 MISC_keymap[XK_KP_2 & 0xFF] = SDLK_KP2; |
747 MISC_keymap[XK_KP_3&0xFF] = SDLK_KP3; | 775 MISC_keymap[XK_KP_3 & 0xFF] = SDLK_KP3; |
748 MISC_keymap[XK_KP_4&0xFF] = SDLK_KP4; | 776 MISC_keymap[XK_KP_4 & 0xFF] = SDLK_KP4; |
749 MISC_keymap[XK_KP_5&0xFF] = SDLK_KP5; | 777 MISC_keymap[XK_KP_5 & 0xFF] = SDLK_KP5; |
750 MISC_keymap[XK_KP_6&0xFF] = SDLK_KP6; | 778 MISC_keymap[XK_KP_6 & 0xFF] = SDLK_KP6; |
751 MISC_keymap[XK_KP_7&0xFF] = SDLK_KP7; | 779 MISC_keymap[XK_KP_7 & 0xFF] = SDLK_KP7; |
752 MISC_keymap[XK_KP_8&0xFF] = SDLK_KP8; | 780 MISC_keymap[XK_KP_8 & 0xFF] = SDLK_KP8; |
753 MISC_keymap[XK_KP_9&0xFF] = SDLK_KP9; | 781 MISC_keymap[XK_KP_9 & 0xFF] = SDLK_KP9; |
754 MISC_keymap[XK_KP_Insert&0xFF] = SDLK_KP0; | 782 MISC_keymap[XK_KP_Insert & 0xFF] = SDLK_KP0; |
755 MISC_keymap[XK_KP_End&0xFF] = SDLK_KP1; | 783 MISC_keymap[XK_KP_End & 0xFF] = SDLK_KP1; |
756 MISC_keymap[XK_KP_Down&0xFF] = SDLK_KP2; | 784 MISC_keymap[XK_KP_Down & 0xFF] = SDLK_KP2; |
757 MISC_keymap[XK_KP_Page_Down&0xFF] = SDLK_KP3; | 785 MISC_keymap[XK_KP_Page_Down & 0xFF] = SDLK_KP3; |
758 MISC_keymap[XK_KP_Left&0xFF] = SDLK_KP4; | 786 MISC_keymap[XK_KP_Left & 0xFF] = SDLK_KP4; |
759 MISC_keymap[XK_KP_Begin&0xFF] = SDLK_KP5; | 787 MISC_keymap[XK_KP_Begin & 0xFF] = SDLK_KP5; |
760 MISC_keymap[XK_KP_Right&0xFF] = SDLK_KP6; | 788 MISC_keymap[XK_KP_Right & 0xFF] = SDLK_KP6; |
761 MISC_keymap[XK_KP_Home&0xFF] = SDLK_KP7; | 789 MISC_keymap[XK_KP_Home & 0xFF] = SDLK_KP7; |
762 MISC_keymap[XK_KP_Up&0xFF] = SDLK_KP8; | 790 MISC_keymap[XK_KP_Up & 0xFF] = SDLK_KP8; |
763 MISC_keymap[XK_KP_Page_Up&0xFF] = SDLK_KP9; | 791 MISC_keymap[XK_KP_Page_Up & 0xFF] = SDLK_KP9; |
764 MISC_keymap[XK_KP_Delete&0xFF] = SDLK_KP_PERIOD; | 792 MISC_keymap[XK_KP_Delete & 0xFF] = SDLK_KP_PERIOD; |
765 MISC_keymap[XK_KP_Decimal&0xFF] = SDLK_KP_PERIOD; | 793 MISC_keymap[XK_KP_Decimal & 0xFF] = SDLK_KP_PERIOD; |
766 MISC_keymap[XK_KP_Divide&0xFF] = SDLK_KP_DIVIDE; | 794 MISC_keymap[XK_KP_Divide & 0xFF] = SDLK_KP_DIVIDE; |
767 MISC_keymap[XK_KP_Multiply&0xFF] = SDLK_KP_MULTIPLY; | 795 MISC_keymap[XK_KP_Multiply & 0xFF] = SDLK_KP_MULTIPLY; |
768 MISC_keymap[XK_KP_Subtract&0xFF] = SDLK_KP_MINUS; | 796 MISC_keymap[XK_KP_Subtract & 0xFF] = SDLK_KP_MINUS; |
769 MISC_keymap[XK_KP_Add&0xFF] = SDLK_KP_PLUS; | 797 MISC_keymap[XK_KP_Add & 0xFF] = SDLK_KP_PLUS; |
770 MISC_keymap[XK_KP_Enter&0xFF] = SDLK_KP_ENTER; | 798 MISC_keymap[XK_KP_Enter & 0xFF] = SDLK_KP_ENTER; |
771 MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS; | 799 MISC_keymap[XK_KP_Equal & 0xFF] = SDLK_KP_EQUALS; |
772 | 800 |
773 MISC_keymap[XK_Up&0xFF] = SDLK_UP; | 801 MISC_keymap[XK_Up & 0xFF] = SDLK_UP; |
774 MISC_keymap[XK_Down&0xFF] = SDLK_DOWN; | 802 MISC_keymap[XK_Down & 0xFF] = SDLK_DOWN; |
775 MISC_keymap[XK_Right&0xFF] = SDLK_RIGHT; | 803 MISC_keymap[XK_Right & 0xFF] = SDLK_RIGHT; |
776 MISC_keymap[XK_Left&0xFF] = SDLK_LEFT; | 804 MISC_keymap[XK_Left & 0xFF] = SDLK_LEFT; |
777 MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT; | 805 MISC_keymap[XK_Insert & 0xFF] = SDLK_INSERT; |
778 MISC_keymap[XK_Home&0xFF] = SDLK_HOME; | 806 MISC_keymap[XK_Home & 0xFF] = SDLK_HOME; |
779 MISC_keymap[XK_End&0xFF] = SDLK_END; | 807 MISC_keymap[XK_End & 0xFF] = SDLK_END; |
780 MISC_keymap[XK_Page_Up&0xFF] = SDLK_PAGEUP; | 808 MISC_keymap[XK_Page_Up & 0xFF] = SDLK_PAGEUP; |
781 MISC_keymap[XK_Page_Down&0xFF] = SDLK_PAGEDOWN; | 809 MISC_keymap[XK_Page_Down & 0xFF] = SDLK_PAGEDOWN; |
782 | 810 |
783 MISC_keymap[XK_F1&0xFF] = SDLK_F1; | 811 MISC_keymap[XK_F1 & 0xFF] = SDLK_F1; |
784 MISC_keymap[XK_F2&0xFF] = SDLK_F2; | 812 MISC_keymap[XK_F2 & 0xFF] = SDLK_F2; |
785 MISC_keymap[XK_F3&0xFF] = SDLK_F3; | 813 MISC_keymap[XK_F3 & 0xFF] = SDLK_F3; |
786 MISC_keymap[XK_F4&0xFF] = SDLK_F4; | 814 MISC_keymap[XK_F4 & 0xFF] = SDLK_F4; |
787 MISC_keymap[XK_F5&0xFF] = SDLK_F5; | 815 MISC_keymap[XK_F5 & 0xFF] = SDLK_F5; |
788 MISC_keymap[XK_F6&0xFF] = SDLK_F6; | 816 MISC_keymap[XK_F6 & 0xFF] = SDLK_F6; |
789 MISC_keymap[XK_F7&0xFF] = SDLK_F7; | 817 MISC_keymap[XK_F7 & 0xFF] = SDLK_F7; |
790 MISC_keymap[XK_F8&0xFF] = SDLK_F8; | 818 MISC_keymap[XK_F8 & 0xFF] = SDLK_F8; |
791 MISC_keymap[XK_F9&0xFF] = SDLK_F9; | 819 MISC_keymap[XK_F9 & 0xFF] = SDLK_F9; |
792 MISC_keymap[XK_F10&0xFF] = SDLK_F10; | 820 MISC_keymap[XK_F10 & 0xFF] = SDLK_F10; |
793 MISC_keymap[XK_F11&0xFF] = SDLK_F11; | 821 MISC_keymap[XK_F11 & 0xFF] = SDLK_F11; |
794 MISC_keymap[XK_F12&0xFF] = SDLK_F12; | 822 MISC_keymap[XK_F12 & 0xFF] = SDLK_F12; |
795 MISC_keymap[XK_F13&0xFF] = SDLK_F13; | 823 MISC_keymap[XK_F13 & 0xFF] = SDLK_F13; |
796 MISC_keymap[XK_F14&0xFF] = SDLK_F14; | 824 MISC_keymap[XK_F14 & 0xFF] = SDLK_F14; |
797 MISC_keymap[XK_F15&0xFF] = SDLK_F15; | 825 MISC_keymap[XK_F15 & 0xFF] = SDLK_F15; |
798 | 826 |
799 MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK; | 827 MISC_keymap[XK_Num_Lock & 0xFF] = SDLK_NUMLOCK; |
800 MISC_keymap[XK_Caps_Lock&0xFF] = SDLK_CAPSLOCK; | 828 MISC_keymap[XK_Caps_Lock & 0xFF] = SDLK_CAPSLOCK; |
801 MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK; | 829 MISC_keymap[XK_Scroll_Lock & 0xFF] = SDLK_SCROLLOCK; |
802 MISC_keymap[XK_Shift_R&0xFF] = SDLK_RSHIFT; | 830 MISC_keymap[XK_Shift_R & 0xFF] = SDLK_RSHIFT; |
803 MISC_keymap[XK_Shift_L&0xFF] = SDLK_LSHIFT; | 831 MISC_keymap[XK_Shift_L & 0xFF] = SDLK_LSHIFT; |
804 MISC_keymap[XK_Control_R&0xFF] = SDLK_RCTRL; | 832 MISC_keymap[XK_Control_R & 0xFF] = SDLK_RCTRL; |
805 MISC_keymap[XK_Control_L&0xFF] = SDLK_LCTRL; | 833 MISC_keymap[XK_Control_L & 0xFF] = SDLK_LCTRL; |
806 MISC_keymap[XK_Alt_R&0xFF] = SDLK_RALT; | 834 MISC_keymap[XK_Alt_R & 0xFF] = SDLK_RALT; |
807 MISC_keymap[XK_Alt_L&0xFF] = SDLK_LALT; | 835 MISC_keymap[XK_Alt_L & 0xFF] = SDLK_LALT; |
808 MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA; | 836 MISC_keymap[XK_Meta_R & 0xFF] = SDLK_RMETA; |
809 MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA; | 837 MISC_keymap[XK_Meta_L & 0xFF] = SDLK_LMETA; |
810 MISC_keymap[XK_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */ | 838 MISC_keymap[XK_Super_L & 0xFF] = SDLK_LSUPER; /* Left "Windows" */ |
811 MISC_keymap[XK_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows */ | 839 MISC_keymap[XK_Super_R & 0xFF] = SDLK_RSUPER; /* Right "Windows */ |
812 MISC_keymap[XK_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */ | 840 MISC_keymap[XK_Mode_switch & 0xFF] = SDLK_MODE; /* "Alt Gr" key */ |
813 MISC_keymap[XK_Multi_key&0xFF] = SDLK_COMPOSE; /* Multi-key compose */ | 841 MISC_keymap[XK_Multi_key & 0xFF] = SDLK_COMPOSE; /* Multi-key compose */ |
814 | 842 |
815 MISC_keymap[XK_Help&0xFF] = SDLK_HELP; | 843 MISC_keymap[XK_Help & 0xFF] = SDLK_HELP; |
816 MISC_keymap[XK_Print&0xFF] = SDLK_PRINT; | 844 MISC_keymap[XK_Print & 0xFF] = SDLK_PRINT; |
817 MISC_keymap[XK_Sys_Req&0xFF] = SDLK_SYSREQ; | 845 MISC_keymap[XK_Sys_Req & 0xFF] = SDLK_SYSREQ; |
818 MISC_keymap[XK_Break&0xFF] = SDLK_BREAK; | 846 MISC_keymap[XK_Break & 0xFF] = SDLK_BREAK; |
819 MISC_keymap[XK_Menu&0xFF] = SDLK_MENU; | 847 MISC_keymap[XK_Menu & 0xFF] = SDLK_MENU; |
820 MISC_keymap[XK_Hyper_R&0xFF] = SDLK_MENU; /* Windows "Menu" key */ | 848 MISC_keymap[XK_Hyper_R & 0xFF] = SDLK_MENU; /* Windows "Menu" key */ |
821 } | 849 } |
822 | 850 |
823 /* Get the translated SDL virtual keysym */ | 851 /* Get the translated SDL virtual keysym */ |
824 SDLKey X11_TranslateKeycode(Display *display, KeyCode kc) | 852 SDLKey |
825 { | 853 X11_TranslateKeycode(Display * display, KeyCode kc) |
826 KeySym xsym; | 854 { |
827 SDLKey key; | 855 KeySym xsym; |
828 | 856 SDLKey key; |
829 xsym = XKeycodeToKeysym(display, kc, 0); | 857 |
858 xsym = XKeycodeToKeysym(display, kc, 0); | |
830 #ifdef DEBUG_KEYS | 859 #ifdef DEBUG_KEYS |
831 fprintf(stderr, "Translating key code %d -> 0x%.4x\n", kc, xsym); | 860 fprintf(stderr, "Translating key code %d -> 0x%.4x\n", kc, xsym); |
832 #endif | 861 #endif |
833 key = SDLK_UNKNOWN; | 862 key = SDLK_UNKNOWN; |
834 if ( xsym ) { | 863 if (xsym) { |
835 switch (xsym>>8) { | 864 switch (xsym >> 8) { |
836 case 0x1005FF: | 865 case 0x1005FF: |
837 #ifdef SunXK_F36 | 866 #ifdef SunXK_F36 |
838 if ( xsym == SunXK_F36 ) | 867 if (xsym == SunXK_F36) |
839 key = SDLK_F11; | 868 key = SDLK_F11; |
840 #endif | 869 #endif |
841 #ifdef SunXK_F37 | 870 #ifdef SunXK_F37 |
842 if ( xsym == SunXK_F37 ) | 871 if (xsym == SunXK_F37) |
843 key = SDLK_F12; | 872 key = SDLK_F12; |
844 #endif | 873 #endif |
845 break; | 874 break; |
846 case 0x00: /* Latin 1 */ | 875 case 0x00: /* Latin 1 */ |
847 key = (SDLKey)(xsym & 0xFF); | 876 key = (SDLKey) (xsym & 0xFF); |
848 break; | 877 break; |
849 case 0x01: /* Latin 2 */ | 878 case 0x01: /* Latin 2 */ |
850 case 0x02: /* Latin 3 */ | 879 case 0x02: /* Latin 3 */ |
851 case 0x03: /* Latin 4 */ | 880 case 0x03: /* Latin 4 */ |
852 case 0x04: /* Katakana */ | 881 case 0x04: /* Katakana */ |
853 case 0x05: /* Arabic */ | 882 case 0x05: /* Arabic */ |
854 case 0x06: /* Cyrillic */ | 883 case 0x06: /* Cyrillic */ |
855 case 0x07: /* Greek */ | 884 case 0x07: /* Greek */ |
856 case 0x08: /* Technical */ | 885 case 0x08: /* Technical */ |
857 case 0x0A: /* Publishing */ | 886 case 0x0A: /* Publishing */ |
858 case 0x0C: /* Hebrew */ | 887 case 0x0C: /* Hebrew */ |
859 case 0x0D: /* Thai */ | 888 case 0x0D: /* Thai */ |
860 /* These are wrong, but it's better than nothing */ | 889 /* These are wrong, but it's better than nothing */ |
861 key = (SDLKey)(xsym & 0xFF); | 890 key = (SDLKey) (xsym & 0xFF); |
862 break; | 891 break; |
863 case 0xFE: | 892 case 0xFE: |
864 key = ODD_keymap[xsym&0xFF]; | 893 key = ODD_keymap[xsym & 0xFF]; |
865 break; | 894 break; |
866 case 0xFF: | 895 case 0xFF: |
867 key = MISC_keymap[xsym&0xFF]; | 896 key = MISC_keymap[xsym & 0xFF]; |
868 break; | 897 break; |
869 default: | 898 default: |
870 /* | 899 /* |
871 fprintf(stderr, "X11: Unhandled xsym, sym = 0x%04x\n", | 900 fprintf(stderr, "X11: Unhandled xsym, sym = 0x%04x\n", |
872 (unsigned int)xsym); | 901 (unsigned int)xsym); |
873 */ | 902 */ |
874 break; | 903 break; |
875 } | 904 } |
876 } else { | 905 } else { |
877 /* X11 doesn't know how to translate the key! */ | 906 /* X11 doesn't know how to translate the key! */ |
878 switch (kc) { | 907 switch (kc) { |
879 /* Caution: | 908 /* Caution: |
880 These keycodes are from the Microsoft Keyboard | 909 These keycodes are from the Microsoft Keyboard |
881 */ | 910 */ |
882 case 115: | 911 case 115: |
883 key = SDLK_LSUPER; | 912 key = SDLK_LSUPER; |
884 break; | 913 break; |
885 case 116: | 914 case 116: |
886 key = SDLK_RSUPER; | 915 key = SDLK_RSUPER; |
887 break; | 916 break; |
888 case 117: | 917 case 117: |
889 key = SDLK_MENU; | 918 key = SDLK_MENU; |
890 break; | 919 break; |
891 default: | 920 default: |
892 /* | 921 /* |
893 * no point in an error message; happens for | 922 * no point in an error message; happens for |
894 * several keys when we get a keymap notify | 923 * several keys when we get a keymap notify |
895 */ | 924 */ |
896 break; | 925 break; |
897 } | 926 } |
898 } | 927 } |
899 return key; | 928 return key; |
900 } | 929 } |
901 | 930 |
902 /* X11 modifier masks for various keys */ | 931 /* X11 modifier masks for various keys */ |
903 static unsigned meta_l_mask, meta_r_mask, alt_l_mask, alt_r_mask; | 932 static unsigned meta_l_mask, meta_r_mask, alt_l_mask, alt_r_mask; |
904 static unsigned num_mask, mode_switch_mask; | 933 static unsigned num_mask, mode_switch_mask; |
905 | 934 |
906 static void get_modifier_masks(Display *display) | 935 static void |
907 { | 936 get_modifier_masks(Display * display) |
908 static unsigned got_masks; | 937 { |
909 int i, j; | 938 static unsigned got_masks; |
910 XModifierKeymap *xmods; | 939 int i, j; |
911 unsigned n; | 940 XModifierKeymap *xmods; |
912 | 941 unsigned n; |
913 if(got_masks) | 942 |
914 return; | 943 if (got_masks) |
915 | 944 return; |
916 xmods = XGetModifierMapping(display); | 945 |
917 n = xmods->max_keypermod; | 946 xmods = XGetModifierMapping(display); |
918 for(i = 3; i < 8; i++) { | 947 n = xmods->max_keypermod; |
919 for(j = 0; j < n; j++) { | 948 for (i = 3; i < 8; i++) { |
920 KeyCode kc = xmods->modifiermap[i * n + j]; | 949 for (j = 0; j < n; j++) { |
921 KeySym ks = XKeycodeToKeysym(display, kc, 0); | 950 KeyCode kc = xmods->modifiermap[i * n + j]; |
922 unsigned mask = 1 << i; | 951 KeySym ks = XKeycodeToKeysym(display, kc, 0); |
923 switch(ks) { | 952 unsigned mask = 1 << i; |
924 case XK_Num_Lock: | 953 switch (ks) { |
925 num_mask = mask; break; | 954 case XK_Num_Lock: |
926 case XK_Alt_L: | 955 num_mask = mask; |
927 alt_l_mask = mask; break; | 956 break; |
928 case XK_Alt_R: | 957 case XK_Alt_L: |
929 alt_r_mask = mask; break; | 958 alt_l_mask = mask; |
930 case XK_Meta_L: | 959 break; |
931 meta_l_mask = mask; break; | 960 case XK_Alt_R: |
932 case XK_Meta_R: | 961 alt_r_mask = mask; |
933 meta_r_mask = mask; break; | 962 break; |
934 case XK_Mode_switch: | 963 case XK_Meta_L: |
935 mode_switch_mask = mask; break; | 964 meta_l_mask = mask; |
936 } | 965 break; |
937 } | 966 case XK_Meta_R: |
938 } | 967 meta_r_mask = mask; |
939 XFreeModifiermap(xmods); | 968 break; |
940 got_masks = 1; | 969 case XK_Mode_switch: |
970 mode_switch_mask = mask; | |
971 break; | |
972 } | |
973 } | |
974 } | |
975 XFreeModifiermap(xmods); | |
976 got_masks = 1; | |
941 } | 977 } |
942 | 978 |
943 | 979 |
944 /* | 980 /* |
945 * This function is semi-official; it is not officially exported and should | 981 * This function is semi-official; it is not officially exported and should |
949 * | 985 * |
950 * Note that it isn't completely accurate either; in particular, multi-key | 986 * Note that it isn't completely accurate either; in particular, multi-key |
951 * sequences (dead accents, compose key sequences) will not work since the | 987 * sequences (dead accents, compose key sequences) will not work since the |
952 * state has been irrevocably lost. | 988 * state has been irrevocably lost. |
953 */ | 989 */ |
954 Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers) | 990 Uint16 |
955 { | 991 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers) |
956 struct SDL_VideoDevice *this = current_video; | 992 { |
957 char keybuf[32]; | 993 SDL_VideoDevice *_this = SDL_GetVideoDevice(); |
958 int i; | 994 char keybuf[32]; |
959 KeySym xsym = 0; | 995 int i; |
960 XKeyEvent xkey; | 996 KeySym xsym = 0; |
961 Uint16 unicode; | 997 XKeyEvent xkey; |
962 | 998 Uint16 unicode; |
963 if ( !this || !SDL_Display ) { | 999 |
964 return 0; | 1000 if (!_this || !SDL_Display) { |
965 } | 1001 return 0; |
966 | 1002 } |
967 SDL_memset(&xkey, 0, sizeof(xkey)); | 1003 |
968 xkey.display = SDL_Display; | 1004 SDL_memset(&xkey, 0, sizeof(xkey)); |
969 | 1005 xkey.display = SDL_Display; |
970 xsym = keysym; /* last resort if not found */ | 1006 |
971 for (i = 0; i < 256; ++i) { | 1007 xsym = keysym; /* last resort if not found */ |
972 if ( MISC_keymap[i] == keysym ) { | 1008 for (i = 0; i < 256; ++i) { |
973 xsym = 0xFF00 | i; | 1009 if (MISC_keymap[i] == keysym) { |
974 break; | 1010 xsym = 0xFF00 | i; |
975 } else if ( ODD_keymap[i] == keysym ) { | 1011 break; |
976 xsym = 0xFE00 | i; | 1012 } else if (ODD_keymap[i] == keysym) { |
977 break; | 1013 xsym = 0xFE00 | i; |
978 } | 1014 break; |
979 } | 1015 } |
980 | 1016 } |
981 xkey.keycode = XKeysymToKeycode(xkey.display, xsym); | 1017 |
982 | 1018 xkey.keycode = XKeysymToKeycode(xkey.display, xsym); |
983 get_modifier_masks(SDL_Display); | 1019 |
984 if(modifiers & KMOD_SHIFT) | 1020 get_modifier_masks(SDL_Display); |
985 xkey.state |= ShiftMask; | 1021 if (modifiers & KMOD_SHIFT) |
986 if(modifiers & KMOD_CAPS) | 1022 xkey.state |= ShiftMask; |
987 xkey.state |= LockMask; | 1023 if (modifiers & KMOD_CAPS) |
988 if(modifiers & KMOD_CTRL) | 1024 xkey.state |= LockMask; |
989 xkey.state |= ControlMask; | 1025 if (modifiers & KMOD_CTRL) |
990 if(modifiers & KMOD_MODE) | 1026 xkey.state |= ControlMask; |
991 xkey.state |= mode_switch_mask; | 1027 if (modifiers & KMOD_MODE) |
992 if(modifiers & KMOD_LALT) | 1028 xkey.state |= mode_switch_mask; |
993 xkey.state |= alt_l_mask; | 1029 if (modifiers & KMOD_LALT) |
994 if(modifiers & KMOD_RALT) | 1030 xkey.state |= alt_l_mask; |
995 xkey.state |= alt_r_mask; | 1031 if (modifiers & KMOD_RALT) |
996 if(modifiers & KMOD_LMETA) | 1032 xkey.state |= alt_r_mask; |
997 xkey.state |= meta_l_mask; | 1033 if (modifiers & KMOD_LMETA) |
998 if(modifiers & KMOD_RMETA) | 1034 xkey.state |= meta_l_mask; |
999 xkey.state |= meta_r_mask; | 1035 if (modifiers & KMOD_RMETA) |
1000 if(modifiers & KMOD_NUM) | 1036 xkey.state |= meta_r_mask; |
1001 xkey.state |= num_mask; | 1037 if (modifiers & KMOD_NUM) |
1002 | 1038 xkey.state |= num_mask; |
1003 unicode = 0; | 1039 |
1004 if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) ) | 1040 unicode = 0; |
1005 unicode = (unsigned char)keybuf[0]; | 1041 if (XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL)) |
1006 return(unicode); | 1042 unicode = (unsigned char) keybuf[0]; |
1043 return (unicode); | |
1007 } | 1044 } |
1008 | 1045 |
1009 | 1046 |
1010 /* | 1047 /* |
1011 * Called when focus is regained, to read the keyboard state and generate | 1048 * Called when focus is regained, to read the keyboard state and generate |
1012 * synthetic keypress/release events. | 1049 * synthetic keypress/release events. |
1013 * key_vec is a bit vector of keycodes (256 bits) | 1050 * key_vec is a bit vector of keycodes (256 bits) |
1014 */ | 1051 */ |
1015 void X11_SetKeyboardState(Display *display, const char *key_vec) | 1052 void |
1016 { | 1053 X11_SetKeyboardState(Display * display, const char *key_vec) |
1017 char keys_return[32]; | 1054 { |
1018 int i; | 1055 char keys_return[32]; |
1019 Uint8 *kstate = SDL_GetKeyState(NULL); | 1056 int i; |
1020 SDLMod modstate; | 1057 Uint8 *kstate = SDL_GetKeyState(NULL); |
1021 Window junk_window; | 1058 SDLMod modstate; |
1022 int x, y; | 1059 Window junk_window; |
1023 unsigned int mask; | 1060 int x, y; |
1024 | 1061 unsigned int mask; |
1025 /* The first time the window is mapped, we initialize key state */ | 1062 |
1026 if ( ! key_vec ) { | 1063 /* The first time the window is mapped, we initialize key state */ |
1027 XQueryKeymap(display, keys_return); | 1064 if (!key_vec) { |
1028 key_vec = keys_return; | 1065 XQueryKeymap(display, keys_return); |
1029 } | 1066 key_vec = keys_return; |
1030 | 1067 } |
1031 /* Get the keyboard modifier state */ | 1068 |
1032 modstate = 0; | 1069 /* Get the keyboard modifier state */ |
1033 get_modifier_masks(display); | 1070 modstate = 0; |
1034 if ( XQueryPointer(display, DefaultRootWindow(display), | 1071 get_modifier_masks(display); |
1035 &junk_window, &junk_window, &x, &y, &x, &y, &mask) ) { | 1072 if (XQueryPointer(display, DefaultRootWindow(display), |
1036 if ( mask & LockMask ) { | 1073 &junk_window, &junk_window, &x, &y, &x, &y, &mask)) { |
1037 modstate |= KMOD_CAPS; | 1074 if (mask & LockMask) { |
1038 } | 1075 modstate |= KMOD_CAPS; |
1039 if ( mask & mode_switch_mask ) { | 1076 } |
1040 modstate |= KMOD_MODE; | 1077 if (mask & mode_switch_mask) { |
1041 } | 1078 modstate |= KMOD_MODE; |
1042 if ( mask & num_mask ) { | 1079 } |
1043 modstate |= KMOD_NUM; | 1080 if (mask & num_mask) { |
1044 } | 1081 modstate |= KMOD_NUM; |
1045 } | 1082 } |
1046 | 1083 } |
1047 /* Zero the new keyboard state and generate it */ | 1084 |
1048 SDL_memset(kstate, 0, SDLK_LAST); | 1085 /* Zero the new keyboard state and generate it */ |
1049 /* | 1086 SDL_memset(kstate, 0, SDLK_LAST); |
1050 * An obvious optimisation is to check entire longwords at a time in | 1087 /* |
1051 * both loops, but we can't be sure the arrays are aligned so it's not | 1088 * An obvious optimisation is to check entire longwords at a time in |
1052 * worth the extra complexity | 1089 * both loops, but we can't be sure the arrays are aligned so it's not |
1053 */ | 1090 * worth the extra complexity |
1054 for ( i = 0; i < 32; i++ ) { | 1091 */ |
1055 int j; | 1092 for (i = 0; i < 32; i++) { |
1056 if ( !key_vec[i] ) | 1093 int j; |
1057 continue; | 1094 if (!key_vec[i]) |
1058 for ( j = 0; j < 8; j++ ) { | 1095 continue; |
1059 if ( key_vec[i] & (1 << j) ) { | 1096 for (j = 0; j < 8; j++) { |
1060 SDLKey key; | 1097 if (key_vec[i] & (1 << j)) { |
1061 KeyCode kc = (i << 3 | j); | 1098 SDLKey key; |
1062 key = X11_TranslateKeycode(display, kc); | 1099 KeyCode kc = (i << 3 | j); |
1063 if ( key == SDLK_UNKNOWN ) { | 1100 key = X11_TranslateKeycode(display, kc); |
1064 continue; | 1101 if (key == SDLK_UNKNOWN) { |
1065 } | 1102 continue; |
1066 kstate[key] = SDL_PRESSED; | 1103 } |
1067 switch (key) { | 1104 kstate[key] = SDL_PRESSED; |
1068 case SDLK_LSHIFT: | 1105 switch (key) { |
1069 modstate |= KMOD_LSHIFT; | 1106 case SDLK_LSHIFT: |
1070 break; | 1107 modstate |= KMOD_LSHIFT; |
1071 case SDLK_RSHIFT: | 1108 break; |
1072 modstate |= KMOD_RSHIFT; | 1109 case SDLK_RSHIFT: |
1073 break; | 1110 modstate |= KMOD_RSHIFT; |
1074 case SDLK_LCTRL: | 1111 break; |
1075 modstate |= KMOD_LCTRL; | 1112 case SDLK_LCTRL: |
1076 break; | 1113 modstate |= KMOD_LCTRL; |
1077 case SDLK_RCTRL: | 1114 break; |
1078 modstate |= KMOD_RCTRL; | 1115 case SDLK_RCTRL: |
1079 break; | 1116 modstate |= KMOD_RCTRL; |
1080 case SDLK_LALT: | 1117 break; |
1081 modstate |= KMOD_LALT; | 1118 case SDLK_LALT: |
1082 break; | 1119 modstate |= KMOD_LALT; |
1083 case SDLK_RALT: | 1120 break; |
1084 modstate |= KMOD_RALT; | 1121 case SDLK_RALT: |
1085 break; | 1122 modstate |= KMOD_RALT; |
1086 case SDLK_LMETA: | 1123 break; |
1087 modstate |= KMOD_LMETA; | 1124 case SDLK_LMETA: |
1088 break; | 1125 modstate |= KMOD_LMETA; |
1089 case SDLK_RMETA: | 1126 break; |
1090 modstate |= KMOD_RMETA; | 1127 case SDLK_RMETA: |
1091 break; | 1128 modstate |= KMOD_RMETA; |
1092 default: | 1129 break; |
1093 break; | 1130 default: |
1094 } | 1131 break; |
1095 } | 1132 } |
1096 } | 1133 } |
1097 } | 1134 } |
1098 | 1135 } |
1099 /* Hack - set toggle key state */ | 1136 |
1100 if ( modstate & KMOD_CAPS ) { | 1137 /* Hack - set toggle key state */ |
1101 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; | 1138 if (modstate & KMOD_CAPS) { |
1102 } else { | 1139 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
1103 kstate[SDLK_CAPSLOCK] = SDL_RELEASED; | 1140 } else { |
1104 } | 1141 kstate[SDLK_CAPSLOCK] = SDL_RELEASED; |
1105 if ( modstate & KMOD_NUM ) { | 1142 } |
1106 kstate[SDLK_NUMLOCK] = SDL_PRESSED; | 1143 if (modstate & KMOD_NUM) { |
1107 } else { | 1144 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
1108 kstate[SDLK_NUMLOCK] = SDL_RELEASED; | 1145 } else { |
1109 } | 1146 kstate[SDLK_NUMLOCK] = SDL_RELEASED; |
1110 | 1147 } |
1111 /* Set the final modifier state */ | 1148 |
1112 SDL_SetModState(modstate); | 1149 /* Set the final modifier state */ |
1113 } | 1150 SDL_SetModState(modstate); |
1114 | 1151 } |
1115 void X11_InitOSKeymap(_THIS) | 1152 |
1116 { | 1153 void |
1117 X11_InitKeymap(); | 1154 X11_InitOSKeymap(_THIS) |
1118 } | 1155 { |
1119 | 1156 X11_InitKeymap(); |
1120 void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms) | 1157 } |
1121 { | 1158 |
1122 int timeout, interval, prefer_blank, allow_exp; | 1159 void |
1123 XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); | 1160 X11_SaveScreenSaver(Display * display, int *saved_timeout, BOOL * dpms) |
1124 *saved_timeout = timeout; | 1161 { |
1162 int timeout, interval, prefer_blank, allow_exp; | |
1163 XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); | |
1164 *saved_timeout = timeout; | |
1125 | 1165 |
1126 #if SDL_VIDEO_DRIVER_X11_DPMS | 1166 #if SDL_VIDEO_DRIVER_X11_DPMS |
1127 if ( SDL_X11_HAVE_DPMS ) { | 1167 if (SDL_X11_HAVE_DPMS) { |
1128 int dummy; | 1168 int dummy; |
1129 if ( DPMSQueryExtension(display, &dummy, &dummy) ) { | 1169 if (DPMSQueryExtension(display, &dummy, &dummy)) { |
1130 CARD16 state; | 1170 CARD16 state; |
1131 DPMSInfo(display, &state, dpms); | 1171 DPMSInfo(display, &state, dpms); |
1132 } | 1172 } |
1133 } | 1173 } |
1134 #else | 1174 #else |
1135 *dpms = 0; | 1175 *dpms = 0; |
1136 #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ | 1176 #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ |
1137 } | 1177 } |
1138 | 1178 |
1139 void X11_DisableScreenSaver(Display *display) | 1179 void |
1140 { | 1180 X11_DisableScreenSaver(Display * display) |
1141 int timeout, interval, prefer_blank, allow_exp; | 1181 { |
1142 XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); | 1182 int timeout, interval, prefer_blank, allow_exp; |
1143 timeout = 0; | 1183 XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); |
1144 XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); | 1184 timeout = 0; |
1185 XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); | |
1145 | 1186 |
1146 #if SDL_VIDEO_DRIVER_X11_DPMS | 1187 #if SDL_VIDEO_DRIVER_X11_DPMS |
1147 if ( SDL_X11_HAVE_DPMS ) { | 1188 if (SDL_X11_HAVE_DPMS) { |
1148 int dummy; | 1189 int dummy; |
1149 if ( DPMSQueryExtension(display, &dummy, &dummy) ) { | 1190 if (DPMSQueryExtension(display, &dummy, &dummy)) { |
1150 DPMSDisable(display); | 1191 DPMSDisable(display); |
1151 } | 1192 } |
1152 } | 1193 } |
1153 #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ | 1194 #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ |
1154 } | 1195 } |
1155 | 1196 |
1156 void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms) | 1197 void |
1157 { | 1198 X11_RestoreScreenSaver(Display * display, int saved_timeout, BOOL dpms) |
1158 int timeout, interval, prefer_blank, allow_exp; | 1199 { |
1159 XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); | 1200 int timeout, interval, prefer_blank, allow_exp; |
1160 timeout = saved_timeout; | 1201 XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); |
1161 XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); | 1202 timeout = saved_timeout; |
1203 XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); | |
1162 | 1204 |
1163 #if SDL_VIDEO_DRIVER_X11_DPMS | 1205 #if SDL_VIDEO_DRIVER_X11_DPMS |
1164 if ( SDL_X11_HAVE_DPMS ) { | 1206 if (SDL_X11_HAVE_DPMS) { |
1165 int dummy; | 1207 int dummy; |
1166 if ( DPMSQueryExtension(display, &dummy, &dummy) ) { | 1208 if (DPMSQueryExtension(display, &dummy, &dummy)) { |
1167 if ( dpms ) { | 1209 if (dpms) { |
1168 DPMSEnable(display); | 1210 DPMSEnable(display); |
1169 } | 1211 } |
1170 } | 1212 } |
1171 } | 1213 } |
1172 #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ | 1214 #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ |
1173 } | 1215 } |
1216 | |
1217 /* vi: set ts=4 sw=4 expandtab: */ |