annotate src/video/x11/SDL_x11modes.c @ 1944:91f41fc124a7

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