Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11modes.c @ 232:678e3ed01019
Don't generate a spurious error on SDL_InitVideo()
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 06 Nov 2001 00:15:04 +0000 |
parents | 275a934573a7 |
children | 4bcb29d3769c |
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 |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
42 #ifdef HAVE_XINERAMA |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
43 #include <X11/extensions/Xinerama.h> |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
44 #endif |
0 | 45 |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
46 #define MAX(a, b) (a > b ? a : b) |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
47 |
0 | 48 #ifdef XFREE86_VM |
49 Bool XVidMode(GetModeInfo, (Display *dpy, int scr, XF86VidModeModeInfo *info)) | |
50 { | |
51 XF86VidModeModeLine *l = (XF86VidModeModeLine*)((char*)info + sizeof info->dotclock); | |
52 return XVidMode(GetModeLine, (dpy, scr, &info->dotclock, l)); | |
53 } | |
54 #endif /* XFREE86_VM */ | |
55 | |
56 #ifdef XFREE86_VM | |
57 static void save_mode(_THIS) | |
58 { | |
59 memset(&saved_mode, 0, sizeof(saved_mode)); | |
60 XVidMode(GetModeInfo, (SDL_Display,SDL_Screen,&saved_mode)); | |
61 XVidMode(GetViewPort, (SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y)); | |
62 } | |
63 #endif | |
64 | |
65 #ifdef XFREE86_VM | |
66 static void restore_mode(_THIS) | |
67 { | |
68 XF86VidModeModeLine mode; | |
69 int unused; | |
70 | |
71 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) { | |
72 if ( (saved_mode.hdisplay != mode.hdisplay) || | |
73 (saved_mode.vdisplay != mode.vdisplay) ) { | |
74 XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, &saved_mode)); | |
75 } | |
76 } | |
77 if ( (saved_view.x != 0) || (saved_view.y != 0) ) { | |
78 XVidMode(SetViewPort, (SDL_Display, SDL_Screen, saved_view.x, saved_view.y)); | |
79 } | |
80 } | |
81 #endif | |
82 | |
83 #ifdef XFREE86_VM | |
84 static int cmpmodes(const void *va, const void *vb) | |
85 { | |
91
e85e03f195b4
From: "Markus F.X.J. Oberhumer"
Sam Lantinga <slouken@lokigames.com>
parents:
90
diff
changeset
|
86 const XF86VidModeModeInfo *a = *(const XF86VidModeModeInfo**)va; |
e85e03f195b4
From: "Markus F.X.J. Oberhumer"
Sam Lantinga <slouken@lokigames.com>
parents:
90
diff
changeset
|
87 const XF86VidModeModeInfo *b = *(const XF86VidModeModeInfo**)vb; |
0 | 88 if(a->hdisplay > b->hdisplay) |
89 return -1; | |
90 return b->vdisplay - a->vdisplay; | |
91 } | |
92 #endif | |
93 | |
94 static void set_best_resolution(_THIS, int width, int height) | |
95 { | |
96 #ifdef XFREE86_VM | |
97 if ( use_vidmode ) { | |
98 XF86VidModeModeLine mode; | |
99 XF86VidModeModeInfo **modes; | |
100 int i; | |
101 int nmodes; | |
102 | |
103 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &i, &mode)) && | |
104 XVidMode(GetAllModeLines, (SDL_Display,SDL_Screen,&nmodes,&modes))){ | |
105 qsort(modes, nmodes, sizeof *modes, cmpmodes); | |
106 #ifdef XFREE86_DEBUG | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
107 printf("Available modes:\n"); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
108 for ( i = 0; i < nmodes; ++i ) { |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
109 printf("Mode %d: %dx%d\n", i, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
110 modes[i]->hdisplay, modes[i]->vdisplay); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
111 } |
0 | 112 #endif |
113 for ( i = nmodes-1; i > 0 ; --i ) { | |
114 if ( (modes[i]->hdisplay >= width) && | |
115 (modes[i]->vdisplay >= height) ) | |
116 break; | |
117 } | |
118 if ( (modes[i]->hdisplay != mode.hdisplay) || | |
119 (modes[i]->vdisplay != mode.vdisplay) ) { | |
120 XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, modes[i])); | |
121 } | |
122 XFree(modes); | |
123 } | |
124 } | |
125 #endif /* XFREE86_VM */ | |
126 } | |
127 | |
128 static void get_real_resolution(_THIS, int* w, int* h) | |
129 { | |
130 #ifdef XFREE86_VM | |
131 if ( use_vidmode ) { | |
132 XF86VidModeModeLine mode; | |
133 int unused; | |
134 | |
135 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) { | |
136 *w = mode.hdisplay; | |
137 *h = mode.vdisplay; | |
138 return; | |
139 } | |
140 } | |
141 #endif | |
142 *w = DisplayWidth(SDL_Display, SDL_Screen); | |
143 *h = DisplayHeight(SDL_Display, SDL_Screen); | |
144 } | |
145 | |
146 /* Called after mapping a window - waits until the window is mapped */ | |
147 void X11_WaitMapped(_THIS, Window win) | |
148 { | |
149 XEvent event; | |
150 do { | |
151 XMaskEvent(SDL_Display, StructureNotifyMask, &event); | |
152 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); | |
153 } | |
154 | |
155 /* Called after unmapping a window - waits until the window is unmapped */ | |
156 void X11_WaitUnmapped(_THIS, Window win) | |
157 { | |
158 XEvent event; | |
159 do { | |
160 XMaskEvent(SDL_Display, StructureNotifyMask, &event); | |
161 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); | |
162 } | |
163 | |
164 static void move_cursor_to(_THIS, int x, int y) | |
165 { | |
166 XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); | |
167 } | |
168 | |
169 static int add_visual(_THIS, int depth, int class) | |
170 { | |
171 XVisualInfo vi; | |
172 if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) { | |
173 int n = this->hidden->nvisuals; | |
174 this->hidden->visuals[n].depth = vi.depth; | |
175 this->hidden->visuals[n].visual = vi.visual; | |
176 this->hidden->nvisuals++; | |
177 } | |
178 return(this->hidden->nvisuals); | |
179 } | |
180 static int add_visual_byid(_THIS, const char *visual_id) | |
181 { | |
182 XVisualInfo *vi, template; | |
183 int nvis; | |
184 | |
185 if ( visual_id ) { | |
186 memset(&template, 0, (sizeof template)); | |
187 template.visualid = strtol(visual_id, NULL, 0); | |
188 vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); | |
189 if ( vi ) { | |
190 int n = this->hidden->nvisuals; | |
191 this->hidden->visuals[n].depth = vi->depth; | |
192 this->hidden->visuals[n].visual = vi->visual; | |
193 this->hidden->nvisuals++; | |
194 XFree(vi); | |
195 } | |
196 } | |
197 return(this->hidden->nvisuals); | |
198 } | |
199 | |
200 /* Global for the error handler */ | |
201 int vm_event, vm_error = -1; | |
202 | |
203 int X11_GetVideoModes(_THIS) | |
204 { | |
205 #ifdef XFREE86_VM | |
206 int buggy_X11; | |
207 int vm_major, vm_minor; | |
208 int nmodes; | |
209 XF86VidModeModeInfo **modes; | |
210 #endif | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
211 int i, n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
212 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
213 int screen_h; |
0 | 214 |
215 vm_error = -1; | |
216 use_vidmode = 0; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
217 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
218 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
219 |
0 | 220 #ifdef XFREE86_VM |
221 /* Metro-X 4.3.0 and earlier has a broken implementation of | |
222 XF86VidModeGetAllModeLines() - it hangs the client. | |
223 */ | |
224 buggy_X11 = 0; | |
225 if ( strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { | |
226 FILE *metro_fp; | |
227 | |
228 metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); | |
229 if ( metro_fp != NULL ) { | |
230 int major, minor, patch, version; | |
231 major = 0; minor = 0; patch = 0; | |
232 fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch); | |
233 version = major*100+minor*10+patch; | |
234 if ( version < 431 ) { | |
235 buggy_X11 = 1; | |
236 } | |
237 fclose(metro_fp); | |
238 } | |
239 } | |
240 #if defined(__alpha__) || defined(__powerpc__) | |
241 /* The alpha and PPC XFree86 servers are also buggy */ | |
242 buggy_X11 = 1; | |
243 #endif | |
244 /* Enumerate the available fullscreen modes */ | |
245 if ( ! buggy_X11 ) { | |
246 if ( XVidMode(QueryExtension, (SDL_Display, &vm_event, &vm_error)) && | |
247 XVidMode(QueryVersion, (SDL_Display, &vm_major, &vm_minor)) ) { | |
248 #ifdef BROKEN_XFREE86_4001 | |
249 #ifdef X_XF86VidModeGetDotClocks /* Compiled under XFree86 4.0 */ | |
250 /* Earlier X servers hang when doing vidmode */ | |
251 if ( vm_major < 2 ) { | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
252 #ifdef XFREE86_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
253 printf("Compiled under XFree86 4.0, server is XFree86 3.X\n"); |
0 | 254 #endif |
255 buggy_X11 = 1; | |
256 } | |
257 #else | |
258 /* XFree86 3.X code works with XFree86 4.0 servers */; | |
259 #endif /* XFree86 4.0 */ | |
260 #endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */ | |
261 } else { | |
262 buggy_X11 = 1; | |
263 } | |
264 } | |
265 if ( ! buggy_X11 && | |
266 XVidMode(GetAllModeLines, (SDL_Display, SDL_Screen,&nmodes,&modes)) ) { | |
267 | |
268 qsort(modes, nmodes, sizeof *modes, cmpmodes); | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
269 SDL_modelist = (SDL_Rect **)malloc((nmodes+2)*sizeof(SDL_Rect *)); |
0 | 270 if ( SDL_modelist ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
271 n = 0; |
0 | 272 for ( i=0; i<nmodes; ++i ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
273 int w, h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
274 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
275 /* Check to see if we should add the screen size (Xinerama) */ |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
276 w = modes[i]->hdisplay; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
277 h = modes[i]->vdisplay; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
278 if ( (screen_w * screen_h) >= (w * h) ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
279 if ( (screen_w != w) || (screen_h != h) ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
280 SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
281 if ( SDL_modelist[n] ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
282 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
283 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
284 SDL_modelist[n]->w = screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
285 SDL_modelist[n]->h = screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
286 ++n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
287 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
288 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
289 screen_w = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
290 screen_h = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
291 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
292 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
293 /* Add the size from the video mode list */ |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
294 SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
295 if ( SDL_modelist[n] == NULL ) { |
0 | 296 break; |
297 } | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
298 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
299 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
300 SDL_modelist[n]->w = w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
301 SDL_modelist[n]->h = h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
302 ++n; |
0 | 303 } |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
304 SDL_modelist[n] = NULL; |
0 | 305 } |
306 XFree(modes); | |
307 | |
100
a1c973c35fef
Fixed using the video mode extension on older servers
Sam Lantinga <slouken@lokigames.com>
parents:
98
diff
changeset
|
308 use_vidmode = vm_major * 100 + vm_minor; |
0 | 309 save_mode(this); |
310 } | |
311 #endif /* XFREE86_VM */ | |
312 | |
313 { | |
314 static int depth_list[] = { 32, 24, 16, 15, 8 }; | |
315 int j, np; | |
316 int use_directcolor = 1; | |
317 XPixmapFormatValues *pf; | |
318 | |
319 /* Search for the visuals in deepest-first order, so that the first | |
320 will be the richest one */ | |
321 if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { | |
322 use_directcolor = 0; | |
323 } | |
324 this->hidden->nvisuals = 0; | |
325 if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) { | |
326 for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) { | |
327 if ( depth_list[i] > 8 ) { | |
328 if ( use_directcolor ) { | |
329 add_visual(this, depth_list[i], DirectColor); | |
330 } | |
331 add_visual(this, depth_list[i], TrueColor); | |
332 } else { | |
333 add_visual(this, depth_list[i], PseudoColor); | |
334 add_visual(this, depth_list[i], StaticColor); | |
335 } | |
336 } | |
337 } | |
338 if ( this->hidden->nvisuals == 0 ) { | |
339 SDL_SetError("Found no sufficiently capable X11 visuals"); | |
340 return -1; | |
341 } | |
342 | |
343 /* look up the pixel quantum for each depth */ | |
344 pf = XListPixmapFormats(SDL_Display, &np); | |
345 for(i = 0; i < this->hidden->nvisuals; i++) { | |
346 int d = this->hidden->visuals[i].depth; | |
347 for(j = 0; j < np; j++) | |
348 if(pf[j].depth == d) | |
349 break; | |
350 this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; | |
351 } | |
352 | |
353 XFree(pf); | |
354 } | |
355 | |
356 if ( SDL_modelist == NULL ) { | |
357 SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); | |
358 if ( SDL_modelist ) { | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
359 n = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
360 SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
361 if ( SDL_modelist[n] ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
362 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
363 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
364 SDL_modelist[n]->w = screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
365 SDL_modelist[n]->h = screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
366 ++n; |
0 | 367 } |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
368 SDL_modelist[n] = NULL; |
0 | 369 } |
370 } | |
371 | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
372 #ifdef XFREE86_DEBUG |
0 | 373 if ( use_vidmode ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
374 printf("XFree86 VidMode is enabled\n"); |
0 | 375 } |
376 if ( SDL_modelist ) { | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
377 printf("X11 video mode list:\n"); |
0 | 378 for ( i=0; SDL_modelist[i]; ++i ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
379 printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h); |
0 | 380 } |
381 } | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
382 #endif /* XFREE86_DEBUG */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
383 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
384 /* The default X/Y fullscreen offset is 0/0 */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
385 xinerama_x = 0; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
386 xinerama_y = 0; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
387 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
388 #ifdef HAVE_XINERAMA |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
389 /* Query Xinerama extention */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
390 if ( XineramaQueryExtension(SDL_Display, &i, &i) && |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
391 XineramaIsActive(SDL_Display) ) { |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
392 /* Find out which screen is the zero'th one */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
393 int screens; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
394 XineramaScreenInfo *xinerama; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
395 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
396 #ifdef XINERAMA_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
397 printf("X11 detected Xinerama:\n"); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
398 #endif |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
399 xinerama = XineramaQueryScreens(SDL_Display, &screens); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
400 for ( i = 0; i < screens; i++ ) { |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
401 #ifdef XINERAMA_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
402 printf("xinerama %d: %dx%d+%d+%d\n", |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
403 xinerama[i].screen_number, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
404 xinerama[i].width, xinerama[i].height, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
405 xinerama[i].x_org, xinerama[i].y_org); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
406 #endif |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
407 if ( xinerama[i].screen_number == 0 ) { |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
408 xinerama_x = xinerama[i].x_org; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
409 xinerama_y = xinerama[i].y_org; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
410 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
411 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
412 XFree(xinerama); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
413 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
414 #endif /* HAVE_XINERAMA */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
415 |
0 | 416 return 0; |
417 } | |
418 | |
419 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) | |
420 { | |
421 int i; | |
422 for(i = 0; i < this->hidden->nvisuals; i++) | |
423 if(this->hidden->visuals[i].bpp == format->BitsPerPixel) | |
424 return 1; | |
425 return 0; | |
426 } | |
427 | |
428 SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
429 { | |
430 if ( X11_SupportedVisual(this, format) ) { | |
431 if ( flags & SDL_FULLSCREEN ) { | |
432 return(SDL_modelist); | |
433 } else { | |
434 return((SDL_Rect **)-1); | |
435 } | |
436 } else { | |
437 return((SDL_Rect **)0); | |
438 } | |
439 } | |
440 | |
441 void X11_FreeVideoModes(_THIS) | |
442 { | |
443 int i; | |
444 | |
445 if ( SDL_modelist ) { | |
446 for ( i=0; SDL_modelist[i]; ++i ) { | |
447 free(SDL_modelist[i]); | |
448 } | |
449 free(SDL_modelist); | |
450 SDL_modelist = NULL; | |
451 } | |
452 } | |
453 | |
454 int X11_ResizeFullScreen(_THIS) | |
455 { | |
456 int x, y; | |
457 int real_w, real_h; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
458 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
459 int screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
460 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
461 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
462 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
0 | 463 |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
464 x = xinerama_x; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
465 y = xinerama_y; |
0 | 466 if ( currently_fullscreen ) { |
467 /* Switch resolution and cover it with the FSwindow */ | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
468 move_cursor_to(this, x, y); |
0 | 469 set_best_resolution(this, current_w, current_h); |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
470 move_cursor_to(this, x, y); |
0 | 471 get_real_resolution(this, &real_w, &real_h); |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
472 if ( current_w > real_w ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
473 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
474 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
475 if ( current_h > real_h ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
476 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
477 } |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
478 XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); |
0 | 479 move_cursor_to(this, real_w/2, real_h/2); |
480 | |
481 /* Center and reparent the drawing window */ | |
482 x = (real_w - current_w)/2; | |
483 y = (real_h - current_h)/2; | |
484 XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); | |
485 /* FIXME: move the mouse to the old relative location */ | |
486 XSync(SDL_Display, True); /* Flush spurious mode change events */ | |
487 } | |
488 return(1); | |
489 } | |
490 | |
491 void X11_QueueEnterFullScreen(_THIS) | |
492 { | |
493 switch_waiting = 0x01 | SDL_FULLSCREEN; | |
494 switch_time = SDL_GetTicks() + 1500; | |
495 #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ | |
496 XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); | |
497 #endif | |
498 } | |
499 | |
500 int X11_EnterFullScreen(_THIS) | |
501 { | |
502 int okay; | |
503 #if 0 | |
504 Window tmpwin, *windows; | |
505 int i, nwindows; | |
506 #endif | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
507 int real_w, real_h; |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
508 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
509 int screen_h; |
0 | 510 |
511 okay = 1; | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
512 if ( currently_fullscreen ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
513 return(okay); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
514 } |
0 | 515 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
516 /* 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
|
517 X11_GrabInputNoLock(this, SDL_GRAB_OFF); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
518 |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
519 /* Map the fullscreen window to blank the screen */ |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
520 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
521 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
522 get_real_resolution(this, &real_w, &real_h); |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
523 if ( current_w > real_w ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
524 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
525 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
526 if ( current_h > real_h ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
527 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
528 } |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
529 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
|
530 XMapRaised(SDL_Display, FSwindow); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
531 X11_WaitMapped(this, FSwindow); |
0 | 532 |
533 #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
|
534 /* 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
|
535 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
|
536 &windows, &nwindows) && windows ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
537 /* 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
|
538 if ( windows[nwindows-1] != FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
539 tmpwin = windows[nwindows-1]; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
540 for ( i=0; i<nwindows; ++i ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
541 if ( windows[i] == FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
542 memcpy(&windows[i], &windows[i+1], |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
543 (nwindows-i-1)*sizeof(windows[i])); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
544 break; |
0 | 545 } |
546 } | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
547 windows[nwindows-1] = FSwindow; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
548 XRestackWindows(SDL_Display, windows, nwindows); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
549 XSync(SDL_Display, False); |
0 | 550 } |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
551 XFree(windows); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
552 } |
0 | 553 #else |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
554 XRaiseWindow(SDL_Display, FSwindow); |
0 | 555 #endif |
556 | |
557 #ifdef XFREE86_VM | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
558 /* Save the current video mode */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
559 if ( use_vidmode ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
560 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
|
561 } |
0 | 562 #endif |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
563 currently_fullscreen = 1; |
0 | 564 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
565 /* Set the new resolution */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
566 okay = X11_ResizeFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
567 if ( ! okay ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
568 X11_LeaveFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
569 } |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
570 /* Set the colormap */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
571 if ( SDL_XColorMap ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
572 XInstallColormap(SDL_Display, SDL_XColorMap); |
0 | 573 } |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
574 if ( okay ) |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
575 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
|
576 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
577 /* 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
|
578 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
|
579 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
580 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
581 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
582 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
583 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
584 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
585 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
586 |
0 | 587 return(okay); |
588 } | |
589 | |
590 int X11_LeaveFullScreen(_THIS) | |
591 { | |
592 if ( currently_fullscreen ) { | |
593 XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); | |
594 #ifdef XFREE86_VM | |
595 if ( use_vidmode ) { | |
596 restore_mode(this); | |
597 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False)); | |
598 } | |
599 #endif | |
600 XUnmapWindow(SDL_Display, FSwindow); | |
601 X11_WaitUnmapped(this, FSwindow); | |
602 XSync(SDL_Display, True); /* Flush spurious mode change events */ | |
603 currently_fullscreen = 0; | |
604 } | |
605 /* If we get popped out of fullscreen mode for some reason, input_grab | |
606 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only | |
607 temporary. In this case, release the grab unless the input has been | |
608 explicitly grabbed. | |
609 */ | |
610 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
|
611 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
612 /* 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
|
613 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
|
614 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
615 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
616 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
617 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
618 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
619 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
620 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
621 |
0 | 622 return(0); |
623 } |