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

Latest commit

 

History

History
965 lines (848 loc) · 28.6 KB

SDL_x11modes.c

File metadata and controls

965 lines (848 loc) · 28.6 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
#if SDL_VIDEO_DRIVER_X11_VIDMODE
int
May 29, 2006
May 29, 2006
42
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 29, 2006
May 29, 2006
51
52
Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr,
SDL_NAME(XF86VidModeModeInfo) * info)
Apr 26, 2001
Apr 26, 2001
53
{
May 29, 2006
May 29, 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
static void
May 29, 2006
May 29, 2006
64
save_mode(_THIS)
Apr 26, 2001
Apr 26, 2001
65
{
May 29, 2006
May 29, 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
static void
May 29, 2006
May 29, 2006
75
restore_mode(_THIS)
Apr 26, 2001
Apr 26, 2001
76
{
May 29, 2006
May 29, 2006
77
SDL_NAME(XF86VidModeModeLine) mode;
Apr 26, 2001
Apr 26, 2001
78
79
int unused;
May 29, 2006
May 29, 2006
80
if (SDL_NAME(XF86VidModeGetModeLine)
May 28, 2006
May 28, 2006
81
82
83
(SDL_Display, SDL_Screen, &unused, &mode)) {
if ((saved_mode.hdisplay != mode.hdisplay) ||
(saved_mode.vdisplay != mode.vdisplay)) {
May 29, 2006
May 29, 2006
84
85
SDL_NAME(XF86VidModeSwitchToMode) (SDL_Display, SDL_Screen,
&saved_mode);
Apr 26, 2001
Apr 26, 2001
86
87
}
}
May 28, 2006
May 28, 2006
88
if ((saved_view.x != 0) || (saved_view.y != 0)) {
May 29, 2006
May 29, 2006
89
90
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 29, 2006
May 29, 2006
95
static void get_real_resolution(_THIS, int *w, int *h);
May 28, 2006
May 28, 2006
96
97
static void
May 29, 2006
May 29, 2006
98
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
mode.format = 0;
mode.w = width;
mode.h = height;
mode.refresh_rate = 0;
May 29, 2006
May 29, 2006
106
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
if (use_vidmode) {
May 29, 2006
May 29, 2006
110
111
112
SDL_NAME(XF86VidModeModeLine) vmode;
SDL_NAME(XF86VidModeModeInfo) vinfo;
SDL_NAME(XF86VidModeModeInfo) ** modes;
May 28, 2006
May 28, 2006
113
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 29, 2006
May 29, 2006
117
if (SDL_NAME(XF86VidModeGetModeLine)
May 28, 2006
May 28, 2006
118
(SDL_Display, SDL_Screen, &dotclock, &vmode)
May 29, 2006
May 29, 2006
119
120
121
&& SDL_NAME(XF86VidModeGetAllModeLines) (SDL_Display,
SDL_Screen, &nmodes,
&modes)) {
May 28, 2006
May 28, 2006
122
vinfo.dotclock = dotclock;
May 29, 2006
May 29, 2006
123
SDL_memcpy(&vinfo.hdisplay, &vmode, sizeof(vmode));
May 28, 2006
May 28, 2006
124
125
126
127
for (i = 0; i < nmodes; i++) {
if ((modes[i]->hdisplay == mode.w) &&
(modes[i]->vdisplay == mode.h) &&
May 29, 2006
May 29, 2006
128
(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
if (best >= 0 &&
((modes[best]->hdisplay != vmode.hdisplay) ||
(modes[best]->vdisplay != vmode.vdisplay) ||
May 29, 2006
May 29, 2006
136
137
(vidmode_refreshrate(modes[best]) !=
vidmode_refreshrate(&vinfo)))) {
May 17, 2006
May 17, 2006
138
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
139
140
141
printf("Best Mode %d: %d x %d @ %d\n", best,
modes[best]->hdisplay, modes[best]->vdisplay,
vidmode_refreshrate(modes[best]));
May 17, 2006
May 17, 2006
142
#endif
May 29, 2006
May 29, 2006
143
144
SDL_NAME(XF86VidModeSwitchToMode) (SDL_Display,
SDL_Screen, modes[best]);
Apr 26, 2001
Apr 26, 2001
145
}
May 29, 2006
May 29, 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
/* check current mode so we can avoid uneccessary mode changes */
May 29, 2006
May 29, 2006
158
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 29, 2006
May 29, 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 29, 2006
May 29, 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 29, 2006
May 29, 2006
178
sizes = XRRConfigSizes(screen_config, &nsizes);
May 28, 2006
May 28, 2006
179
180
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 29, 2006
May 29, 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 29, 2006
May 29, 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 29, 2006
May 29, 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
static void
May 29, 2006
May 29, 2006
216
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 29, 2006
May 29, 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 29, 2006
May 29, 2006
228
fprintf(stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h);
Nov 22, 2001
Nov 22, 2001
229
#endif
May 29, 2006
May 29, 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
if (use_vidmode) {
May 29, 2006
May 29, 2006
237
SDL_NAME(XF86VidModeModeLine) mode;
May 17, 2006
May 17, 2006
238
239
int unused;
May 29, 2006
May 29, 2006
240
if (SDL_NAME(XF86VidModeGetModeLine)
May 28, 2006
May 28, 2006
241
(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 29, 2006
May 29, 2006
254
sizes = XRRConfigSizes(screen_config, &nsizes);
May 28, 2006
May 28, 2006
255
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
cur_size =
May 29, 2006
May 29, 2006
260
XRRConfigCurrentConfiguration(screen_config, &cur_rotation);
May 28, 2006
May 28, 2006
261
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 29, 2006
May 29, 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 29, 2006
May 29, 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
void
May 29, 2006
May 29, 2006
288
X11_WaitMapped(_THIS, Window win)
Apr 26, 2001
Apr 26, 2001
289
290
291
{
XEvent event;
do {
May 29, 2006
May 29, 2006
292
XMaskEvent(SDL_Display, StructureNotifyMask, &event);
May 28, 2006
May 28, 2006
293
294
}
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
void
May 29, 2006
May 29, 2006
299
X11_WaitUnmapped(_THIS, Window win)
Apr 26, 2001
Apr 26, 2001
300
301
302
{
XEvent event;
do {
May 29, 2006
May 29, 2006
303
XMaskEvent(SDL_Display, StructureNotifyMask, &event);
May 28, 2006
May 28, 2006
304
305
}
while ((event.type != UnmapNotify) || (event.xunmap.event != win));
Apr 26, 2001
Apr 26, 2001
306
307
}
May 28, 2006
May 28, 2006
308
static void
May 29, 2006
May 29, 2006
309
move_cursor_to(_THIS, int x, int y)
Apr 26, 2001
Apr 26, 2001
310
{
May 29, 2006
May 29, 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
static int
May 29, 2006
May 29, 2006
315
add_visual(_THIS, int depth, int class)
Apr 26, 2001
Apr 26, 2001
316
317
{
XVisualInfo vi;
May 29, 2006
May 29, 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
static int
May 29, 2006
May 29, 2006
327
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
if (visual_id) {
May 29, 2006
May 29, 2006
333
334
335
SDL_memset(&template, 0, (sizeof template));
template.visualid = SDL_strtol(visual_id, NULL, 0);
vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
May 28, 2006
May 28, 2006
336
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 29, 2006
May 29, 2006
341
XFree(vi);
May 28, 2006
May 28, 2006
342
343
344
345
346
347
}
}
return (this->hidden->nvisuals);
}
int
May 29, 2006
May 29, 2006
348
X11_GetVisuals(_THIS)
May 28, 2006
May 28, 2006
349
350
351
352
353
354
355
356
357
358
359
360
{
/* 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 */
May 29, 2006
May 29, 2006
361
if (SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) {
May 28, 2006
May 28, 2006
362
363
364
use_directcolor = 0;
}
this->hidden->nvisuals = 0;
May 29, 2006
May 29, 2006
365
366
if (!add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID"))) {
for (i = 0; i < SDL_arraysize(depth_list); ++i) {
May 28, 2006
May 28, 2006
367
368
if (depth_list[i] > 8) {
if (use_directcolor) {
May 29, 2006
May 29, 2006
369
add_visual(this, depth_list[i], DirectColor);
May 28, 2006
May 28, 2006
370
}
May 29, 2006
May 29, 2006
371
add_visual(this, depth_list[i], TrueColor);
May 28, 2006
May 28, 2006
372
} else {
May 29, 2006
May 29, 2006
373
374
add_visual(this, depth_list[i], PseudoColor);
add_visual(this, depth_list[i], StaticColor);
May 28, 2006
May 28, 2006
375
}
Apr 26, 2001
Apr 26, 2001
376
377
}
}
May 28, 2006
May 28, 2006
378
if (this->hidden->nvisuals == 0) {
May 29, 2006
May 29, 2006
379
SDL_SetError("Found no sufficiently capable X11 visuals");
May 28, 2006
May 28, 2006
380
381
382
383
return -1;
}
/* look up the pixel quantum for each depth */
May 29, 2006
May 29, 2006
384
pf = XListPixmapFormats(SDL_Display, &np);
May 28, 2006
May 28, 2006
385
386
387
388
389
390
391
392
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;
}
May 29, 2006
May 29, 2006
393
XFree(pf);
May 28, 2006
May 28, 2006
394
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
static int
May 29, 2006
May 29, 2006
402
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 29, 2006
May 29, 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 29, 2006
May 29, 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
static int
May 29, 2006
May 29, 2006
426
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 29, 2006
May 29, 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 29, 2006
May 29, 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
static int
May 29, 2006
May 29, 2006
458
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 29, 2006
May 29, 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 29, 2006
May 29, 2006
474
if (SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0) {
May 17, 2006
May 17, 2006
475
476
FILE *metro_fp;
May 29, 2006
May 29, 2006
477
metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
May 28, 2006
May 28, 2006
478
if (metro_fp != NULL) {
May 17, 2006
May 17, 2006
479
int major, minor, patch, version;
May 28, 2006
May 28, 2006
480
481
482
major = 0;
minor = 0;
patch = 0;
May 29, 2006
May 29, 2006
483
484
fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
fclose(metro_fp);
May 28, 2006
May 28, 2006
485
486
version = major * 100 + minor * 10 + patch;
if (version < 431) {
May 17, 2006
May 17, 2006
487
488
489
490
491
492
493
return 0;
}
}
}
/* Query the extension version */
vm_error = -1;
May 29, 2006
May 29, 2006
494
if (!SDL_NAME(XF86VidModeQueryExtension)
May 28, 2006
May 28, 2006
495
(SDL_Display, &vm_event, &vm_error)
May 29, 2006
May 29, 2006
496
|| !SDL_NAME(XF86VidModeQueryVersion) (SDL_Display, major, minor)) {
May 17, 2006
May 17, 2006
497
498
499
500
501
502
503
return 0;
}
return 1;
}
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
#if SDL_VIDEO_DRIVER_X11_XME
May 28, 2006
May 28, 2006
504
static int
May 29, 2006
May 29, 2006
505
CheckXME(_THIS, int *major, int *minor)
May 17, 2006
May 17, 2006
506
507
508
509
510
511
512
{
const char *env;
/* Default the extension not available */
*major = *minor = 0;
/* Allow environment override */
May 29, 2006
May 29, 2006
513
514
env = getenv("SDL_VIDEO_X11_VIDMODE");
if (env && !SDL_atoi(env)) {
May 17, 2006
May 17, 2006
515
516
return 0;
}
May 28, 2006
May 28, 2006
517
May 17, 2006
May 17, 2006
518
/* Query the extension version */
May 29, 2006
May 29, 2006
519
if (!XiGMiscQueryVersion(SDL_Display, major, minor)) {
May 17, 2006
May 17, 2006
520
521
522
523
524
525
return 0;
}
return 1;
}
#endif /* SDL_VIDEO_DRIVER_X11_XME */
May 28, 2006
May 28, 2006
526
int
May 29, 2006
May 29, 2006
527
X11_GetVideoModes(_THIS)
Apr 26, 2001
Apr 26, 2001
528
{
May 17, 2006
May 17, 2006
529
530
531
532
533
534
535
#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
536
537
int nrates;
short *rates;
May 17, 2006
May 17, 2006
538
#endif
Feb 16, 2006
Feb 16, 2006
539
#if SDL_VIDEO_DRIVER_X11_VIDMODE
Apr 26, 2001
Apr 26, 2001
540
541
int vm_major, vm_minor;
int nmodes;
May 29, 2006
May 29, 2006
542
SDL_NAME(XF86VidModeModeInfo) ** modes;
Nov 22, 2001
Nov 22, 2001
543
#endif
Feb 16, 2006
Feb 16, 2006
544
#if SDL_VIDEO_DRIVER_X11_XME
Nov 22, 2001
Nov 22, 2001
545
546
547
int xme_major, xme_minor;
int ractive, nummodes;
XiGMiscResolutionInfo *modelist;
Apr 26, 2001
Apr 26, 2001
548
#endif
May 28, 2006
May 28, 2006
549
int i;
Nov 4, 2001
Nov 4, 2001
550
551
int screen_w;
int screen_h;
May 28, 2006
May 28, 2006
552
SDL_DisplayMode mode;
Apr 26, 2001
Apr 26, 2001
553
May 17, 2006
May 17, 2006
554
use_xinerama = 0;
Mar 22, 2006
Mar 22, 2006
555
use_xrandr = 0;
May 17, 2006
May 17, 2006
556
557
use_vidmode = 0;
use_xme = 0;
May 29, 2006
May 29, 2006
558
559
screen_w = DisplayWidth(SDL_Display, SDL_Screen);
screen_h = DisplayHeight(SDL_Display, SDL_Screen);
May 28, 2006
May 28, 2006
560
561
562
563
564
mode.format = this->displays[this->current_display].desktop_mode.format;
mode.w = screen_w;
mode.h = screen_h;
mode.refresh_rate = 0;
May 29, 2006
May 29, 2006
565
SDL_AddDisplayMode(0, &mode);
Nov 4, 2001
Nov 4, 2001
566
May 17, 2006
May 17, 2006
567
568
#if SDL_VIDEO_DRIVER_X11_XINERAMA
/* Query Xinerama extention */
May 29, 2006
May 29, 2006
569
if (CheckXinerama(this, &xinerama_major, &xinerama_minor)) {
May 17, 2006
May 17, 2006
570
571
572
int screens;
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
573
printf("X11 detected Xinerama:\n");
May 17, 2006
May 17, 2006
574
#endif
May 29, 2006
May 29, 2006
575
xinerama = SDL_NAME(XineramaQueryScreens) (SDL_Display, &screens);
May 28, 2006
May 28, 2006
576
for (i = 0; i < screens; i++) {
May 17, 2006
May 17, 2006
577
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
578
579
580
581
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
582
#endif
May 28, 2006
May 28, 2006
583
if (xinerama[i].screen_number != 0) {
May 29, 2006
May 29, 2006
584
SDL_AddVideoDisplay(&mode);
May 17, 2006
May 17, 2006
585
}
May 28, 2006
May 28, 2006
586
587
mode.w = xinerama[i].width;
mode.h = xinerama[i].height;
May 29, 2006
May 29, 2006
588
SDL_AddDisplayMode(xinerama[i].screen_number, &mode);
May 17, 2006
May 17, 2006
589
}
May 28, 2006
May 28, 2006
590
use_xinerama = 1;
May 17, 2006
May 17, 2006
591
592
593
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
Mar 22, 2006
Mar 22, 2006
594
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 17, 2006
May 17, 2006
595
/* XRandR */
Mar 22, 2006
Mar 22, 2006
596
/* require at least XRandR v1.0 (arbitrary) */
May 29, 2006
May 29, 2006
597
if (CheckXRandR(this, &xrandr_major, &xrandr_minor)
May 28, 2006
May 28, 2006
598
&& (xrandr_major >= 1)) {
May 17, 2006
May 17, 2006
599
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
600
601
fprintf(stderr, "XRANDR: XRRQueryVersion: V%d.%d\n",
xrandr_major, xrandr_minor);
Mar 22, 2006
Mar 22, 2006
602
603
604
605
#endif
/* save the screen configuration since we must reference it
each time we toggle modes.
May 28, 2006
May 28, 2006
606
*/
May 29, 2006
May 29, 2006
607
screen_config = XRRGetScreenInfo(SDL_Display, SDL_Root);
Mar 22, 2006
Mar 22, 2006
608
609
/* retrieve the list of resolution */
May 29, 2006
May 29, 2006
610
sizes = XRRConfigSizes(screen_config, &nsizes);
Mar 22, 2006
Mar 22, 2006
611
if (nsizes > 0) {
May 28, 2006
May 28, 2006
612
613
614
615
for (i = 0; i < nsizes; i++) {
mode.w = sizes[i].width;
mode.h = sizes[i].height;
May 29, 2006
May 29, 2006
616
rates = XRRConfigRates(screen_config, i, &nrates);
May 28, 2006
May 28, 2006
617
618
if (nrates == 0) {
mode.refresh_rate = 0;
May 29, 2006
May 29, 2006
619
SDL_AddDisplayMode(0, &mode);
May 28, 2006
May 28, 2006
620
621
622
623
} else {
int j;
for (j = 0; j < nrates; ++j) {
mode.refresh_rate = rates[j];
May 29, 2006
May 29, 2006
624
SDL_AddDisplayMode(0, &mode);
May 28, 2006
May 28, 2006
625
}
May 17, 2006
May 17, 2006
626
}
Mar 22, 2006
Mar 22, 2006
627
}
May 17, 2006
May 17, 2006
628
Mar 22, 2006
Mar 22, 2006
629
use_xrandr = xrandr_major * 100 + xrandr_minor;
May 28, 2006
May 28, 2006
630
saved_size_id =
May 29, 2006
May 29, 2006
631
XRRConfigCurrentConfiguration(screen_config, &saved_rotation);
Mar 22, 2006
Mar 22, 2006
632
633
634
635
}
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Feb 16, 2006
Feb 16, 2006
636
#if SDL_VIDEO_DRIVER_X11_VIDMODE
May 17, 2006
May 17, 2006
637
/* XVidMode */
May 28, 2006
May 28, 2006
638
if (!use_xrandr &&
May 29, 2006
May 29, 2006
639
640
641
CheckVidMode(this, &vm_major, &vm_minor) &&
SDL_NAME(XF86VidModeGetAllModeLines) (SDL_Display, SDL_Screen,
&nmodes, &modes)) {
May 17, 2006
May 17, 2006
642
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
643
printf("VidMode modes: (unsorted)\n");
May 28, 2006
May 28, 2006
644
for (i = 0; i < nmodes; ++i) {
May 29, 2006
May 29, 2006
645
646
647
printf("Mode %d: %d x %d @ %d\n", i,
modes[i]->hdisplay, modes[i]->vdisplay,
vidmode_refreshrate(modes[i]));
Jun 28, 2003
Jun 28, 2003
648
649
}
#endif
May 28, 2006
May 28, 2006
650
651
652
for (i = 0; i < nmodes; ++i) {
mode.w = modes[i]->hdisplay;
mode.h = modes[i]->vdisplay;
May 29, 2006
May 29, 2006
653
654
mode.refresh_rate = vidmode_refreshrate(modes[i]);
SDL_AddDisplayMode(0, &mode);
Apr 26, 2001
Apr 26, 2001
655
}
May 29, 2006
May 29, 2006
656
XFree(modes);
Apr 26, 2001
Apr 26, 2001
657
Jul 11, 2001
Jul 11, 2001
658
use_vidmode = vm_major * 100 + vm_minor;
May 29, 2006
May 29, 2006
659
save_mode(this);
Apr 26, 2001
Apr 26, 2001
660
}
Feb 16, 2006
Feb 16, 2006
661
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
Apr 26, 2001
Apr 26, 2001
662
Feb 16, 2006
Feb 16, 2006
663
#if SDL_VIDEO_DRIVER_X11_XME
May 17, 2006
May 17, 2006
664
/* XiG */
Nov 22, 2001
Nov 22, 2001
665
modelist = NULL;
May 17, 2006
May 17, 2006
666
/* first lets make sure we have the extension, and it's at least v2.0 */
May 29, 2006
May 29, 2006
667
668
669
if (CheckXME(this, &xme_major, &xme_minor) && xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display, SDL_Screen, 0, /* view */
&ractive,
&modelist))
May 28, 2006
May 28, 2006
670
> 1) { /* then we actually have some */
May 17, 2006
May 17, 2006
671
672
673
/* We get the list already sorted in descending order.
We'll copy it in reverse order so SDL is happy */
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
674
675
fprintf(stderr, "XME: nummodes = %d, active mode = %d\n",
nummodes, ractive);
Nov 22, 2001
Nov 22, 2001
676
#endif
May 28, 2006
May 28, 2006
677
678
mode.refresh_rate = 0;
for (i = 0; i < nummodes; ++i) {
May 17, 2006
May 17, 2006
679
#ifdef X11MODES_DEBUG
May 29, 2006
May 29, 2006
680
681
fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n",
i, modelist[i].width, modelist[i].height);
Nov 22, 2001
Nov 22, 2001
682
#endif
May 28, 2006
May 28, 2006
683
684
mode.w = modelist[i].width;
mode.h = modelist[i].height;
May 29, 2006
May 29, 2006
685
SDL_AddDisplayMode(0, &mode);
Sep 30, 2002
Sep 30, 2002
686
}
May 17, 2006
May 17, 2006
687
688
use_xme = xme_major * 100 + xme_minor;
May 28, 2006
May 28, 2006
689
saved_res = modelist[ractive]; /* save the current resolution */
Nov 22, 2001
Nov 22, 2001
690
}
May 28, 2006
May 28, 2006
691
if (modelist) {
May 29, 2006
May 29, 2006
692
XFree(modelist);
Nov 22, 2001
Nov 22, 2001
693
}
Feb 16, 2006
Feb 16, 2006
694
#endif /* SDL_VIDEO_DRIVER_X11_XME */
Nov 22, 2001
Nov 22, 2001
695
May 17, 2006
May 17, 2006
696
#ifdef X11MODES_DEBUG
May 28, 2006
May 28, 2006
697
if (use_xinerama) {
May 29, 2006
May 29, 2006
698
printf("Xinerama is enabled\n");
Apr 26, 2001
Apr 26, 2001
699
700
}
May 28, 2006
May 28, 2006
701
if (use_xrandr) {
May 29, 2006
May 29, 2006
702
printf("XRandR is enabled\n");
Apr 26, 2001
Apr 26, 2001
703
}
Nov 22, 2001
Nov 22, 2001
704
May 28, 2006
May 28, 2006
705
if (use_vidmode) {
May 29, 2006
May 29, 2006
706
printf("VidMode is enabled\n");
May 17, 2006
May 17, 2006
707
}
Nov 22, 2001
Nov 22, 2001
708
May 28, 2006
May 28, 2006
709
if (use_xme) {
May 29, 2006
May 29, 2006
710
printf("Xi Graphics XME fullscreen is enabled\n");
Apr 26, 2001
Apr 26, 2001
711
}
May 17, 2006
May 17, 2006
712
#endif /* X11MODES_DEBUG */
Nov 3, 2001
Nov 3, 2001
713
Apr 26, 2001
Apr 26, 2001
714
715
716
return 0;
}
May 28, 2006
May 28, 2006
717
void
May 29, 2006
May 29, 2006
718
X11_FreeVideoModes(_THIS)
Apr 26, 2001
Apr 26, 2001
719
{
Mar 22, 2006
Mar 22, 2006
720
721
#if SDL_VIDEO_DRIVER_X11_XRANDR
/* Free the Xrandr screen configuration */
May 28, 2006
May 28, 2006
722
if (screen_config) {
May 29, 2006
May 29, 2006
723
XRRFreeScreenConfigInfo(screen_config);
Mar 22, 2006
Mar 22, 2006
724
725
726
screen_config = NULL;
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Apr 26, 2001
Apr 26, 2001
727
728
}
May 28, 2006
May 28, 2006
729
int
May 29, 2006
May 29, 2006
730
X11_ResizeFullScreen(_THIS)
Apr 26, 2001
Apr 26, 2001
731
{
May 17, 2006
May 17, 2006
732
int x = 0, y = 0;
Apr 26, 2001
Apr 26, 2001
733
int real_w, real_h;
Nov 4, 2001
Nov 4, 2001
734
735
736
int screen_w;
int screen_h;
May 29, 2006
May 29, 2006
737
738
screen_w = DisplayWidth(SDL_Display, SDL_Screen);
screen_h = DisplayHeight(SDL_Display, SDL_Screen);
Apr 26, 2001
Apr 26, 2001
739
Jun 20, 2006
Jun 20, 2006
740
#if SDL_VIDEO_DRIVER_X11_XINERAMA
May 28, 2006
May 28, 2006
741
742
743
744
745
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
746
}
Jun 20, 2006
Jun 20, 2006
747
748
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
May 28, 2006
May 28, 2006
749
if (currently_fullscreen) {
Apr 26, 2001
Apr 26, 2001
750
/* Switch resolution and cover it with the FSwindow */
May 29, 2006
May 29, 2006
751
752
753
754
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);
May 28, 2006
May 28, 2006
755
if (window_w > real_w) {
May 29, 2006
May 29, 2006
756
real_w = MAX(real_w, screen_w);
Nov 4, 2001
Nov 4, 2001
757
}
May 28, 2006
May 28, 2006
758
if (window_h > real_h) {
May 29, 2006
May 29, 2006
759
real_h = MAX(real_h, screen_h);
Nov 4, 2001
Nov 4, 2001
760
}
May 29, 2006
May 29, 2006
761
762
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
763
764
/* Center and reparent the drawing window */
May 28, 2006
May 28, 2006
765
766
x = (real_w - window_w) / 2;
y = (real_h - window_h) / 2;
May 29, 2006
May 29, 2006
767
XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);
Apr 26, 2001
Apr 26, 2001
768
/* FIXME: move the mouse to the old relative location */
May 29, 2006
May 29, 2006
769
XSync(SDL_Display, True); /* Flush spurious mode change events */
Apr 26, 2001
Apr 26, 2001
770
}
May 28, 2006
May 28, 2006
771
return (1);
Apr 26, 2001
Apr 26, 2001
772
773
}
May 28, 2006
May 28, 2006
774
void
May 29, 2006
May 29, 2006
775
X11_QueueEnterFullScreen(_THIS)
Apr 26, 2001
Apr 26, 2001
776
777
{
switch_waiting = 0x01 | SDL_FULLSCREEN;
May 29, 2006
May 29, 2006
778
switch_time = SDL_GetTicks() + 1500;
May 28, 2006
May 28, 2006
779
#if 0 /* This causes a BadMatch error if the window is iconified (not needed) */
May 29, 2006
May 29, 2006
780
XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime);
Apr 26, 2001
Apr 26, 2001
781
782
783
#endif
}
May 28, 2006
May 28, 2006
784
int
May 29, 2006
May 29, 2006
785
X11_EnterFullScreen(_THIS)
Apr 26, 2001
Apr 26, 2001
786
787
788
789
790
791
{
int okay;
#if 0
Window tmpwin, *windows;
int i, nwindows;
#endif
May 17, 2006
May 17, 2006
792
int x = 0, y = 0;
Jul 9, 2001
Jul 9, 2001
793
int real_w, real_h;
Nov 4, 2001
Nov 4, 2001
794
795
int screen_w;
int screen_h;
Apr 26, 2001
Apr 26, 2001
796
797
okay = 1;
May 28, 2006
May 28, 2006
798
799
if (currently_fullscreen) {
return (okay);
Jul 9, 2001
Jul 9, 2001
800
}
Apr 26, 2001
Apr 26, 2001
801
Jul 9, 2001
Jul 9, 2001
802
/* Ungrab the input so that we can move the mouse around */
May 29, 2006
May 29, 2006
803
X11_GrabInputNoLock(this, SDL_GRAB_OFF);
Jul 9, 2001
Jul 9, 2001
804
Jun 20, 2006
Jun 20, 2006
805
#if SDL_VIDEO_DRIVER_X11_XINERAMA
May 28, 2006
May 28, 2006
806
807
808
809
810
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
811
}
Jun 20, 2006
Jun 20, 2006
812
813
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
Jul 9, 2001
Jul 9, 2001
814
/* Map the fullscreen window to blank the screen */
May 29, 2006
May 29, 2006
815
816
817
screen_w = DisplayWidth(SDL_Display, SDL_Screen);
screen_h = DisplayHeight(SDL_Display, SDL_Screen);
get_real_resolution(this, &real_w, &real_h);
May 28, 2006
May 28, 2006
818
if (window_w > real_w) {
May 29, 2006
May 29, 2006
819
real_w = MAX(real_w, screen_w);
Nov 4, 2001
Nov 4, 2001
820
}
May 28, 2006
May 28, 2006
821
if (window_h > real_h) {
May 29, 2006
May 29, 2006
822
real_h = MAX(real_h, screen_h);
Nov 4, 2001
Nov 4, 2001
823
}
May 29, 2006
May 29, 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 29, 2006
May 29, 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
if (windows[nwindows - 1] != FSwindow) {
tmpwin = windows[nwindows - 1];
for (i = 0; i < nwindows; ++i) {
if (windows[i] == FSwindow) {
May 29, 2006
May 29, 2006
837
838
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
windows[nwindows - 1] = FSwindow;
May 29, 2006
May 29, 2006
843
844
XRestackWindows(SDL_Display, windows, nwindows);
XSync(SDL_Display, False);
Apr 26, 2001
Apr 26, 2001
845
}
May 29, 2006
May 29, 2006
846
XFree(windows);
Jul 9, 2001
Jul 9, 2001
847
}
Apr 26, 2001
Apr 26, 2001
848
#else
May 29, 2006
May 29, 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
if (use_vidmode) {
May 29, 2006
May 29, 2006
855
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 29, 2006
May 29, 2006
861
okay = X11_ResizeFullScreen(this);
May 28, 2006
May 28, 2006
862
if (!okay) {
May 29, 2006
May 29, 2006
863
X11_LeaveFullScreen(this);
Jul 9, 2001
Jul 9, 2001
864
865
}
/* Set the colormap */
May 28, 2006
May 28, 2006
866
if (SDL_XColorMap) {
May 29, 2006
May 29, 2006
867
XInstallColormap(SDL_Display, SDL_XColorMap);
Apr 26, 2001
Apr 26, 2001
868
}
May 28, 2006
May 28, 2006
869
if (okay) {
May 29, 2006
May 29, 2006
870
871
872
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
if (SDL_VideoSurface) {
if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
May 29, 2006
May 29, 2006
879
SDL_PrivateExpose();
Jul 7, 2001
Jul 7, 2001
880
} else {
May 29, 2006
May 29, 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
int
May 29, 2006
May 29, 2006
889
X11_LeaveFullScreen(_THIS)
Apr 26, 2001
Apr 26, 2001
890
{
May 28, 2006
May 28, 2006
891
if (currently_fullscreen) {
May 29, 2006
May 29, 2006
892
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
if (use_vidmode) {
May 29, 2006
May 29, 2006
895
896
897
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 29, 2006
May 29, 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 29, 2006
May 29, 2006
909
910
911
XiGMiscChangeResolution(SDL_Display, SDL_Screen, 0, /* view */
saved_res.width, saved_res.height, 0);
XSync(SDL_Display, False);
Sep 30, 2002
Sep 30, 2002
912
913
}
}
Nov 22, 2001
Nov 22, 2001
914
915
#endif
Mar 22, 2006
Mar 22, 2006
916
#if SDL_VIDEO_DRIVER_X11_XRANDR
May 28, 2006
May 28, 2006
917
if (use_xrandr) {
May 29, 2006
May 29, 2006
918
919
XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root,
saved_size_id, saved_rotation, CurrentTime);
Mar 22, 2006
Mar 22, 2006
920
921
922
}
#endif
May 29, 2006
May 29, 2006
923
924
925
XUnmapWindow(SDL_Display, FSwindow);
X11_WaitUnmapped(this, FSwindow);
XSync(SDL_Display, True); /* Flush spurious mode change events */
Apr 26, 2001
Apr 26, 2001
926
927
928
929
930
931
932
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 29, 2006
May 29, 2006
933
934
X11_GrabInputNoLock(this,
SDL_CurrentWindow.input_grab & ~SDL_GRAB_FULLSCREEN);
Jul 7, 2001
Jul 7, 2001
935
936
937
/* 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
938
939
if (SDL_VideoSurface) {
if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
May 29, 2006
May 29, 2006
940
SDL_PrivateExpose();
Jul 7, 2001
Jul 7, 2001
941
} else {
May 29, 2006
May 29, 2006
942
X11_RefreshDisplay(this);
Jul 7, 2001
Jul 7, 2001
943
944
945
}
}
May 28, 2006
May 28, 2006
946
return (0);
Apr 26, 2001
Apr 26, 2001
947
}
May 28, 2006
May 28, 2006
948
949
Uint32
May 29, 2006
May 29, 2006
950
X11_VisualToFormat(const Visual * visual, int depth, int bpp)
May 28, 2006
May 28, 2006
951
952
953
954
955
956
957
958
959
960
961
{
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;
}
May 29, 2006
May 29, 2006
962
return (SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask));
May 28, 2006
May 28, 2006
963
964
965
}
/* vi: set ts=4 sw=4 expandtab: */