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