Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11modes.c @ 1882:339d733e3699
Fixed bug #258
Account for the menu height in AdjustWindowRectEx()
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 24 Jun 2006 04:30:01 +0000 |
parents | 0e44c6f90b95 |
children | c121d94672cb db4007f17bc8 |
rev | line source |
---|---|
0 | 1 /* |
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 | 4 |
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 | 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 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
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 | 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 | 18 |
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 | 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 | 23 |
24 /* Utilities for getting and setting the X display mode */ | |
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 | 27 |
28 #include "SDL_timer.h" | |
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 | 31 #include "SDL_x11video.h" |
32 #include "SDL_x11wm_c.h" | |
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 | 35 |
1768 | 36 /*#define X11MODES_DEBUG*/ |
37 | |
1765 | 38 #define MAX(a, b) (a > b ? a : b) |
0 | 39 |
1765 | 40 #if SDL_VIDEO_DRIVER_X11_XRANDR |
41 static int cmpmodelist(const void *va, const void *vb) | |
42 { | |
43 const SDL_Rect *a = *(const SDL_Rect **)va; | |
44 const SDL_Rect *b = *(const SDL_Rect **)vb; | |
45 if ( a->w == b->w ) | |
46 return b->h - a->h; | |
47 else | |
48 return b->w - a->w; | |
49 } | |
50 #endif | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
51 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
52 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
53 Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info) |
0 | 54 { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
55 SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock); |
1196
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
56 return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, (int*)&info->dotclock, l); |
0 | 57 } |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
58 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
0 | 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 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 61 static void save_mode(_THIS) |
62 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
63 SDL_memset(&saved_mode, 0, sizeof(saved_mode)); |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
64 SDL_NAME(XF86VidModeGetModeInfo)(SDL_Display,SDL_Screen,&saved_mode); |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
65 SDL_NAME(XF86VidModeGetViewPort)(SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y); |
0 | 66 } |
67 #endif | |
68 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
69 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 70 static void restore_mode(_THIS) |
71 { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
72 SDL_NAME(XF86VidModeModeLine) mode; |
0 | 73 int unused; |
74 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
75 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
0 | 76 if ( (saved_mode.hdisplay != mode.hdisplay) || |
77 (saved_mode.vdisplay != mode.vdisplay) ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
78 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, &saved_mode); |
0 | 79 } |
80 } | |
81 if ( (saved_view.x != 0) || (saved_view.y != 0) ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
82 SDL_NAME(XF86VidModeSetViewPort)(SDL_Display, SDL_Screen, saved_view.x, saved_view.y); |
0 | 83 } |
84 } | |
85 #endif | |
86 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
87 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 88 static int cmpmodes(const void *va, const void *vb) |
89 { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
90 const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
91 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; |
966
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
92 if ( a->hdisplay == b->hdisplay ) |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
93 return b->vdisplay - a->vdisplay; |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
94 else |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
95 return b->hdisplay - a->hdisplay; |
0 | 96 } |
97 #endif | |
98 | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
99 static void get_real_resolution(_THIS, int* w, int* h); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
100 |
0 | 101 static void set_best_resolution(_THIS, int width, int height) |
102 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
103 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 104 if ( use_vidmode ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
105 SDL_NAME(XF86VidModeModeLine) mode; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
106 SDL_NAME(XF86VidModeModeInfo) **modes; |
0 | 107 int i; |
108 int nmodes; | |
1768 | 109 int best = -1; |
0 | 110 |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
111 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) && |
1768 | 112 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes) ) { |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
113 for ( i = 0; i < nmodes ; i++ ) { |
604
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
114 if ( (modes[i]->hdisplay == width) && |
1768 | 115 (modes[i]->vdisplay == height) ) { |
116 best = i; | |
117 break; | |
118 } | |
119 if ( modes[i]->hdisplay >= width && | |
120 modes[i]->vdisplay >= height ) { | |
121 if ( best < 0 || | |
122 (modes[i]->hdisplay < modes[best]->hdisplay && | |
123 modes[i]->vdisplay <= modes[best]->vdisplay) || | |
124 (modes[i]->vdisplay < modes[best]->vdisplay && | |
125 modes[i]->hdisplay <= modes[best]->hdisplay) ) { | |
126 best = i; | |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
127 } |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
128 } |
0 | 129 } |
1768 | 130 if ( best >= 0 && |
131 ((modes[best]->hdisplay != mode.hdisplay) || | |
132 (modes[best]->vdisplay != mode.vdisplay)) ) { | |
133 #ifdef X11MODES_DEBUG | |
134 printf("Best Mode %d: %d x %d @ %d\n", best, | |
135 modes[best]->hdisplay, modes[best]->vdisplay, | |
136 (modes[best]->htotal && modes[best]->vtotal) ? (1000 * modes[best]->dotclock / (modes[best]->htotal * modes[best]->vtotal)) : 0 ); | |
137 #endif | |
138 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[best]); | |
0 | 139 } |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
140 XFree(modes); |
0 | 141 } |
142 } | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
143 #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
|
144 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
145 /* XiG */ |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
146 #if SDL_VIDEO_DRIVER_X11_XME |
1768 | 147 if ( use_xme && SDL_modelist ) { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
148 int i; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
149 |
1768 | 150 #ifdef X11MODES_DEBUG |
151 fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n", | |
152 width, height); | |
153 #endif | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
154 for ( i=0; SDL_modelist[i]; ++i ) { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
155 if ( (SDL_modelist[i]->w >= width) && |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
156 (SDL_modelist[i]->h >= height) ) { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
157 break; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
158 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
159 } |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
160 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
161 if ( SDL_modelist[i] ) { /* found one, lets try it */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
162 int w, h; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
163 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
164 /* 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
|
165 get_real_resolution(this, &w, &h); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
166 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
167 if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) { |
1765 | 168 #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
|
169 fprintf(stderr, "XME: set_best_resolution: " |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
170 "XiGMiscChangeResolution: %d %d\n", |
1768 | 171 SDL_modelist[i]->w, SDL_modelist[i]->h); |
172 #endif | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
173 XiGMiscChangeResolution(SDL_Display, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
174 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
175 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
176 SDL_modelist[i]->w, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 SDL_modelist[i]->h, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
178 0); |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
179 XSync(SDL_Display, False); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
180 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
181 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
182 } |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
183 #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
|
184 |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
185 #if SDL_VIDEO_DRIVER_X11_XRANDR |
1768 | 186 if ( use_xrandr && SDL_modelist ) { |
1765 | 187 #ifdef X11MODES_DEBUG |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
188 fprintf(stderr, "XRANDR: set_best_resolution(): w = %d, h = %d\n", |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
189 width, height); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
190 #endif |
1768 | 191 int i, nsizes; |
192 XRRScreenSize *sizes; | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
193 |
1768 | 194 /* find the smallest resolution that is at least as big as the user requested */ |
195 sizes = XRRConfigSizes(screen_config, &nsizes); | |
196 for ( i = (nsizes-1); i >= 0; i-- ) { | |
197 if ( (SDL_modelist[i]->w >= width) && | |
198 (SDL_modelist[i]->h >= height) ) { | |
199 break; | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
200 } |
1768 | 201 } |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
202 |
1768 | 203 if ( i >= 0 && SDL_modelist[i] ) { /* found one, lets try it */ |
204 int w, h; | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
205 |
1768 | 206 /* check current mode so we can avoid uneccessary mode changes */ |
207 get_real_resolution(this, &w, &h); | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
208 |
1768 | 209 if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) { |
210 int size_id; | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
211 |
1765 | 212 #ifdef X11MODES_DEBUG |
1768 | 213 fprintf(stderr, "XRANDR: set_best_resolution: " |
214 "XXRSetScreenConfig: %d %d\n", | |
215 SDL_modelist[i]->w, SDL_modelist[i]->h); | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
216 #endif |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
217 |
1768 | 218 /* find the matching size entry index */ |
219 for ( size_id = 0; size_id < nsizes; ++size_id ) { | |
220 if ( (sizes[size_id].width == SDL_modelist[i]->w) && | |
221 (sizes[size_id].height == SDL_modelist[i]->h) ) | |
222 break; | |
223 } | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
224 |
1768 | 225 XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root, |
226 size_id, saved_rotation, CurrentTime); | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
227 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
228 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
229 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
230 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ |
0 | 231 } |
232 | |
233 static void get_real_resolution(_THIS, int* w, int* h) | |
234 { | |
1765 | 235 #if SDL_VIDEO_DRIVER_X11_XME |
236 if ( use_xme ) { | |
237 int ractive; | |
238 XiGMiscResolutionInfo *modelist; | |
239 | |
240 XiGMiscQueryResolutions(SDL_Display, SDL_Screen, | |
241 0, /* view */ | |
242 &ractive, &modelist); | |
243 *w = modelist[ractive].width; | |
244 *h = modelist[ractive].height; | |
245 #ifdef X11MODES_DEBUG | |
246 fprintf(stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h); | |
247 #endif | |
248 XFree(modelist); | |
249 return; | |
250 } | |
251 #endif /* SDL_VIDEO_DRIVER_X11_XME */ | |
252 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
253 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 254 if ( use_vidmode ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
255 SDL_NAME(XF86VidModeModeLine) mode; |
0 | 256 int unused; |
257 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
258 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
0 | 259 *w = mode.hdisplay; |
260 *h = mode.vdisplay; | |
261 return; | |
262 } | |
263 } | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
264 #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
|
265 |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
266 #if SDL_VIDEO_DRIVER_X11_XRANDR |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
267 if ( use_xrandr ) { |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
268 int nsizes; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
269 XRRScreenSize* sizes; |
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 sizes = XRRConfigSizes(screen_config, &nsizes); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
272 if ( nsizes > 0 ) { |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
273 int cur_size; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
274 Rotation cur_rotation; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
275 |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
276 cur_size = XRRConfigCurrentConfiguration(screen_config, &cur_rotation); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
277 if ( cur_size >= 0 && cur_size < nsizes ) { |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
278 *w = sizes[cur_size].width; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
279 *h = sizes[cur_size].height; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
280 } |
1765 | 281 #ifdef X11MODES_DEBUG |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
282 fprintf(stderr, "XRANDR: get_real_resolution: w = %d h = %d\n", *w, *h); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
283 #endif |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
284 return; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
285 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
286 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
287 #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
|
288 |
1765 | 289 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
290 if ( use_xinerama ) { | |
291 *w = xinerama_info.width; | |
292 *h = xinerama_info.height; | |
293 return; | |
294 } | |
295 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ | |
296 | |
0 | 297 *w = DisplayWidth(SDL_Display, SDL_Screen); |
298 *h = DisplayHeight(SDL_Display, SDL_Screen); | |
299 } | |
300 | |
301 /* Called after mapping a window - waits until the window is mapped */ | |
302 void X11_WaitMapped(_THIS, Window win) | |
303 { | |
304 XEvent event; | |
305 do { | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
306 XMaskEvent(SDL_Display, StructureNotifyMask, &event); |
0 | 307 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); |
308 } | |
309 | |
310 /* Called after unmapping a window - waits until the window is unmapped */ | |
311 void X11_WaitUnmapped(_THIS, Window win) | |
312 { | |
313 XEvent event; | |
314 do { | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
315 XMaskEvent(SDL_Display, StructureNotifyMask, &event); |
0 | 316 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); |
317 } | |
318 | |
319 static void move_cursor_to(_THIS, int x, int y) | |
320 { | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
321 XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); |
0 | 322 } |
323 | |
324 static int add_visual(_THIS, int depth, int class) | |
325 { | |
326 XVisualInfo vi; | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
327 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
|
328 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
|
329 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
|
330 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
|
331 this->hidden->nvisuals++; |
0 | 332 } |
333 return(this->hidden->nvisuals); | |
334 } | |
335 static int add_visual_byid(_THIS, const char *visual_id) | |
336 { | |
337 XVisualInfo *vi, template; | |
338 int nvis; | |
339 | |
340 if ( visual_id ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
341 SDL_memset(&template, 0, (sizeof template)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
342 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
|
343 vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); |
0 | 344 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
|
345 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
|
346 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
|
347 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
|
348 this->hidden->nvisuals++; |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
349 XFree(vi); |
0 | 350 } |
351 } | |
352 return(this->hidden->nvisuals); | |
353 } | |
354 | |
355 /* Global for the error handler */ | |
356 int vm_event, vm_error = -1; | |
357 | |
1765 | 358 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
359 static int CheckXinerama(_THIS, int *major, int *minor) | |
360 { | |
361 const char *env; | |
362 | |
363 /* Default the extension not available */ | |
364 *major = *minor = 0; | |
365 | |
366 /* Allow environment override */ | |
367 env = getenv("SDL_VIDEO_X11_XINERAMA"); | |
368 if ( env && !SDL_atoi(env) ) { | |
369 return 0; | |
370 } | |
371 | |
372 /* Query the extension version */ | |
373 if ( !SDL_NAME(XineramaQueryExtension)(SDL_Display, major, minor) || | |
374 !SDL_NAME(XineramaIsActive)(SDL_Display) ) { | |
375 return 0; | |
376 } | |
377 return 1; | |
378 } | |
379 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ | |
380 | |
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
|
381 #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
|
382 static int CheckXRandR(_THIS, int *major, int *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
|
383 { |
1765 | 384 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
|
385 |
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
|
386 /* 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
|
387 *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
|
388 |
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
|
389 /* 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
|
390 env = getenv("SDL_VIDEO_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
|
391 if ( env && !SDL_atoi(env) ) { |
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
|
392 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
|
393 } |
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
|
394 |
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
|
395 /* This defaults off now, due to KDE window maximize problems */ |
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
|
396 if ( !env ) { |
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
|
397 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
|
398 } |
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
|
399 |
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
|
400 if ( !SDL_X11_HAVE_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
|
401 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
|
402 } |
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
|
403 |
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
|
404 /* Query the extension version */ |
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
|
405 if ( !XRRQueryVersion(SDL_Display, major, 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
|
406 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
|
407 } |
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
|
408 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
|
409 } |
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
|
410 #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
|
411 |
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
|
412 #if 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
|
413 static int CheckVidMode(_THIS, int *major, int *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
|
414 { |
1765 | 415 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
|
416 |
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
|
417 /* 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
|
418 *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
|
419 |
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
|
420 /* 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
|
421 env = getenv("SDL_VIDEO_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
|
422 if ( env && !SDL_atoi(env) ) { |
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
|
423 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
|
424 } |
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
|
425 |
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
|
426 /* 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
|
427 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
|
428 */ |
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 if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 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
|
430 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
|
431 |
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 metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); |
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 if ( metro_fp != NULL ) { |
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 int major, minor, patch, version; |
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
|
435 major = 0; minor = 0; patch = 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
|
436 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
|
437 fclose(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
|
438 version = major*100+minor*10+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
|
439 if ( version < 431 ) { |
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
|
440 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
|
441 } |
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 } |
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
|
444 |
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 /* Query the extension version */ |
1747 | 446 vm_error = -1; |
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
|
447 if ( !SDL_NAME(XF86VidModeQueryExtension)(SDL_Display, &vm_event, &vm_error) || |
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 !SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, major, 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
|
449 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
|
450 } |
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 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
|
452 } |
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 #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
|
454 |
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 #if 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
|
456 static int CheckXME(_THIS, int *major, int *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
|
457 { |
1765 | 458 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
|
459 |
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
|
460 /* 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
|
461 *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
|
462 |
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 /* 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
|
464 env = getenv("SDL_VIDEO_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
|
465 if ( env && !SDL_atoi(env) ) { |
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 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
|
467 } |
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 |
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 /* Query the extension version */ |
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
|
470 if ( !XiGMiscQueryVersion(SDL_Display, major, 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
|
471 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
|
472 } |
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 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
|
474 } |
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 #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
|
476 |
0 | 477 int X11_GetVideoModes(_THIS) |
478 { | |
1765 | 479 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
480 int xinerama_major, xinerama_minor; | |
481 #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
|
482 #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
|
483 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
|
484 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
|
485 XRRScreenSize *sizes; |
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
|
486 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
487 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 488 int vm_major, vm_minor; |
489 int nmodes; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
490 SDL_NAME(XF86VidModeModeInfo) **modes; |
0 | 491 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
492 #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
|
493 int xme_major, xme_minor; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
494 int ractive, nummodes; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
495 XiGMiscResolutionInfo *modelist; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
496 #endif |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
497 int i, n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
498 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
499 int screen_h; |
0 | 500 |
1765 | 501 use_xinerama = 0; |
502 use_xrandr = 0; | |
0 | 503 use_vidmode = 0; |
1765 | 504 use_xme = 0; |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
505 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
506 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
507 |
1765 | 508 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
509 /* Query Xinerama extention */ | |
510 if ( CheckXinerama(this, &xinerama_major, &xinerama_minor) ) { | |
511 /* Find out which screen is the desired one */ | |
512 int desired = 0; | |
513 int screens; | |
514 int w, h; | |
515 SDL_NAME(XineramaScreenInfo) *xinerama; | |
516 | |
517 const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD"); | |
518 if ( variable ) { | |
519 desired = SDL_atoi(variable); | |
520 } | |
521 #ifdef X11MODES_DEBUG | |
522 printf("X11 detected Xinerama:\n"); | |
523 #endif | |
524 xinerama = SDL_NAME(XineramaQueryScreens)(SDL_Display, &screens); | |
525 for ( i = 0; i < screens; i++ ) { | |
526 #ifdef X11MODES_DEBUG | |
527 printf("xinerama %d: %dx%d+%d+%d\n", | |
528 xinerama[i].screen_number, | |
529 xinerama[i].width, xinerama[i].height, | |
530 xinerama[i].x_org, xinerama[i].y_org); | |
531 #endif | |
532 if ( xinerama[i].screen_number == desired ) { | |
533 use_xinerama = 1; | |
534 xinerama_info = xinerama[i]; | |
535 } | |
536 } | |
537 XFree(xinerama); | |
538 | |
539 if ( use_xinerama ) { | |
540 SDL_modelist = (SDL_Rect **)SDL_malloc(3*sizeof(SDL_Rect *)); | |
541 if ( !SDL_modelist ) { | |
542 SDL_OutOfMemory(); | |
543 return -1; | |
544 } | |
545 | |
546 /* Add the full xinerama mode */ | |
547 n = 0; | |
548 w = xinerama_info.width; | |
549 h = xinerama_info.height; | |
550 if ( screen_w > w || screen_h > h) { | |
551 SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | |
552 if ( SDL_modelist[n] ) { | |
553 SDL_modelist[n]->x = 0; | |
554 SDL_modelist[n]->y = 0; | |
555 SDL_modelist[n]->w = screen_w; | |
556 SDL_modelist[n]->h = screen_h; | |
557 ++n; | |
558 } | |
559 } | |
560 | |
561 /* Add the head xinerama mode */ | |
562 SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | |
563 if ( SDL_modelist[n] ) { | |
564 SDL_modelist[n]->x = 0; | |
565 SDL_modelist[n]->y = 0; | |
566 SDL_modelist[n]->w = w; | |
567 SDL_modelist[n]->h = h; | |
568 ++n; | |
569 } | |
570 SDL_modelist[n] = NULL; | |
571 } | |
572 } | |
573 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ | |
574 | |
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
|
575 #if SDL_VIDEO_DRIVER_X11_XRANDR |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
576 /* XRandR */ |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
577 /* require at least XRandR v1.0 (arbitrary) */ |
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
|
578 if ( CheckXRandR(this, &xrandr_major, &xrandr_minor) && (xrandr_major >= 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
|
579 { |
1765 | 580 #ifdef X11MODES_DEBUG |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
581 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
|
582 xrandr_major, xrandr_minor); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
583 #endif |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
584 |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
585 /* 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
|
586 each time we toggle modes. |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
587 */ |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
588 screen_config = XRRGetScreenInfo(SDL_Display, SDL_Root); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
589 |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
590 /* retrieve the list of resolution */ |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
591 sizes = XRRConfigSizes(screen_config, &nsizes); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
592 if (nsizes > 0) { |
1765 | 593 if ( SDL_modelist ) { |
594 for ( i = 0; SDL_modelist[i]; ++i ) { | |
595 SDL_free(SDL_modelist[i]); | |
596 } | |
597 SDL_free(SDL_modelist); | |
598 } | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
599 SDL_modelist = (SDL_Rect **)malloc((nsizes+1)*sizeof(SDL_Rect *)); |
1765 | 600 if ( !SDL_modelist ) { |
601 SDL_OutOfMemory(); | |
602 return -1; | |
603 } | |
604 for ( i=0; i < nsizes; i++ ) { | |
605 if ((SDL_modelist[i] = | |
606 (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL) | |
607 break; | |
608 #ifdef X11MODES_DEBUG | |
609 fprintf(stderr, "XRANDR: mode = %4d, w = %4d, h = %4d\n", | |
610 i, sizes[i].width, sizes[i].height); | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
611 #endif |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
612 |
1765 | 613 SDL_modelist[i]->x = 0; |
614 SDL_modelist[i]->y = 0; | |
615 SDL_modelist[i]->w = sizes[i].width; | |
616 SDL_modelist[i]->h = sizes[i].height; | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
617 |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
618 } |
1765 | 619 /* sort the mode list descending as SDL expects */ |
1771 | 620 SDL_qsort(SDL_modelist, nsizes, sizeof *SDL_modelist, cmpmodelist); |
1765 | 621 SDL_modelist[i] = NULL; /* terminator */ |
622 | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
623 use_xrandr = xrandr_major * 100 + xrandr_minor; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
624 saved_size_id = XRRConfigCurrentConfiguration(screen_config, &saved_rotation); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
625 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
626 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
627 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
628 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
629 #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
|
630 /* XVidMode */ |
1765 | 631 if ( !use_xrandr && |
1863 | 632 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
1765 | 633 (!use_xinerama || xinerama_info.screen_number == 0) && |
1863 | 634 #endif |
1765 | 635 CheckVidMode(this, &vm_major, &vm_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
|
636 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) |
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 { |
1765 | 638 #ifdef X11MODES_DEBUG |
1768 | 639 printf("VidMode modes: (unsorted)\n"); |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
640 for ( i = 0; i < nmodes; ++i ) { |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
641 printf("Mode %d: %d x %d @ %d\n", i, |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
642 modes[i]->hdisplay, modes[i]->vdisplay, |
1765 | 643 (modes[i]->htotal && modes[i]->vtotal) ? (1000 * modes[i]->dotclock / (modes[i]->htotal * modes[i]->vtotal)) : 0 ); |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
644 } |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
645 #endif |
1765 | 646 if ( SDL_modelist ) { |
647 for ( i = 0; SDL_modelist[i]; ++i ) { | |
648 SDL_free(SDL_modelist[i]); | |
649 } | |
650 SDL_free(SDL_modelist); | |
651 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
652 SDL_modelist = (SDL_Rect **)SDL_malloc((nmodes+2)*sizeof(SDL_Rect *)); |
1765 | 653 if ( !SDL_modelist ) { |
654 SDL_OutOfMemory(); | |
655 return -1; | |
656 } | |
657 SDL_qsort(modes, nmodes, sizeof *modes, cmpmodes); | |
658 n = 0; | |
659 for ( i=0; i<nmodes; ++i ) { | |
660 int w, h; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
661 |
1765 | 662 /* Eliminate duplicate modes with different refresh rates */ |
663 if ( i > 0 && | |
664 modes[i]->hdisplay == modes[i-1]->hdisplay && | |
665 modes[i]->vdisplay == modes[i-1]->vdisplay ) { | |
666 continue; | |
667 } | |
1318
f95502c6fc72
Eliminate duplicate modes with different refresh rates
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
668 |
1765 | 669 /* Check to see if we should add the screen size (Xinerama) */ |
670 w = modes[i]->hdisplay; | |
671 h = modes[i]->vdisplay; | |
672 if ( (screen_w * screen_h) >= (w * h) ) { | |
673 if ( (screen_w != w) || (screen_h != h) ) { | |
674 SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | |
675 if ( SDL_modelist[n] ) { | |
676 SDL_modelist[n]->x = 0; | |
677 SDL_modelist[n]->y = 0; | |
678 SDL_modelist[n]->w = screen_w; | |
679 SDL_modelist[n]->h = screen_h; | |
680 ++n; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
681 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
682 } |
1765 | 683 screen_w = 0; |
684 screen_h = 0; | |
685 } | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
686 |
1765 | 687 /* Add the size from the video mode list */ |
688 SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | |
689 if ( SDL_modelist[n] == NULL ) { | |
690 break; | |
0 | 691 } |
1765 | 692 SDL_modelist[n]->x = 0; |
693 SDL_modelist[n]->y = 0; | |
694 SDL_modelist[n]->w = w; | |
695 SDL_modelist[n]->h = h; | |
696 ++n; | |
0 | 697 } |
1765 | 698 SDL_modelist[n] = NULL; |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
699 XFree(modes); |
0 | 700 |
100
a1c973c35fef
Fixed using the video mode extension on older servers
Sam Lantinga <slouken@lokigames.com>
parents:
98
diff
changeset
|
701 use_vidmode = vm_major * 100 + vm_minor; |
0 | 702 save_mode(this); |
703 } | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
704 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
0 | 705 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
706 #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
|
707 /* 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
|
708 modelist = NULL; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
709 /* first lets make sure we have the extension, and it's at least v2.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
|
710 if ( CheckXME(this, &xme_major, &xme_minor) && xme_major >= 2 && |
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
|
711 (nummodes = XiGMiscQueryResolutions(SDL_Display, SDL_Screen, |
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
|
712 0, /* view */ |
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
|
713 &ractive, &modelist)) > 1 ) |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
714 { /* then we actually have some */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
715 int j; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
716 |
1765 | 717 /* We get the list already sorted in descending order. |
718 We'll copy it in reverse order so SDL is happy */ | |
719 #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
|
720 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
|
721 nummodes, ractive); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
722 #endif |
1765 | 723 if ( SDL_modelist ) { |
724 for ( i = 0; SDL_modelist[i]; ++i ) { | |
725 SDL_free(SDL_modelist[i]); | |
726 } | |
727 SDL_free(SDL_modelist); | |
728 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
729 SDL_modelist = (SDL_Rect **)SDL_malloc((nummodes+1)*sizeof(SDL_Rect *)); |
1765 | 730 if ( !SDL_modelist ) { |
731 SDL_OutOfMemory(); | |
732 return -1; | |
733 } | |
734 for ( i=0, j=nummodes-1; j>=0; i++, j-- ) { | |
735 if ((SDL_modelist[i] = | |
736 (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect))) == NULL) | |
737 break; | |
738 #ifdef X11MODES_DEBUG | |
739 fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n", | |
740 i, modelist[i].width, modelist[i].height); | |
741 #endif | |
742 | |
743 SDL_modelist[i]->x = 0; | |
744 SDL_modelist[i]->y = 0; | |
745 SDL_modelist[i]->w = modelist[j].width; | |
746 SDL_modelist[i]->h = modelist[j].height; | |
747 | |
748 } | |
749 SDL_modelist[i] = NULL; /* terminator */ | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
750 |
1765 | 751 use_xme = xme_major * 100 + xme_minor; |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
752 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
|
753 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
754 if ( modelist ) { |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
755 XFree(modelist); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
756 } |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
757 #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
|
758 |
0 | 759 { |
1641 | 760 /* It's interesting to note that if we allow 32 bit depths, |
761 we get a visual with an alpha mask on composite servers. | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
762 static int depth_list[] = { 32, 24, 16, 15, 8 }; |
1641 | 763 */ |
764 static int depth_list[] = { 24, 16, 15, 8 }; | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
765 int j, np; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
766 int use_directcolor = 1; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
767 XPixmapFormatValues *pf; |
0 | 768 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
769 /* Search for the visuals in deepest-first order, so that the first |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
770 will be the richest one */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
771 if ( SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
772 use_directcolor = 0; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
773 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
774 this->hidden->nvisuals = 0; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
775 if ( ! add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID")) ) { |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
776 for ( i=0; i<SDL_arraysize(depth_list); ++i ) { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
777 if ( depth_list[i] > 8 ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
778 if ( use_directcolor ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
779 add_visual(this, depth_list[i], DirectColor); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
780 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
781 add_visual(this, depth_list[i], TrueColor); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
782 } else { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
783 add_visual(this, depth_list[i], PseudoColor); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
784 add_visual(this, depth_list[i], StaticColor); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
785 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
786 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
787 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
788 if ( this->hidden->nvisuals == 0 ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
789 SDL_SetError("Found no sufficiently capable X11 visuals"); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
790 return -1; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
791 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
792 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
793 /* look up the pixel quantum for each depth */ |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
794 pf = XListPixmapFormats(SDL_Display, &np); |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
795 for(i = 0; i < this->hidden->nvisuals; i++) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
796 int d = this->hidden->visuals[i].depth; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
797 for(j = 0; j < np; j++) |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
798 if(pf[j].depth == d) |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
799 break; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
800 this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
801 } |
0 | 802 |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
803 XFree(pf); |
0 | 804 } |
805 | |
806 if ( SDL_modelist == NULL ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
807 SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); |
1765 | 808 if ( !SDL_modelist ) { |
809 SDL_OutOfMemory(); | |
810 return -1; | |
0 | 811 } |
1765 | 812 n = 0; |
813 SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | |
814 if ( SDL_modelist[n] ) { | |
815 SDL_modelist[n]->x = 0; | |
816 SDL_modelist[n]->y = 0; | |
817 SDL_modelist[n]->w = screen_w; | |
818 SDL_modelist[n]->h = screen_h; | |
819 ++n; | |
820 } | |
821 SDL_modelist[n] = NULL; | |
0 | 822 } |
823 | |
1765 | 824 #ifdef X11MODES_DEBUG |
825 if ( use_xinerama ) { | |
826 printf("Xinerama is enabled\n"); | |
827 } | |
828 | |
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
|
829 if ( use_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
|
830 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
|
831 } |
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
|
832 |
0 | 833 if ( use_vidmode ) { |
1768 | 834 printf("VidMode is enabled\n"); |
0 | 835 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
836 |
1765 | 837 if ( use_xme ) { |
1766 | 838 printf("Xi Graphics XME fullscreen is enabled\n"); |
1765 | 839 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
840 |
0 | 841 if ( SDL_modelist ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
842 printf("X11 video mode list:\n"); |
0 | 843 for ( i=0; SDL_modelist[i]; ++i ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
844 printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h); |
0 | 845 } |
846 } | |
1765 | 847 #endif /* X11MODES_DEBUG */ |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
848 |
0 | 849 return 0; |
850 } | |
851 | |
852 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) | |
853 { | |
854 int i; | |
855 for(i = 0; i < this->hidden->nvisuals; i++) | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
856 if(this->hidden->visuals[i].bpp == format->BitsPerPixel) |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
857 return 1; |
0 | 858 return 0; |
859 } | |
860 | |
861 SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
862 { | |
863 if ( X11_SupportedVisual(this, format) ) { | |
864 if ( flags & SDL_FULLSCREEN ) { | |
865 return(SDL_modelist); | |
866 } else { | |
867 return((SDL_Rect **)-1); | |
868 } | |
869 } else { | |
870 return((SDL_Rect **)0); | |
871 } | |
872 } | |
873 | |
874 void X11_FreeVideoModes(_THIS) | |
875 { | |
876 int i; | |
877 | |
878 if ( SDL_modelist ) { | |
879 for ( i=0; SDL_modelist[i]; ++i ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
880 SDL_free(SDL_modelist[i]); |
0 | 881 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
882 SDL_free(SDL_modelist); |
0 | 883 SDL_modelist = NULL; |
884 } | |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
885 |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
886 #if SDL_VIDEO_DRIVER_X11_XRANDR |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
887 /* Free the Xrandr screen configuration */ |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
888 if ( screen_config ) { |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
889 XRRFreeScreenConfigInfo(screen_config); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
890 screen_config = NULL; |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
891 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
892 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ |
0 | 893 } |
894 | |
895 int X11_ResizeFullScreen(_THIS) | |
896 { | |
1765 | 897 int x = 0, y = 0; |
0 | 898 int real_w, real_h; |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
899 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
900 int screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
901 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
902 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
903 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
0 | 904 |
1863 | 905 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
1765 | 906 if ( use_xinerama && |
907 window_w <= xinerama_info.width && | |
908 window_h <= xinerama_info.height ) { | |
909 x = xinerama_info.x_org; | |
910 y = xinerama_info.y_org; | |
911 } | |
1863 | 912 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ |
913 | |
0 | 914 if ( currently_fullscreen ) { |
915 /* 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
|
916 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
|
917 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
|
918 move_cursor_to(this, x, y); |
0 | 919 get_real_resolution(this, &real_w, &real_h); |
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
|
920 if ( window_w > real_w ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
921 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
922 } |
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
|
923 if ( window_h > real_h ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
924 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
925 } |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
926 XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); |
0 | 927 move_cursor_to(this, real_w/2, real_h/2); |
928 | |
929 /* Center and reparent the drawing window */ | |
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
|
930 x = (real_w - window_w)/2; |
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
|
931 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
|
932 XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); |
0 | 933 /* FIXME: move the mouse to the old relative location */ |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
934 XSync(SDL_Display, True); /* Flush spurious mode change events */ |
0 | 935 } |
936 return(1); | |
937 } | |
938 | |
939 void X11_QueueEnterFullScreen(_THIS) | |
940 { | |
941 switch_waiting = 0x01 | SDL_FULLSCREEN; | |
942 switch_time = SDL_GetTicks() + 1500; | |
943 #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
|
944 XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); |
0 | 945 #endif |
946 } | |
947 | |
948 int X11_EnterFullScreen(_THIS) | |
949 { | |
950 int okay; | |
951 #if 0 | |
952 Window tmpwin, *windows; | |
953 int i, nwindows; | |
954 #endif | |
1765 | 955 int x = 0, y = 0; |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
956 int real_w, real_h; |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
957 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
958 int screen_h; |
0 | 959 |
960 okay = 1; | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
961 if ( currently_fullscreen ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
962 return(okay); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
963 } |
0 | 964 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
965 /* 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
|
966 X11_GrabInputNoLock(this, SDL_GRAB_OFF); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
967 |
1863 | 968 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
1765 | 969 if ( use_xinerama && |
970 window_w <= xinerama_info.width && | |
971 window_h <= xinerama_info.height ) { | |
972 x = xinerama_info.x_org; | |
973 y = xinerama_info.y_org; | |
974 } | |
1863 | 975 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ |
976 | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
977 /* 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
|
978 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
979 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
|
980 get_real_resolution(this, &real_w, &real_h); |
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
|
981 if ( window_w > real_w ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
982 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
983 } |
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
|
984 if ( window_h > real_h ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
985 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
986 } |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
987 XMoveResizeWindow(SDL_Display, FSwindow, |
1765 | 988 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
|
989 XMapRaised(SDL_Display, FSwindow); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
990 X11_WaitMapped(this, FSwindow); |
0 | 991 |
992 #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
|
993 /* Make sure we got to the top of the window stack */ |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
994 if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
995 &windows, &nwindows) && windows ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
996 /* If not, try to put us there - if fail... oh well */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
997 if ( windows[nwindows-1] != FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
998 tmpwin = windows[nwindows-1]; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
999 for ( i=0; i<nwindows; ++i ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1000 if ( windows[i] == FSwindow ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1318
diff
changeset
|
1001 SDL_memcpy(&windows[i], &windows[i+1], |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1002 (nwindows-i-1)*sizeof(windows[i])); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1003 break; |
0 | 1004 } |
1005 } | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1006 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
|
1007 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
|
1008 XSync(SDL_Display, False); |
0 | 1009 } |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1010 XFree(windows); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1011 } |
0 | 1012 #else |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1013 XRaiseWindow(SDL_Display, FSwindow); |
0 | 1014 #endif |
1015 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
1016 #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
|
1017 /* Save the current video mode */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1018 if ( use_vidmode ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1019 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
|
1020 } |
0 | 1021 #endif |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1022 currently_fullscreen = 1; |
0 | 1023 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1024 /* Set the new resolution */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1025 okay = X11_ResizeFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1026 if ( ! okay ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1027 X11_LeaveFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1028 } |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1029 /* Set the colormap */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
1030 if ( SDL_XColorMap ) { |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1031 XInstallColormap(SDL_Display, SDL_XColorMap); |
0 | 1032 } |
1765 | 1033 if ( okay ) { |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1034 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); |
1765 | 1035 } |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1036 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1037 /* 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
|
1038 We also don't get an event, which is why we explicitly refresh. */ |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1039 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1040 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1041 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1042 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1043 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1044 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1045 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1046 |
0 | 1047 return(okay); |
1048 } | |
1049 | |
1050 int X11_LeaveFullScreen(_THIS) | |
1051 { | |
1052 if ( currently_fullscreen ) { | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1053 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
|
1054 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
0 | 1055 if ( use_vidmode ) { |
1056 restore_mode(this); | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
1057 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); |
0 | 1058 } |
1059 #endif | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
1060 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
1061 #if SDL_VIDEO_DRIVER_X11_XME |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1062 if ( use_xme ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1063 int rw, rh; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1064 |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
1065 /* 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
|
1066 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
|
1067 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1068 if (rw != saved_res.width || rh != saved_res.height) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1069 XiGMiscChangeResolution(SDL_Display, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1070 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1071 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1072 saved_res.width, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1073 saved_res.height, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1074 0); |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1075 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
|
1076 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1077 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
1078 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
1079 |
1589
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1080 #if SDL_VIDEO_DRIVER_X11_XRANDR |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1081 if ( use_xrandr ) { |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1082 XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root, |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1083 saved_size_id, saved_rotation, CurrentTime); |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1084 } |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1085 #endif |
34cca785be57
Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents:
1575
diff
changeset
|
1086 |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1087 XUnmapWindow(SDL_Display, FSwindow); |
0 | 1088 X11_WaitUnmapped(this, FSwindow); |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1545
diff
changeset
|
1089 XSync(SDL_Display, True); /* Flush spurious mode change events */ |
0 | 1090 currently_fullscreen = 0; |
1091 } | |
1092 /* If we get popped out of fullscreen mode for some reason, input_grab | |
1093 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only | |
1094 temporary. In this case, release the grab unless the input has been | |
1095 explicitly grabbed. | |
1096 */ | |
1097 X11_GrabInputNoLock(this, this->input_grab & ~SDL_GRAB_FULLSCREEN); | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1098 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1099 /* 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
|
1100 We also don't get an event, which is why we explicitly refresh. */ |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1101 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1102 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1103 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1104 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1105 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1106 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1107 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1108 |
0 | 1109 return(0); |
1110 } |