Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11modes.c @ 216:e2a10730ae94
Fail if setting a video mode when requesting GL and can't get it.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 25 Oct 2001 06:22:38 +0000 |
parents | a1c973c35fef |
children | 24878c14b391 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@devolution.com | |
21 */ | |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* Utilities for getting and setting the X display mode */ | |
29 | |
30 #include <stdlib.h> | |
31 #include <string.h> | |
32 | |
33 #include "SDL_timer.h" | |
34 #include "SDL_error.h" | |
35 #include "SDL_events.h" | |
36 #include "SDL_events_c.h" | |
37 #include "SDL_x11video.h" | |
38 #include "SDL_x11wm_c.h" | |
39 #include "SDL_x11modes_c.h" | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
40 #include "SDL_x11image_c.h" |
0 | 41 |
42 | |
43 #ifdef XFREE86_VM | |
44 Bool XVidMode(GetModeInfo, (Display *dpy, int scr, XF86VidModeModeInfo *info)) | |
45 { | |
46 XF86VidModeModeLine *l = (XF86VidModeModeLine*)((char*)info + sizeof info->dotclock); | |
47 return XVidMode(GetModeLine, (dpy, scr, &info->dotclock, l)); | |
48 } | |
49 #endif /* XFREE86_VM */ | |
50 | |
51 #ifdef XFREE86_VM | |
52 static void save_mode(_THIS) | |
53 { | |
54 memset(&saved_mode, 0, sizeof(saved_mode)); | |
55 XVidMode(GetModeInfo, (SDL_Display,SDL_Screen,&saved_mode)); | |
56 XVidMode(GetViewPort, (SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y)); | |
57 } | |
58 #endif | |
59 | |
60 #ifdef XFREE86_VM | |
61 static void restore_mode(_THIS) | |
62 { | |
63 XF86VidModeModeLine mode; | |
64 int unused; | |
65 | |
66 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) { | |
67 if ( (saved_mode.hdisplay != mode.hdisplay) || | |
68 (saved_mode.vdisplay != mode.vdisplay) ) { | |
69 XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, &saved_mode)); | |
70 } | |
71 } | |
72 if ( (saved_view.x != 0) || (saved_view.y != 0) ) { | |
73 XVidMode(SetViewPort, (SDL_Display, SDL_Screen, saved_view.x, saved_view.y)); | |
74 } | |
75 } | |
76 #endif | |
77 | |
78 #ifdef XFREE86_VM | |
79 static int cmpmodes(const void *va, const void *vb) | |
80 { | |
91
e85e03f195b4
From: "Markus F.X.J. Oberhumer"
Sam Lantinga <slouken@lokigames.com>
parents:
90
diff
changeset
|
81 const XF86VidModeModeInfo *a = *(const XF86VidModeModeInfo**)va; |
e85e03f195b4
From: "Markus F.X.J. Oberhumer"
Sam Lantinga <slouken@lokigames.com>
parents:
90
diff
changeset
|
82 const XF86VidModeModeInfo *b = *(const XF86VidModeModeInfo**)vb; |
0 | 83 if(a->hdisplay > b->hdisplay) |
84 return -1; | |
85 return b->vdisplay - a->vdisplay; | |
86 } | |
87 #endif | |
88 | |
89 static void set_best_resolution(_THIS, int width, int height) | |
90 { | |
91 #ifdef XFREE86_VM | |
92 if ( use_vidmode ) { | |
93 XF86VidModeModeLine mode; | |
94 XF86VidModeModeInfo **modes; | |
95 int i; | |
96 int nmodes; | |
97 | |
98 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &i, &mode)) && | |
99 XVidMode(GetAllModeLines, (SDL_Display,SDL_Screen,&nmodes,&modes))){ | |
100 qsort(modes, nmodes, sizeof *modes, cmpmodes); | |
101 #ifdef XFREE86_DEBUG | |
102 printf("Available modes:\n"); | |
103 for ( i = 0; i < nmodes; ++i ) { | |
104 printf("Mode %d: %dx%d\n", i, modes[i]->hdisplay, modes[i]->vdisplay); | |
105 } | |
106 #endif | |
107 for ( i = nmodes-1; i > 0 ; --i ) { | |
108 if ( (modes[i]->hdisplay >= width) && | |
109 (modes[i]->vdisplay >= height) ) | |
110 break; | |
111 } | |
112 if ( (modes[i]->hdisplay != mode.hdisplay) || | |
113 (modes[i]->vdisplay != mode.vdisplay) ) { | |
114 XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, modes[i])); | |
115 } | |
116 XFree(modes); | |
117 } | |
118 } | |
119 #endif /* XFREE86_VM */ | |
120 } | |
121 | |
122 static void get_real_resolution(_THIS, int* w, int* h) | |
123 { | |
124 #ifdef XFREE86_VM | |
125 if ( use_vidmode ) { | |
126 XF86VidModeModeLine mode; | |
127 int unused; | |
128 | |
129 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) { | |
130 *w = mode.hdisplay; | |
131 *h = mode.vdisplay; | |
132 return; | |
133 } | |
134 } | |
135 #endif | |
136 *w = DisplayWidth(SDL_Display, SDL_Screen); | |
137 *h = DisplayHeight(SDL_Display, SDL_Screen); | |
138 } | |
139 | |
140 /* Called after mapping a window - waits until the window is mapped */ | |
141 void X11_WaitMapped(_THIS, Window win) | |
142 { | |
143 XEvent event; | |
144 do { | |
145 XMaskEvent(SDL_Display, StructureNotifyMask, &event); | |
146 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); | |
147 } | |
148 | |
149 /* Called after unmapping a window - waits until the window is unmapped */ | |
150 void X11_WaitUnmapped(_THIS, Window win) | |
151 { | |
152 XEvent event; | |
153 do { | |
154 XMaskEvent(SDL_Display, StructureNotifyMask, &event); | |
155 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); | |
156 } | |
157 | |
158 static void move_cursor_to(_THIS, int x, int y) | |
159 { | |
160 XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); | |
161 } | |
162 | |
163 static int add_visual(_THIS, int depth, int class) | |
164 { | |
165 XVisualInfo vi; | |
166 if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) { | |
167 int n = this->hidden->nvisuals; | |
168 this->hidden->visuals[n].depth = vi.depth; | |
169 this->hidden->visuals[n].visual = vi.visual; | |
170 this->hidden->nvisuals++; | |
171 } | |
172 return(this->hidden->nvisuals); | |
173 } | |
174 static int add_visual_byid(_THIS, const char *visual_id) | |
175 { | |
176 XVisualInfo *vi, template; | |
177 int nvis; | |
178 | |
179 if ( visual_id ) { | |
180 memset(&template, 0, (sizeof template)); | |
181 template.visualid = strtol(visual_id, NULL, 0); | |
182 vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); | |
183 if ( vi ) { | |
184 int n = this->hidden->nvisuals; | |
185 this->hidden->visuals[n].depth = vi->depth; | |
186 this->hidden->visuals[n].visual = vi->visual; | |
187 this->hidden->nvisuals++; | |
188 XFree(vi); | |
189 } | |
190 } | |
191 return(this->hidden->nvisuals); | |
192 } | |
193 | |
194 /* Global for the error handler */ | |
195 int vm_event, vm_error = -1; | |
196 | |
197 int X11_GetVideoModes(_THIS) | |
198 { | |
199 #ifdef XFREE86_VM | |
200 int buggy_X11; | |
201 int vm_major, vm_minor; | |
202 int nmodes; | |
203 XF86VidModeModeInfo **modes; | |
204 #endif | |
205 int i; | |
206 | |
207 vm_error = -1; | |
208 use_vidmode = 0; | |
209 #ifdef XFREE86_VM | |
210 /* Metro-X 4.3.0 and earlier has a broken implementation of | |
211 XF86VidModeGetAllModeLines() - it hangs the client. | |
212 */ | |
213 buggy_X11 = 0; | |
214 if ( strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { | |
215 FILE *metro_fp; | |
216 | |
217 metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); | |
218 if ( metro_fp != NULL ) { | |
219 int major, minor, patch, version; | |
220 major = 0; minor = 0; patch = 0; | |
221 fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch); | |
222 version = major*100+minor*10+patch; | |
223 if ( version < 431 ) { | |
224 buggy_X11 = 1; | |
225 } | |
226 fclose(metro_fp); | |
227 } | |
228 } | |
229 #if defined(__alpha__) || defined(__powerpc__) | |
230 /* The alpha and PPC XFree86 servers are also buggy */ | |
231 buggy_X11 = 1; | |
232 #endif | |
233 /* Enumerate the available fullscreen modes */ | |
234 if ( ! buggy_X11 ) { | |
235 if ( XVidMode(QueryExtension, (SDL_Display, &vm_event, &vm_error)) && | |
236 XVidMode(QueryVersion, (SDL_Display, &vm_major, &vm_minor)) ) { | |
237 #ifdef BROKEN_XFREE86_4001 | |
238 #ifdef X_XF86VidModeGetDotClocks /* Compiled under XFree86 4.0 */ | |
239 /* Earlier X servers hang when doing vidmode */ | |
240 if ( vm_major < 2 ) { | |
241 #ifdef DEBUG_XF86 | |
242 printf("Compiled under XFree86 4.0, server is XFree86 3.X\n"); | |
243 #endif | |
244 buggy_X11 = 1; | |
245 } | |
246 #else | |
247 /* XFree86 3.X code works with XFree86 4.0 servers */; | |
248 #endif /* XFree86 4.0 */ | |
249 #endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */ | |
250 } else { | |
251 buggy_X11 = 1; | |
252 } | |
253 } | |
254 if ( ! buggy_X11 && | |
255 XVidMode(GetAllModeLines, (SDL_Display, SDL_Screen,&nmodes,&modes)) ) { | |
256 | |
257 qsort(modes, nmodes, sizeof *modes, cmpmodes); | |
258 SDL_modelist = (SDL_Rect **)malloc((nmodes+1)*sizeof(SDL_Rect *)); | |
259 if ( SDL_modelist ) { | |
260 for ( i=0; i<nmodes; ++i ) { | |
261 SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); | |
262 if ( SDL_modelist[i] == NULL ) { | |
263 break; | |
264 } | |
265 SDL_modelist[i]->x = 0; | |
266 SDL_modelist[i]->y = 0; | |
267 SDL_modelist[i]->w = modes[i]->hdisplay; | |
268 SDL_modelist[i]->h = modes[i]->vdisplay; | |
269 } | |
270 SDL_modelist[i] = NULL; | |
271 } | |
272 XFree(modes); | |
273 | |
100
a1c973c35fef
Fixed using the video mode extension on older servers
Sam Lantinga <slouken@lokigames.com>
parents:
98
diff
changeset
|
274 use_vidmode = vm_major * 100 + vm_minor; |
0 | 275 save_mode(this); |
276 } | |
277 #endif /* XFREE86_VM */ | |
278 | |
279 { | |
280 static int depth_list[] = { 32, 24, 16, 15, 8 }; | |
281 int j, np; | |
282 int use_directcolor = 1; | |
283 XPixmapFormatValues *pf; | |
284 | |
285 /* Search for the visuals in deepest-first order, so that the first | |
286 will be the richest one */ | |
287 if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { | |
288 use_directcolor = 0; | |
289 } | |
290 this->hidden->nvisuals = 0; | |
291 if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) { | |
292 for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) { | |
293 if ( depth_list[i] > 8 ) { | |
294 if ( use_directcolor ) { | |
295 add_visual(this, depth_list[i], DirectColor); | |
296 } | |
297 add_visual(this, depth_list[i], TrueColor); | |
298 } else { | |
299 add_visual(this, depth_list[i], PseudoColor); | |
300 add_visual(this, depth_list[i], StaticColor); | |
301 } | |
302 } | |
303 } | |
304 if ( this->hidden->nvisuals == 0 ) { | |
305 SDL_SetError("Found no sufficiently capable X11 visuals"); | |
306 return -1; | |
307 } | |
308 | |
309 /* look up the pixel quantum for each depth */ | |
310 pf = XListPixmapFormats(SDL_Display, &np); | |
311 for(i = 0; i < this->hidden->nvisuals; i++) { | |
312 int d = this->hidden->visuals[i].depth; | |
313 for(j = 0; j < np; j++) | |
314 if(pf[j].depth == d) | |
315 break; | |
316 this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; | |
317 } | |
318 | |
319 XFree(pf); | |
320 } | |
321 | |
322 if ( SDL_modelist == NULL ) { | |
323 SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); | |
324 i = 0; | |
325 if ( SDL_modelist ) { | |
326 SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); | |
327 if ( SDL_modelist[i] ) { | |
328 SDL_modelist[i]->x = 0; | |
329 SDL_modelist[i]->y = 0; | |
330 SDL_modelist[i]->w = DisplayWidth(SDL_Display, SDL_Screen); | |
331 SDL_modelist[i]->h = DisplayHeight(SDL_Display, SDL_Screen); | |
332 ++i; | |
333 } | |
334 SDL_modelist[i] = NULL; | |
335 } | |
336 } | |
337 | |
338 #ifdef DEBUG_XF86 | |
339 if ( use_vidmode ) { | |
340 fprintf(stderr, "XFree86 VidMode is enabled\n"); | |
341 } | |
342 if ( SDL_modelist ) { | |
343 fprintf(stderr, "X11 video mode list:\n"); | |
344 for ( i=0; SDL_modelist[i]; ++i ) { | |
345 fprintf(stderr, "\t%dx%d\n", | |
346 SDL_modelist[i]->w, SDL_modelist[i]->h); | |
347 } | |
348 } | |
349 #endif /* DEBUG_XF86 */ | |
350 return 0; | |
351 } | |
352 | |
353 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) | |
354 { | |
355 int i; | |
356 for(i = 0; i < this->hidden->nvisuals; i++) | |
357 if(this->hidden->visuals[i].bpp == format->BitsPerPixel) | |
358 return 1; | |
359 return 0; | |
360 } | |
361 | |
362 SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
363 { | |
364 if ( X11_SupportedVisual(this, format) ) { | |
365 if ( flags & SDL_FULLSCREEN ) { | |
366 return(SDL_modelist); | |
367 } else { | |
368 return((SDL_Rect **)-1); | |
369 } | |
370 } else { | |
371 return((SDL_Rect **)0); | |
372 } | |
373 } | |
374 | |
375 void X11_FreeVideoModes(_THIS) | |
376 { | |
377 int i; | |
378 | |
379 if ( SDL_modelist ) { | |
380 for ( i=0; SDL_modelist[i]; ++i ) { | |
381 free(SDL_modelist[i]); | |
382 } | |
383 free(SDL_modelist); | |
384 SDL_modelist = NULL; | |
385 } | |
386 } | |
387 | |
388 int X11_ResizeFullScreen(_THIS) | |
389 { | |
390 int x, y; | |
391 int real_w, real_h; | |
392 | |
393 if ( currently_fullscreen ) { | |
394 /* Switch resolution and cover it with the FSwindow */ | |
395 move_cursor_to(this, 0, 0); | |
396 set_best_resolution(this, current_w, current_h); | |
397 move_cursor_to(this, 0, 0); | |
398 get_real_resolution(this, &real_w, &real_h); | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
399 XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h); |
0 | 400 move_cursor_to(this, real_w/2, real_h/2); |
401 | |
402 /* Center and reparent the drawing window */ | |
403 x = (real_w - current_w)/2; | |
404 y = (real_h - current_h)/2; | |
405 XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); | |
406 /* FIXME: move the mouse to the old relative location */ | |
407 XSync(SDL_Display, True); /* Flush spurious mode change events */ | |
408 } | |
409 return(1); | |
410 } | |
411 | |
412 void X11_QueueEnterFullScreen(_THIS) | |
413 { | |
414 switch_waiting = 0x01 | SDL_FULLSCREEN; | |
415 switch_time = SDL_GetTicks() + 1500; | |
416 #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ | |
417 XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); | |
418 #endif | |
419 } | |
420 | |
421 int X11_EnterFullScreen(_THIS) | |
422 { | |
423 int okay; | |
424 #if 0 | |
425 Window tmpwin, *windows; | |
426 int i, nwindows; | |
427 #endif | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
428 int real_w, real_h; |
0 | 429 |
430 okay = 1; | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
431 if ( currently_fullscreen ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
432 return(okay); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
433 } |
0 | 434 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
435 /* Ungrab the input so that we can move the mouse around */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
436 X11_GrabInputNoLock(this, SDL_GRAB_OFF); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
437 |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
438 /* Map the fullscreen window to blank the screen */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
439 get_real_resolution(this, &real_w, &real_h); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
440 XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
441 XMapRaised(SDL_Display, FSwindow); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
442 X11_WaitMapped(this, FSwindow); |
0 | 443 |
444 #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
445 /* Make sure we got to the top of the window stack */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
446 if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
447 &windows, &nwindows) && windows ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
448 /* If not, try to put us there - if fail... oh well */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
449 if ( windows[nwindows-1] != FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
450 tmpwin = windows[nwindows-1]; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
451 for ( i=0; i<nwindows; ++i ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
452 if ( windows[i] == FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
453 memcpy(&windows[i], &windows[i+1], |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
454 (nwindows-i-1)*sizeof(windows[i])); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
455 break; |
0 | 456 } |
457 } | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
458 windows[nwindows-1] = FSwindow; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
459 XRestackWindows(SDL_Display, windows, nwindows); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
460 XSync(SDL_Display, False); |
0 | 461 } |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
462 XFree(windows); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
463 } |
0 | 464 #else |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
465 XRaiseWindow(SDL_Display, FSwindow); |
0 | 466 #endif |
467 | |
468 #ifdef XFREE86_VM | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
469 /* Save the current video mode */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
470 if ( use_vidmode ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
471 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True)); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
472 } |
0 | 473 #endif |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
474 currently_fullscreen = 1; |
0 | 475 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
476 /* Set the new resolution */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
477 okay = X11_ResizeFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
478 if ( ! okay ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
479 X11_LeaveFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
480 } |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
481 /* Set the colormap */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
482 if ( SDL_XColorMap ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
483 XInstallColormap(SDL_Display, SDL_XColorMap); |
0 | 484 } |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
485 if ( okay ) |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
486 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
487 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
488 /* We may need to refresh the screen at this point (no backing store) |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
489 We also don't get an event, which is why we explicitly refresh. */ |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
490 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
491 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
492 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
493 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
494 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
495 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
496 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
497 |
0 | 498 return(okay); |
499 } | |
500 | |
501 int X11_LeaveFullScreen(_THIS) | |
502 { | |
503 if ( currently_fullscreen ) { | |
504 XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); | |
505 #ifdef XFREE86_VM | |
506 if ( use_vidmode ) { | |
507 restore_mode(this); | |
508 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False)); | |
509 } | |
510 #endif | |
511 XUnmapWindow(SDL_Display, FSwindow); | |
512 X11_WaitUnmapped(this, FSwindow); | |
513 XSync(SDL_Display, True); /* Flush spurious mode change events */ | |
514 currently_fullscreen = 0; | |
515 } | |
516 /* If we get popped out of fullscreen mode for some reason, input_grab | |
517 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only | |
518 temporary. In this case, release the grab unless the input has been | |
519 explicitly grabbed. | |
520 */ | |
521 X11_GrabInputNoLock(this, this->input_grab & ~SDL_GRAB_FULLSCREEN); | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
522 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
523 /* We may need to refresh the screen at this point (no backing store) |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
524 We also don't get an event, which is why we explicitly refresh. */ |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
525 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
526 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
527 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
528 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
529 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
530 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
531 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
532 |
0 | 533 return(0); |
534 } |