Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
966 lines (851 loc) · 28.8 KB

SDL_x11modes.c

File metadata and controls

966 lines (851 loc) · 28.8 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
/*
SDL - Simple DirectMedia Layer
Feb 1, 2006
Feb 1, 2006
3
Copyright (C) 1997-2006 Sam Lantinga
Apr 26, 2001
Apr 26, 2001
4
5
This library is free software; you can redistribute it and/or
Feb 1, 2006
Feb 1, 2006
6
modify it under the terms of the GNU Lesser General Public
Apr 26, 2001
Apr 26, 2001
7
License as published by the Free Software Foundation; either
Feb 1, 2006
Feb 1, 2006
8
version 2.1 of the License, or (at your option) any later version.
Apr 26, 2001
Apr 26, 2001
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Feb 1, 2006
Feb 1, 2006
13
Lesser General Public License for more details.
Apr 26, 2001
Apr 26, 2001
14
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Apr 26, 2001
Apr 26, 2001
18
19
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Apr 26, 2001
Apr 26, 2001
21
*/
Feb 21, 2006
Feb 21, 2006
22
#include "SDL_config.h"
Apr 26, 2001
Apr 26, 2001
23
24
25
/* Utilities for getting and setting the X display mode */
Feb 7, 2006
Feb 7, 2006
26
#include <stdio.h>
Apr 26, 2001
Apr 26, 2001
27
28
29
#include "SDL_timer.h"
#include "SDL_events.h"
Feb 16, 2006
Feb 16, 2006
30
#include "../../events/SDL_events_c.h"
Apr 26, 2001
Apr 26, 2001
31
32
33
#include "SDL_x11video.h"
#include "SDL_x11wm_c.h"
#include "SDL_x11modes_c.h"
Jul 7, 2001
Jul 7, 2001
34
#include "SDL_x11image_c.h"
Apr 26, 2001
Apr 26, 2001
35
May 17, 2006
May 17, 2006
36
/*#define X11MODES_DEBUG*/
Apr 26, 2001
Apr 26, 2001
37
Sep 30, 2002
Sep 30, 2002
38
#define MAX(a, b) (a > b ? a : b)
Nov 4, 2001
Nov 4, 2001
39
May 28, 2006
May 28, 2006
40
41
42
#if SDL_VIDEO_DRIVER_X11_VIDMODE
int
vidmode_refreshrate (SDL_NAME (XF86VidModeModeInfo) * mode)
May 17, 2006
May 17, 2006
43
{
May 28, 2006
May 28, 2006
44
45
46
return (mode->htotal
&& mode->vtotal) ? (1000 * mode->dotclock / (mode->htotal *
mode->vtotal)) : 0;
May 17, 2006
May 17, 2006
47
48
49
}
#endif
Feb 16, 2006
Feb 16, 2006
50
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
51
52
Bool SDL_NAME (XF86VidModeGetModeInfo) (Display * dpy, int scr,
SDL_NAME (XF86VidModeModeInfo) * info)
Apr 26, 2001
Apr 26, 2001
53
{
May 28, 2006
May 28, 2006
54
55
56
57
58
SDL_NAME (XF86VidModeModeLine) * l =
(SDL_NAME (XF86VidModeModeLine) *) ((char *) info +
sizeof info->dotclock);
return SDL_NAME (XF86VidModeGetModeLine) (dpy, scr,
(int *) &info->dotclock, l);
Apr 26, 2001
Apr 26, 2001
59
}
Feb 16, 2006
Feb 16, 2006
60
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
Apr 26, 2001
Apr 26, 2001
61
Feb 16, 2006
Feb 16, 2006
62
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
63
64
static void
save_mode (_THIS)
Apr 26, 2001
Apr 26, 2001
65
{
May 28, 2006
May 28, 2006
66
67
68
69
SDL_memset (&saved_mode, 0, sizeof (saved_mode));
SDL_NAME (XF86VidModeGetModeInfo) (SDL_Display, SDL_Screen, &saved_mode);
SDL_NAME (XF86VidModeGetViewPort) (SDL_Display, SDL_Screen, &saved_view.x,
&saved_view.y);
Apr 26, 2001
Apr 26, 2001
70
71
72
}
#endif
Feb 16, 2006
Feb 16, 2006
73
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
74
75
static void
restore_mode (_THIS)
Apr 26, 2001
Apr 26, 2001
76
{
May 28, 2006
May 28, 2006
77
SDL_NAME (XF86VidModeModeLine) mode;
Apr 26, 2001
Apr 26, 2001
78
79
int unused;
May 28, 2006
May 28, 2006
80
81
82
83
84
85
if (SDL_NAME (XF86VidModeGetModeLine)
(SDL_Display, SDL_Screen, &unused, &mode)) {
if ((saved_mode.hdisplay != mode.hdisplay) ||
(saved_mode.vdisplay != mode.vdisplay)) {
SDL_NAME (XF86VidModeSwitchToMode) (SDL_Display, SDL_Screen,
&saved_mode);
Apr 26, 2001
Apr 26, 2001
86
87
}
}
May 28, 2006
May 28, 2006
88
89
90
if ((saved_view.x != 0) || (saved_view.y != 0)) {
SDL_NAME (XF86VidModeSetViewPort) (SDL_Display, SDL_Screen,
saved_view.x, saved_view.y);
Apr 26, 2001
Apr 26, 2001
91
92
93
94
}
}
#endif
May 28, 2006
May 28, 2006
95
96
97
98
static void get_real_resolution (_THIS, int *w, int *h);
static void
set_best_resolution (_THIS, int width, int height)
Apr 26, 2001
Apr 26, 2001
99
{
May 28, 2006
May 28, 2006
100
SDL_DisplayMode mode;
Apr 26, 2001
Apr 26, 2001
101
May 28, 2006
May 28, 2006
102
103
104
105
106
mode.format = 0;
mode.w = width;
mode.h = height;
mode.refresh_rate = 0;
SDL_GetClosestDisplayMode (&mode, &mode, SDL_FULLSCREEN);
Nov 22, 2001
Nov 22, 2001
107
Feb 16, 2006
Feb 16, 2006
108
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
109
110
111
112
113
if (use_vidmode) {
SDL_NAME (XF86VidModeModeLine) vmode;
SDL_NAME (XF86VidModeModeInfo) vinfo;
SDL_NAME (XF86VidModeModeInfo) ** modes;
int i, dotclock;
Apr 26, 2001
Apr 26, 2001
114
int nmodes;
May 17, 2006
May 17, 2006
115
int best = -1;
Apr 26, 2001
Apr 26, 2001
116
May 28, 2006
May 28, 2006
117
118
119
120
121
122
123
124
125
126
127
128
if (SDL_NAME (XF86VidModeGetModeLine)
(SDL_Display, SDL_Screen, &dotclock, &vmode)
&& SDL_NAME (XF86VidModeGetAllModeLines) (SDL_Display,
SDL_Screen, &nmodes,
&modes)) {
vinfo.dotclock = dotclock;
SDL_memcpy (&vinfo.hdisplay, &vmode, sizeof (vmode));
for (i = 0; i < nmodes; i++) {
if ((modes[i]->hdisplay == mode.w) &&
(modes[i]->vdisplay == mode.h) &&
(vidmode_refreshrate (modes[i]) == mode.refresh_rate)) {
May 17, 2006
May 17, 2006
129
130
131
best = i;
break;
}
Apr 26, 2001
Apr 26, 2001
132
}
May 28, 2006
May 28, 2006
133
134
135
136
137
if (best >= 0 &&
((modes[best]->hdisplay != vmode.hdisplay) ||
(modes[best]->vdisplay != vmode.vdisplay) ||
(vidmode_refreshrate (modes[best]) !=
vidmode_refreshrate (&vinfo)))) {
May 17, 2006
May 17, 2006
138
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
139
printf ("Best Mode %d: %d x %d @ %d\n", best,
May 17, 2006
May 17, 2006
140
modes[best]->hdisplay, modes[best]->vdisplay,
May 28, 2006
May 28, 2006
141
vidmode_refreshrate (modes[best]));
May 17, 2006
May 17, 2006
142
#endif
May 28, 2006
May 28, 2006
143
144
SDL_NAME (XF86VidModeSwitchToMode) (SDL_Display,
SDL_Screen, modes[best]);
Apr 26, 2001
Apr 26, 2001
145
}
May 28, 2006
May 28, 2006
146
XFree (modes);
Apr 26, 2001
Apr 26, 2001
147
148
}
}
Feb 16, 2006
Feb 16, 2006
149
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
Nov 22, 2001
Nov 22, 2001
150
May 28, 2006
May 28, 2006
151
/* XiG */
Feb 16, 2006
Feb 16, 2006
152
#if SDL_VIDEO_DRIVER_X11_XME
May 28, 2006
May 28, 2006
153
if (use_xme) {
Sep 30, 2002
Sep 30, 2002
154
int i;
May 28, 2006
May 28, 2006
155
int w, h;
Nov 22, 2001
Nov 22, 2001
156
May 28, 2006
May 28, 2006
157
158
/* check current mode so we can avoid uneccessary mode changes */
get_real_resolution (this, &w, &h);
Nov 22, 2001
Nov 22, 2001
159
May 28, 2006
May 28, 2006
160
if ((mode.w != w) || (mode.h != h)) {
May 17, 2006
May 17, 2006
161
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
162
163
fprintf (stderr, "XME: set_best_resolution: "
"XiGMiscChangeResolution: %d %d\n", mode.w, mode.h);
May 17, 2006
May 17, 2006
164
#endif
May 28, 2006
May 28, 2006
165
166
167
XiGMiscChangeResolution (SDL_Display, SDL_Screen, 0, /* view */
mode.w, mode.h, 0);
XSync (SDL_Display, False);
Nov 22, 2001
Nov 22, 2001
168
169
}
}
Feb 16, 2006
Feb 16, 2006
170
#endif /* SDL_VIDEO_DRIVER_X11_XME */
Nov 22, 2001
Nov 22, 2001
171
Mar 22, 2006
Mar 22, 2006
172
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 28, 2006
May 28, 2006
173
if (use_xrandr) {
May 17, 2006
May 17, 2006
174
175
176
177
int i, nsizes;
XRRScreenSize *sizes;
/* find the smallest resolution that is at least as big as the user requested */
May 28, 2006
May 28, 2006
178
179
180
sizes = XRRConfigSizes (screen_config, &nsizes);
for (i = (nsizes - 1); i >= 0; i--) {
if ((mode.w >= width) && (mode.h >= height)) {
May 17, 2006
May 17, 2006
181
break;
Mar 22, 2006
Mar 22, 2006
182
}
May 17, 2006
May 17, 2006
183
}
Mar 22, 2006
Mar 22, 2006
184
May 28, 2006
May 28, 2006
185
if (i >= 0) { /* found one, lets try it */
May 17, 2006
May 17, 2006
186
int w, h;
Mar 22, 2006
Mar 22, 2006
187
May 17, 2006
May 17, 2006
188
/* check current mode so we can avoid uneccessary mode changes */
May 28, 2006
May 28, 2006
189
get_real_resolution (this, &w, &h);
Mar 22, 2006
Mar 22, 2006
190
May 28, 2006
May 28, 2006
191
if ((mode.w != w) || (mode.h != h)) {
May 17, 2006
May 17, 2006
192
int size_id;
Mar 22, 2006
Mar 22, 2006
193
May 17, 2006
May 17, 2006
194
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
195
196
fprintf (stderr, "XRANDR: set_best_resolution: "
"XXRSetScreenConfig: %d %d\n", mode.w, mode.h);
Mar 22, 2006
Mar 22, 2006
197
198
#endif
May 17, 2006
May 17, 2006
199
/* find the matching size entry index */
May 28, 2006
May 28, 2006
200
201
202
for (size_id = 0; size_id < nsizes; ++size_id) {
if ((sizes[size_id].width == mode.w) &&
(sizes[size_id].height == mode.h))
May 17, 2006
May 17, 2006
203
break;
Mar 22, 2006
Mar 22, 2006
204
}
May 17, 2006
May 17, 2006
205
May 28, 2006
May 28, 2006
206
207
208
XRRSetScreenConfig (SDL_Display, screen_config,
SDL_Root, size_id, saved_rotation,
CurrentTime);
Mar 22, 2006
Mar 22, 2006
209
210
211
212
}
}
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Apr 26, 2001
Apr 26, 2001
213
214
}
May 28, 2006
May 28, 2006
215
216
static void
get_real_resolution (_THIS, int *w, int *h)
Apr 26, 2001
Apr 26, 2001
217
{
Feb 16, 2006
Feb 16, 2006
218
#if SDL_VIDEO_DRIVER_X11_XME
May 28, 2006
May 28, 2006
219
if (use_xme) {
Nov 22, 2001
Nov 22, 2001
220
221
222
int ractive;
XiGMiscResolutionInfo *modelist;
May 28, 2006
May 28, 2006
223
224
XiGMiscQueryResolutions (SDL_Display, SDL_Screen, 0, /* view */
&ractive, &modelist);
Nov 22, 2001
Nov 22, 2001
225
226
*w = modelist[ractive].width;
*h = modelist[ractive].height;
May 17, 2006
May 17, 2006
227
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
228
fprintf (stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h);
Nov 22, 2001
Nov 22, 2001
229
#endif
May 28, 2006
May 28, 2006
230
XFree (modelist);
Nov 22, 2001
Nov 22, 2001
231
232
return;
}
Mar 22, 2006
Mar 22, 2006
233
234
#endif /* SDL_VIDEO_DRIVER_X11_XME */
May 17, 2006
May 17, 2006
235
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
236
237
if (use_vidmode) {
SDL_NAME (XF86VidModeModeLine) mode;
May 17, 2006
May 17, 2006
238
239
int unused;
May 28, 2006
May 28, 2006
240
241
if (SDL_NAME (XF86VidModeGetModeLine)
(SDL_Display, SDL_Screen, &unused, &mode)) {
May 17, 2006
May 17, 2006
242
243
244
245
246
247
248
*w = mode.hdisplay;
*h = mode.vdisplay;
return;
}
}
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
Mar 22, 2006
Mar 22, 2006
249
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 28, 2006
May 28, 2006
250
if (use_xrandr) {
Mar 22, 2006
Mar 22, 2006
251
int nsizes;
May 28, 2006
May 28, 2006
252
XRRScreenSize *sizes;
Mar 22, 2006
Mar 22, 2006
253
May 28, 2006
May 28, 2006
254
255
sizes = XRRConfigSizes (screen_config, &nsizes);
if (nsizes > 0) {
Mar 22, 2006
Mar 22, 2006
256
257
258
int cur_size;
Rotation cur_rotation;
May 28, 2006
May 28, 2006
259
260
261
cur_size =
XRRConfigCurrentConfiguration (screen_config, &cur_rotation);
if (cur_size >= 0 && cur_size < nsizes) {
Mar 22, 2006
Mar 22, 2006
262
263
264
*w = sizes[cur_size].width;
*h = sizes[cur_size].height;
}
May 17, 2006
May 17, 2006
265
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
266
267
fprintf (stderr,
"XRANDR: get_real_resolution: w = %d h = %d\n", *w, *h);
Mar 22, 2006
Mar 22, 2006
268
269
270
271
272
#endif
return;
}
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Nov 22, 2001
Nov 22, 2001
273
May 17, 2006
May 17, 2006
274
#if SDL_VIDEO_DRIVER_X11_XINERAMA
May 28, 2006
May 28, 2006
275
276
277
if (use_xinerama) {
*w = xinerama[this->current_display].width;
*h = xinerama[this->current_display].height;
May 17, 2006
May 17, 2006
278
279
280
281
return;
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
May 28, 2006
May 28, 2006
282
283
*w = DisplayWidth (SDL_Display, SDL_Screen);
*h = DisplayHeight (SDL_Display, SDL_Screen);
Apr 26, 2001
Apr 26, 2001
284
285
286
}
/* Called after mapping a window - waits until the window is mapped */
May 28, 2006
May 28, 2006
287
288
void
X11_WaitMapped (_THIS, Window win)
Apr 26, 2001
Apr 26, 2001
289
290
291
{
XEvent event;
do {
May 28, 2006
May 28, 2006
292
293
294
XMaskEvent (SDL_Display, StructureNotifyMask, &event);
}
while ((event.type != MapNotify) || (event.xmap.event != win));
Apr 26, 2001
Apr 26, 2001
295
296
297
}
/* Called after unmapping a window - waits until the window is unmapped */
May 28, 2006
May 28, 2006
298
299
void
X11_WaitUnmapped (_THIS, Window win)
Apr 26, 2001
Apr 26, 2001
300
301
302
{
XEvent event;
do {
May 28, 2006
May 28, 2006
303
304
305
XMaskEvent (SDL_Display, StructureNotifyMask, &event);
}
while ((event.type != UnmapNotify) || (event.xunmap.event != win));
Apr 26, 2001
Apr 26, 2001
306
307
}
May 28, 2006
May 28, 2006
308
309
static void
move_cursor_to (_THIS, int x, int y)
Apr 26, 2001
Apr 26, 2001
310
{
May 28, 2006
May 28, 2006
311
XWarpPointer (SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y);
Apr 26, 2001
Apr 26, 2001
312
313
}
May 28, 2006
May 28, 2006
314
315
static int
add_visual (_THIS, int depth, int class)
Apr 26, 2001
Apr 26, 2001
316
317
{
XVisualInfo vi;
May 28, 2006
May 28, 2006
318
if (XMatchVisualInfo (SDL_Display, SDL_Screen, depth, class, &vi)) {
Sep 30, 2002
Sep 30, 2002
319
320
321
322
int n = this->hidden->nvisuals;
this->hidden->visuals[n].depth = vi.depth;
this->hidden->visuals[n].visual = vi.visual;
this->hidden->nvisuals++;
Apr 26, 2001
Apr 26, 2001
323
}
May 28, 2006
May 28, 2006
324
return (this->hidden->nvisuals);
Apr 26, 2001
Apr 26, 2001
325
}
May 28, 2006
May 28, 2006
326
327
static int
add_visual_byid (_THIS, const char *visual_id)
Apr 26, 2001
Apr 26, 2001
328
329
330
331
{
XVisualInfo *vi, template;
int nvis;
May 28, 2006
May 28, 2006
332
333
334
335
336
if (visual_id) {
SDL_memset (&template, 0, (sizeof template));
template.visualid = SDL_strtol (visual_id, NULL, 0);
vi = XGetVisualInfo (SDL_Display, VisualIDMask, &template, &nvis);
if (vi) {
Sep 30, 2002
Sep 30, 2002
337
338
339
340
int n = this->hidden->nvisuals;
this->hidden->visuals[n].depth = vi->depth;
this->hidden->visuals[n].visual = vi->visual;
this->hidden->nvisuals++;
May 28, 2006
May 28, 2006
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
XFree (vi);
}
}
return (this->hidden->nvisuals);
}
int
X11_GetVisuals (_THIS)
{
/* It's interesting to note that if we allow 32 bit depths,
we get a visual with an alpha mask on composite servers.
static int depth_list[] = { 32, 24, 16, 15, 8 };
*/
static int depth_list[] = { 24, 16, 15, 8 };
int i, j, np;
int use_directcolor = 1;
XPixmapFormatValues *pf;
/* Search for the visuals in deepest-first order, so that the first
will be the richest one */
if (SDL_getenv ("SDL_VIDEO_X11_NODIRECTCOLOR")) {
use_directcolor = 0;
}
this->hidden->nvisuals = 0;
if (!add_visual_byid (this, SDL_getenv ("SDL_VIDEO_X11_VISUALID"))) {
for (i = 0; i < SDL_arraysize (depth_list); ++i) {
if (depth_list[i] > 8) {
if (use_directcolor) {
add_visual (this, depth_list[i], DirectColor);
}
add_visual (this, depth_list[i], TrueColor);
} else {
add_visual (this, depth_list[i], PseudoColor);
add_visual (this, depth_list[i], StaticColor);
}
Apr 26, 2001
Apr 26, 2001
376
377
}
}
May 28, 2006
May 28, 2006
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
if (this->hidden->nvisuals == 0) {
SDL_SetError ("Found no sufficiently capable X11 visuals");
return -1;
}
/* look up the pixel quantum for each depth */
pf = XListPixmapFormats (SDL_Display, &np);
for (i = 0; i < this->hidden->nvisuals; i++) {
int d = this->hidden->visuals[i].depth;
for (j = 0; j < np; j++)
if (pf[j].depth == d)
break;
this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
}
XFree (pf);
return 0;
Apr 26, 2001
Apr 26, 2001
395
396
397
398
399
}
/* Global for the error handler */
int vm_event, vm_error = -1;
May 17, 2006
May 17, 2006
400
#if SDL_VIDEO_DRIVER_X11_XINERAMA
May 28, 2006
May 28, 2006
401
402
static int
CheckXinerama (_THIS, int *major, int *minor)
May 17, 2006
May 17, 2006
403
404
405
406
407
408
409
{
const char *env;
/* Default the extension not available */
*major = *minor = 0;
/* Allow environment override */
May 28, 2006
May 28, 2006
410
411
env = getenv ("SDL_VIDEO_X11_XINERAMA");
if (env && !SDL_atoi (env)) {
May 17, 2006
May 17, 2006
412
413
414
415
return 0;
}
/* Query the extension version */
May 28, 2006
May 28, 2006
416
417
if (!SDL_NAME (XineramaQueryExtension) (SDL_Display, major, minor) ||
!SDL_NAME (XineramaIsActive) (SDL_Display)) {
May 17, 2006
May 17, 2006
418
419
420
421
422
423
424
return 0;
}
return 1;
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 28, 2006
May 28, 2006
425
426
static int
CheckXRandR (_THIS, int *major, int *minor)
May 17, 2006
May 17, 2006
427
428
429
430
431
432
433
{
const char *env;
/* Default the extension not available */
*major = *minor = 0;
/* Allow environment override */
May 28, 2006
May 28, 2006
434
435
env = getenv ("SDL_VIDEO_X11_XRANDR");
if (env && !SDL_atoi (env)) {
May 17, 2006
May 17, 2006
436
437
438
439
return 0;
}
/* This defaults off now, due to KDE window maximize problems */
May 28, 2006
May 28, 2006
440
if (!env) {
May 17, 2006
May 17, 2006
441
442
443
return 0;
}
May 28, 2006
May 28, 2006
444
if (!SDL_X11_HAVE_XRANDR) {
May 17, 2006
May 17, 2006
445
446
447
448
return 0;
}
/* Query the extension version */
May 28, 2006
May 28, 2006
449
if (!XRRQueryVersion (SDL_Display, major, minor)) {
May 17, 2006
May 17, 2006
450
451
452
453
454
455
456
return 0;
}
return 1;
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
457
458
static int
CheckVidMode (_THIS, int *major, int *minor)
May 17, 2006
May 17, 2006
459
460
461
462
463
464
465
{
const char *env;
/* Default the extension not available */
*major = *minor = 0;
/* Allow environment override */
May 28, 2006
May 28, 2006
466
467
env = getenv ("SDL_VIDEO_X11_VIDMODE");
if (env && !SDL_atoi (env)) {
May 17, 2006
May 17, 2006
468
469
return 0;
}
May 28, 2006
May 28, 2006
470
May 17, 2006
May 17, 2006
471
472
473
/* Metro-X 4.3.0 and earlier has a broken implementation of
XF86VidModeGetAllModeLines() - it hangs the client.
*/
May 28, 2006
May 28, 2006
474
475
if (SDL_strcmp (ServerVendor (SDL_Display), "Metro Link Incorporated") ==
0) {
May 17, 2006
May 17, 2006
476
477
FILE *metro_fp;
May 28, 2006
May 28, 2006
478
479
metro_fp = fopen ("/usr/X11R6/lib/X11/Metro/.version", "r");
if (metro_fp != NULL) {
May 17, 2006
May 17, 2006
480
int major, minor, patch, version;
May 28, 2006
May 28, 2006
481
482
483
484
485
486
487
major = 0;
minor = 0;
patch = 0;
fscanf (metro_fp, "%d.%d.%d", &major, &minor, &patch);
fclose (metro_fp);
version = major * 100 + minor * 10 + patch;
if (version < 431) {
May 17, 2006
May 17, 2006
488
489
490
491
492
493
494
return 0;
}
}
}
/* Query the extension version */
vm_error = -1;
May 28, 2006
May 28, 2006
495
496
497
if (!SDL_NAME (XF86VidModeQueryExtension)
(SDL_Display, &vm_event, &vm_error)
|| !SDL_NAME (XF86VidModeQueryVersion) (SDL_Display, major, minor)) {
May 17, 2006
May 17, 2006
498
499
500
501
502
503
504
return 0;
}
return 1;
}
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
#if SDL_VIDEO_DRIVER_X11_XME
May 28, 2006
May 28, 2006
505
506
static int
CheckXME (_THIS, int *major, int *minor)
May 17, 2006
May 17, 2006
507
508
509
510
511
512
513
{
const char *env;
/* Default the extension not available */
*major = *minor = 0;
/* Allow environment override */
May 28, 2006
May 28, 2006
514
515
env = getenv ("SDL_VIDEO_X11_VIDMODE");
if (env && !SDL_atoi (env)) {
May 17, 2006
May 17, 2006
516
517
return 0;
}
May 28, 2006
May 28, 2006
518
May 17, 2006
May 17, 2006
519
/* Query the extension version */
May 28, 2006
May 28, 2006
520
if (!XiGMiscQueryVersion (SDL_Display, major, minor)) {
May 17, 2006
May 17, 2006
521
522
523
524
525
526
return 0;
}
return 1;
}
#endif /* SDL_VIDEO_DRIVER_X11_XME */
May 28, 2006
May 28, 2006
527
528
int
X11_GetVideoModes (_THIS)
Apr 26, 2001
Apr 26, 2001
529
{
May 17, 2006
May 17, 2006
530
531
532
533
534
535
536
#if SDL_VIDEO_DRIVER_X11_XINERAMA
int xinerama_major, xinerama_minor;
#endif
#if SDL_VIDEO_DRIVER_X11_XRANDR
int xrandr_major, xrandr_minor;
int nsizes;
XRRScreenSize *sizes;
May 28, 2006
May 28, 2006
537
538
int nrates;
short *rates;
May 17, 2006
May 17, 2006
539
#endif
Feb 16, 2006
Feb 16, 2006
540
#if SDL_VIDEO_DRIVER_X11_VIDMODE
Apr 26, 2001
Apr 26, 2001
541
542
int vm_major, vm_minor;
int nmodes;
May 28, 2006
May 28, 2006
543
SDL_NAME (XF86VidModeModeInfo) ** modes;
Nov 22, 2001
Nov 22, 2001
544
#endif
Feb 16, 2006
Feb 16, 2006
545
#if SDL_VIDEO_DRIVER_X11_XME
Nov 22, 2001
Nov 22, 2001
546
547
548
int xme_major, xme_minor;
int ractive, nummodes;
XiGMiscResolutionInfo *modelist;
Apr 26, 2001
Apr 26, 2001
549
#endif
May 28, 2006
May 28, 2006
550
int i;
Nov 4, 2001
Nov 4, 2001
551
552
int screen_w;
int screen_h;
May 28, 2006
May 28, 2006
553
SDL_DisplayMode mode;
Apr 26, 2001
Apr 26, 2001
554
May 17, 2006
May 17, 2006
555
use_xinerama = 0;
Mar 22, 2006
Mar 22, 2006
556
use_xrandr = 0;
May 17, 2006
May 17, 2006
557
558
use_vidmode = 0;
use_xme = 0;
May 28, 2006
May 28, 2006
559
560
561
562
563
564
565
566
screen_w = DisplayWidth (SDL_Display, SDL_Screen);
screen_h = DisplayHeight (SDL_Display, SDL_Screen);
mode.format = this->displays[this->current_display].desktop_mode.format;
mode.w = screen_w;
mode.h = screen_h;
mode.refresh_rate = 0;
SDL_AddDisplayMode (0, &mode);
Nov 4, 2001
Nov 4, 2001
567
May 17, 2006
May 17, 2006
568
569
#if SDL_VIDEO_DRIVER_X11_XINERAMA
/* Query Xinerama extention */
May 28, 2006
May 28, 2006
570
if (CheckXinerama (this, &xinerama_major, &xinerama_minor)) {
May 17, 2006
May 17, 2006
571
572
573
int screens;
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
574
printf ("X11 detected Xinerama:\n");
May 17, 2006
May 17, 2006
575
#endif
May 28, 2006
May 28, 2006
576
577
xinerama = SDL_NAME (XineramaQueryScreens) (SDL_Display, &screens);
for (i = 0; i < screens; i++) {
May 17, 2006
May 17, 2006
578
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
579
580
581
582
printf ("xinerama %d: %dx%d+%d+%d\n",
xinerama[i].screen_number,
xinerama[i].width, xinerama[i].height,
xinerama[i].x_org, xinerama[i].y_org);
May 17, 2006
May 17, 2006
583
#endif
May 28, 2006
May 28, 2006
584
585
if (xinerama[i].screen_number != 0) {
SDL_AddVideoDisplay (&mode);
May 17, 2006
May 17, 2006
586
}
May 28, 2006
May 28, 2006
587
588
589
mode.w = xinerama[i].width;
mode.h = xinerama[i].height;
SDL_AddDisplayMode (xinerama[i].screen_number, &mode);
May 17, 2006
May 17, 2006
590
}
May 28, 2006
May 28, 2006
591
use_xinerama = 1;
May 17, 2006
May 17, 2006
592
593
594
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
Mar 22, 2006
Mar 22, 2006
595
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 17, 2006
May 17, 2006
596
/* XRandR */
Mar 22, 2006
Mar 22, 2006
597
/* require at least XRandR v1.0 (arbitrary) */
May 28, 2006
May 28, 2006
598
599
if (CheckXRandR (this, &xrandr_major, &xrandr_minor)
&& (xrandr_major >= 1)) {
May 17, 2006
May 17, 2006
600
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
601
602
fprintf (stderr, "XRANDR: XRRQueryVersion: V%d.%d\n",
xrandr_major, xrandr_minor);
Mar 22, 2006
Mar 22, 2006
603
604
605
606
#endif
/* save the screen configuration since we must reference it
each time we toggle modes.
May 28, 2006
May 28, 2006
607
608
*/
screen_config = XRRGetScreenInfo (SDL_Display, SDL_Root);
Mar 22, 2006
Mar 22, 2006
609
610
/* retrieve the list of resolution */
May 28, 2006
May 28, 2006
611
sizes = XRRConfigSizes (screen_config, &nsizes);
Mar 22, 2006
Mar 22, 2006
612
if (nsizes > 0) {
May 28, 2006
May 28, 2006
613
614
615
616
617
618
619
620
621
622
623
624
625
626
for (i = 0; i < nsizes; i++) {
mode.w = sizes[i].width;
mode.h = sizes[i].height;
rates = XRRConfigRates (screen_config, i, &nrates);
if (nrates == 0) {
mode.refresh_rate = 0;
SDL_AddDisplayMode (0, &mode);
} else {
int j;
for (j = 0; j < nrates; ++j) {
mode.refresh_rate = rates[j];
SDL_AddDisplayMode (0, &mode);
}
May 17, 2006
May 17, 2006
627
}
Mar 22, 2006
Mar 22, 2006
628
}
May 17, 2006
May 17, 2006
629
Mar 22, 2006
Mar 22, 2006
630
use_xrandr = xrandr_major * 100 + xrandr_minor;
May 28, 2006
May 28, 2006
631
632
633
saved_size_id =
XRRConfigCurrentConfiguration (screen_config,
&saved_rotation);
Mar 22, 2006
Mar 22, 2006
634
635
636
637
}
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Feb 16, 2006
Feb 16, 2006
638
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 17, 2006
May 17, 2006
639
/* XVidMode */
May 28, 2006
May 28, 2006
640
641
642
643
if (!use_xrandr &&
CheckVidMode (this, &vm_major, &vm_minor) &&
SDL_NAME (XF86VidModeGetAllModeLines) (SDL_Display, SDL_Screen,
&nmodes, &modes)) {
May 17, 2006
May 17, 2006
644
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
645
646
647
printf ("VidMode modes: (unsorted)\n");
for (i = 0; i < nmodes; ++i) {
printf ("Mode %d: %d x %d @ %d\n", i,
Jun 28, 2003
Jun 28, 2003
648
modes[i]->hdisplay, modes[i]->vdisplay,
May 28, 2006
May 28, 2006
649
vidmode_refreshrate (modes[i]));
Jun 28, 2003
Jun 28, 2003
650
651
}
#endif
May 28, 2006
May 28, 2006
652
653
654
655
656
for (i = 0; i < nmodes; ++i) {
mode.w = modes[i]->hdisplay;
mode.h = modes[i]->vdisplay;
mode.refresh_rate = vidmode_refreshrate (modes[i]);
SDL_AddDisplayMode (0, &mode);
Apr 26, 2001
Apr 26, 2001
657
}
May 28, 2006
May 28, 2006
658
XFree (modes);
Apr 26, 2001
Apr 26, 2001
659
Jul 11, 2001
Jul 11, 2001
660
use_vidmode = vm_major * 100 + vm_minor;
May 28, 2006
May 28, 2006
661
save_mode (this);
Apr 26, 2001
Apr 26, 2001
662
}
Feb 16, 2006
Feb 16, 2006
663
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
Apr 26, 2001
Apr 26, 2001
664
Feb 16, 2006
Feb 16, 2006
665
#if SDL_VIDEO_DRIVER_X11_XME
May 17, 2006
May 17, 2006
666
/* XiG */
Nov 22, 2001
Nov 22, 2001
667
modelist = NULL;
May 17, 2006
May 17, 2006
668
/* first lets make sure we have the extension, and it's at least v2.0 */
May 28, 2006
May 28, 2006
669
670
671
672
if (CheckXME (this, &xme_major, &xme_minor) && xme_major >= 2 && (nummodes = XiGMiscQueryResolutions (SDL_Display, SDL_Screen, 0, /* view */
&ractive,
&modelist))
> 1) { /* then we actually have some */
May 17, 2006
May 17, 2006
673
674
675
/* We get the list already sorted in descending order.
We'll copy it in reverse order so SDL is happy */
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
676
677
fprintf (stderr, "XME: nummodes = %d, active mode = %d\n",
nummodes, ractive);
Nov 22, 2001
Nov 22, 2001
678
#endif
May 28, 2006
May 28, 2006
679
680
mode.refresh_rate = 0;
for (i = 0; i < nummodes; ++i) {
May 17, 2006
May 17, 2006
681
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
682
683
fprintf (stderr, "XME: mode = %4d, w = %4d, h = %4d\n",
i, modelist[i].width, modelist[i].height);
Nov 22, 2001
Nov 22, 2001
684
#endif
May 28, 2006
May 28, 2006
685
686
687
mode.w = modelist[i].width;
mode.h = modelist[i].height;
SDL_AddDisplayMode (0, &mode);
Sep 30, 2002
Sep 30, 2002
688
}
May 17, 2006
May 17, 2006
689
690
use_xme = xme_major * 100 + xme_minor;
May 28, 2006
May 28, 2006
691
saved_res = modelist[ractive]; /* save the current resolution */
Nov 22, 2001
Nov 22, 2001
692
}
May 28, 2006
May 28, 2006
693
694
if (modelist) {
XFree (modelist);
Nov 22, 2001
Nov 22, 2001
695
}
Feb 16, 2006
Feb 16, 2006
696
#endif /* SDL_VIDEO_DRIVER_X11_XME */
Nov 22, 2001
Nov 22, 2001
697
May 17, 2006
May 17, 2006
698
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
699
700
if (use_xinerama) {
printf ("Xinerama is enabled\n");
Apr 26, 2001
Apr 26, 2001
701
702
}
May 28, 2006
May 28, 2006
703
704
if (use_xrandr) {
printf ("XRandR is enabled\n");
Apr 26, 2001
Apr 26, 2001
705
}
Nov 22, 2001
Nov 22, 2001
706
May 28, 2006
May 28, 2006
707
708
if (use_vidmode) {
printf ("VidMode is enabled\n");
May 17, 2006
May 17, 2006
709
}
Nov 22, 2001
Nov 22, 2001
710
May 28, 2006
May 28, 2006
711
712
if (use_xme) {
printf ("Xi Graphics XME fullscreen is enabled\n");
Apr 26, 2001
Apr 26, 2001
713
}
May 17, 2006
May 17, 2006
714
#endif /* X11MODES_DEBUG */
Nov 3, 2001
Nov 3, 2001
715
Apr 26, 2001
Apr 26, 2001
716
717
718
return 0;
}
May 28, 2006
May 28, 2006
719
720
void
X11_FreeVideoModes (_THIS)
Apr 26, 2001
Apr 26, 2001
721
{
Mar 22, 2006
Mar 22, 2006
722
723
#if SDL_VIDEO_DRIVER_X11_XRANDR
/* Free the Xrandr screen configuration */
May 28, 2006
May 28, 2006
724
725
if (screen_config) {
XRRFreeScreenConfigInfo (screen_config);
Mar 22, 2006
Mar 22, 2006
726
727
728
screen_config = NULL;
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Apr 26, 2001
Apr 26, 2001
729
730
}
May 28, 2006
May 28, 2006
731
732
int
X11_ResizeFullScreen (_THIS)
Apr 26, 2001
Apr 26, 2001
733
{
May 17, 2006
May 17, 2006
734
int x = 0, y = 0;
Apr 26, 2001
Apr 26, 2001
735
int real_w, real_h;
Nov 4, 2001
Nov 4, 2001
736
737
738
int screen_w;
int screen_h;
May 28, 2006
May 28, 2006
739
740
screen_w = DisplayWidth (SDL_Display, SDL_Screen);
screen_h = DisplayHeight (SDL_Display, SDL_Screen);
Apr 26, 2001
Apr 26, 2001
741
May 17, 2006
May 17, 2006
742
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
743
744
745
746
747
if (use_xinerama &&
window_w <= xinerama[this->current_display].width &&
window_h <= xinerama[this->current_display].height) {
x = xinerama[this->current_display].x_org;
y = xinerama[this->current_display].y_org;
May 17, 2006
May 17, 2006
748
749
}
#endif
May 28, 2006
May 28, 2006
750
if (currently_fullscreen) {
Apr 26, 2001
Apr 26, 2001
751
/* Switch resolution and cover it with the FSwindow */
May 28, 2006
May 28, 2006
752
753
754
755
756
757
move_cursor_to (this, x, y);
set_best_resolution (this, window_w, window_h);
move_cursor_to (this, x, y);
get_real_resolution (this, &real_w, &real_h);
if (window_w > real_w) {
real_w = MAX (real_w, screen_w);
Nov 4, 2001
Nov 4, 2001
758
}
May 28, 2006
May 28, 2006
759
760
if (window_h > real_h) {
real_h = MAX (real_h, screen_h);
Nov 4, 2001
Nov 4, 2001
761
}
May 28, 2006
May 28, 2006
762
763
XMoveResizeWindow (SDL_Display, FSwindow, x, y, real_w, real_h);
move_cursor_to (this, real_w / 2, real_h / 2);
Apr 26, 2001
Apr 26, 2001
764
765
/* Center and reparent the drawing window */
May 28, 2006
May 28, 2006
766
767
768
x = (real_w - window_w) / 2;
y = (real_h - window_h) / 2;
XReparentWindow (SDL_Display, SDL_Window, FSwindow, x, y);
Apr 26, 2001
Apr 26, 2001
769
/* FIXME: move the mouse to the old relative location */
May 28, 2006
May 28, 2006
770
XSync (SDL_Display, True); /* Flush spurious mode change events */
Apr 26, 2001
Apr 26, 2001
771
}
May 28, 2006
May 28, 2006
772
return (1);
Apr 26, 2001
Apr 26, 2001
773
774
}
May 28, 2006
May 28, 2006
775
776
void
X11_QueueEnterFullScreen (_THIS)
Apr 26, 2001
Apr 26, 2001
777
778
{
switch_waiting = 0x01 | SDL_FULLSCREEN;
May 28, 2006
May 28, 2006
779
780
781
switch_time = SDL_GetTicks () + 1500;
#if 0 /* This causes a BadMatch error if the window is iconified (not needed) */
XSetInputFocus (SDL_Display, WMwindow, RevertToNone, CurrentTime);
Apr 26, 2001
Apr 26, 2001
782
783
784
#endif
}
May 28, 2006
May 28, 2006
785
786
int
X11_EnterFullScreen (_THIS)
Apr 26, 2001
Apr 26, 2001
787
788
789
790
791
792
{
int okay;
#if 0
Window tmpwin, *windows;
int i, nwindows;
#endif
May 17, 2006
May 17, 2006
793
int x = 0, y = 0;
Jul 9, 2001
Jul 9, 2001
794
int real_w, real_h;
Nov 4, 2001
Nov 4, 2001
795
796
int screen_w;
int screen_h;
Apr 26, 2001
Apr 26, 2001
797
798
okay = 1;
May 28, 2006
May 28, 2006
799
800
if (currently_fullscreen) {
return (okay);
Jul 9, 2001
Jul 9, 2001
801
}
Apr 26, 2001
Apr 26, 2001
802
Jul 9, 2001
Jul 9, 2001
803
/* Ungrab the input so that we can move the mouse around */
May 28, 2006
May 28, 2006
804
X11_GrabInputNoLock (this, SDL_GRAB_OFF);
Jul 9, 2001
Jul 9, 2001
805
May 17, 2006
May 17, 2006
806
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
807
808
809
810
811
if (use_xinerama &&
window_w <= xinerama[this->current_display].width &&
window_h <= xinerama[this->current_display].height) {
x = xinerama[this->current_display].x_org;
y = xinerama[this->current_display].y_org;
May 17, 2006
May 17, 2006
812
813
}
#endif
Jul 9, 2001
Jul 9, 2001
814
/* Map the fullscreen window to blank the screen */
May 28, 2006
May 28, 2006
815
816
817
818
819
screen_w = DisplayWidth (SDL_Display, SDL_Screen);
screen_h = DisplayHeight (SDL_Display, SDL_Screen);
get_real_resolution (this, &real_w, &real_h);
if (window_w > real_w) {
real_w = MAX (real_w, screen_w);
Nov 4, 2001
Nov 4, 2001
820
}
May 28, 2006
May 28, 2006
821
822
if (window_h > real_h) {
real_h = MAX (real_h, screen_h);
Nov 4, 2001
Nov 4, 2001
823
}
May 28, 2006
May 28, 2006
824
825
826
XMoveResizeWindow (SDL_Display, FSwindow, x, y, real_w, real_h);
XMapRaised (SDL_Display, FSwindow);
X11_WaitMapped (this, FSwindow);
Apr 26, 2001
Apr 26, 2001
827
May 28, 2006
May 28, 2006
828
#if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
Jul 9, 2001
Jul 9, 2001
829
/* Make sure we got to the top of the window stack */
May 28, 2006
May 28, 2006
830
831
if (XQueryTree (SDL_Display, SDL_Root, &tmpwin, &tmpwin,
&windows, &nwindows) && windows) {
Jul 9, 2001
Jul 9, 2001
832
/* If not, try to put us there - if fail... oh well */
May 28, 2006
May 28, 2006
833
834
835
836
837
838
if (windows[nwindows - 1] != FSwindow) {
tmpwin = windows[nwindows - 1];
for (i = 0; i < nwindows; ++i) {
if (windows[i] == FSwindow) {
SDL_memcpy (&windows[i], &windows[i + 1],
(nwindows - i - 1) * sizeof (windows[i]));
Jul 9, 2001
Jul 9, 2001
839
break;
Apr 26, 2001
Apr 26, 2001
840
841
}
}
May 28, 2006
May 28, 2006
842
843
844
windows[nwindows - 1] = FSwindow;
XRestackWindows (SDL_Display, windows, nwindows);
XSync (SDL_Display, False);
Apr 26, 2001
Apr 26, 2001
845
}
May 28, 2006
May 28, 2006
846
XFree (windows);
Jul 9, 2001
Jul 9, 2001
847
}
Apr 26, 2001
Apr 26, 2001
848
#else
May 28, 2006
May 28, 2006
849
XRaiseWindow (SDL_Display, FSwindow);
Apr 26, 2001
Apr 26, 2001
850
851
#endif
Feb 16, 2006
Feb 16, 2006
852
#if SDL_VIDEO_DRIVER_X11_VIDMODE
Jul 9, 2001
Jul 9, 2001
853
/* Save the current video mode */
May 28, 2006
May 28, 2006
854
855
if (use_vidmode) {
SDL_NAME (XF86VidModeLockModeSwitch) (SDL_Display, SDL_Screen, True);
Jul 9, 2001
Jul 9, 2001
856
}
Apr 26, 2001
Apr 26, 2001
857
#endif
Jul 9, 2001
Jul 9, 2001
858
currently_fullscreen = 1;
Apr 26, 2001
Apr 26, 2001
859
Jul 9, 2001
Jul 9, 2001
860
/* Set the new resolution */
May 28, 2006
May 28, 2006
861
862
863
okay = X11_ResizeFullScreen (this);
if (!okay) {
X11_LeaveFullScreen (this);
Jul 9, 2001
Jul 9, 2001
864
865
}
/* Set the colormap */
May 28, 2006
May 28, 2006
866
867
if (SDL_XColorMap) {
XInstallColormap (SDL_Display, SDL_XColorMap);
Apr 26, 2001
Apr 26, 2001
868
}
May 28, 2006
May 28, 2006
869
870
871
872
if (okay) {
X11_GrabInputNoLock (this,
SDL_CurrentWindow.
input_grab | SDL_GRAB_FULLSCREEN);
May 17, 2006
May 17, 2006
873
}
Jul 7, 2001
Jul 7, 2001
874
875
876
/* We may need to refresh the screen at this point (no backing store)
We also don't get an event, which is why we explicitly refresh. */
May 28, 2006
May 28, 2006
877
878
879
if (SDL_VideoSurface) {
if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
SDL_PrivateExpose ();
Jul 7, 2001
Jul 7, 2001
880
} else {
May 28, 2006
May 28, 2006
881
X11_RefreshDisplay (this);
Jul 7, 2001
Jul 7, 2001
882
883
884
}
}
May 28, 2006
May 28, 2006
885
return (okay);
Apr 26, 2001
Apr 26, 2001
886
887
}
May 28, 2006
May 28, 2006
888
889
int
X11_LeaveFullScreen (_THIS)
Apr 26, 2001
Apr 26, 2001
890
{
May 28, 2006
May 28, 2006
891
892
if (currently_fullscreen) {
XReparentWindow (SDL_Display, SDL_Window, WMwindow, 0, 0);
Feb 16, 2006
Feb 16, 2006
893
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 28, 2006
May 28, 2006
894
895
896
897
if (use_vidmode) {
restore_mode (this);
SDL_NAME (XF86VidModeLockModeSwitch) (SDL_Display, SDL_Screen,
False);
Apr 26, 2001
Apr 26, 2001
898
899
}
#endif
Nov 22, 2001
Nov 22, 2001
900
Feb 16, 2006
Feb 16, 2006
901
#if SDL_VIDEO_DRIVER_X11_XME
May 28, 2006
May 28, 2006
902
903
904
if (use_xme) {
int rw, rh;
Nov 22, 2001
Nov 22, 2001
905
/* check current mode so we can avoid uneccessary mode changes */
May 28, 2006
May 28, 2006
906
get_real_resolution (this, &rw, &rh);
Sep 30, 2002
Sep 30, 2002
907
908
if (rw != saved_res.width || rh != saved_res.height) {
May 28, 2006
May 28, 2006
909
910
911
912
XiGMiscChangeResolution (SDL_Display, SDL_Screen, 0, /* view */
saved_res.width,
saved_res.height, 0);
XSync (SDL_Display, False);
Sep 30, 2002
Sep 30, 2002
913
914
}
}
Nov 22, 2001
Nov 22, 2001
915
916
#endif
Mar 22, 2006
Mar 22, 2006
917
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 28, 2006
May 28, 2006
918
919
920
if (use_xrandr) {
XRRSetScreenConfig (SDL_Display, screen_config, SDL_Root,
saved_size_id, saved_rotation, CurrentTime);
Mar 22, 2006
Mar 22, 2006
921
922
923
}
#endif
May 28, 2006
May 28, 2006
924
925
926
XUnmapWindow (SDL_Display, FSwindow);
X11_WaitUnmapped (this, FSwindow);
XSync (SDL_Display, True); /* Flush spurious mode change events */
Apr 26, 2001
Apr 26, 2001
927
928
929
930
931
932
933
currently_fullscreen = 0;
}
/* If we get popped out of fullscreen mode for some reason, input_grab
will still have the SDL_GRAB_FULLSCREEN flag set, since this is only
temporary. In this case, release the grab unless the input has been
explicitly grabbed.
*/
May 28, 2006
May 28, 2006
934
935
X11_GrabInputNoLock (this,
SDL_CurrentWindow.input_grab & ~SDL_GRAB_FULLSCREEN);
Jul 7, 2001
Jul 7, 2001
936
937
938
/* We may need to refresh the screen at this point (no backing store)
We also don't get an event, which is why we explicitly refresh. */
May 28, 2006
May 28, 2006
939
940
941
if (SDL_VideoSurface) {
if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
SDL_PrivateExpose ();
Jul 7, 2001
Jul 7, 2001
942
} else {
May 28, 2006
May 28, 2006
943
X11_RefreshDisplay (this);
Jul 7, 2001
Jul 7, 2001
944
945
946
}
}
May 28, 2006
May 28, 2006
947
return (0);
Apr 26, 2001
Apr 26, 2001
948
}
May 28, 2006
May 28, 2006
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
Uint32
X11_VisualToFormat (const Visual * visual, int depth, int bpp)
{
Uint32 Rmask = visual->red_mask;
Uint32 Gmask = visual->green_mask;
Uint32 Bmask = visual->blue_mask;
Uint32 Amask;
if (depth == 32) {
Amask = (0xFFFFFFFF & ~(Rmask | Gmask | Bmask));
} else {
Amask = 0;
}
return (SDL_MasksToPixelFormatEnum (bpp, Rmask, Gmask, Bmask, Amask));
}
/* vi: set ts=4 sw=4 expandtab: */