Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11modes.c @ 604:31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
From: Ragnvald "Despair" Maartmann-Moe IV
Subject: SDL x11 video mode selection bug
Hi, I've found an oddity with video mode selection. I recently added a bunch of
oddball video modes to my XF86Config, to support weird resolutions xine &
mplayer need if I don't want to beat my cpu up with video scaling.
Since adding them, SDL started picking the biggest video mode it could find
that matched the height constraint. Getting a narrow vertical strip of
QuakeForge (I code for the project, so needless to say it's my favorite test)
in the middle of an 800x480 screen, instead of the 640x480 I asked for
annoys me tremendously.
So here's a patch that tries a bit harder to get an exact match. I didn't
touch the XiG section, since I can't test that, but I'd bet a similar patch
would prevent similar problems there.
--Ragnvald "Despair" Maartmann-Moe IV
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 06 Mar 2003 06:02:16 +0000 |
parents | f480ecd70499 |
children | f8710950cddc |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
292
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
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 | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
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 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* Utilities for getting and setting the X display mode */ | |
29 | |
30 #include <stdlib.h> | |
31 #include <string.h> | |
32 | |
33 #include "SDL_timer.h" | |
34 #include "SDL_error.h" | |
35 #include "SDL_events.h" | |
36 #include "SDL_events_c.h" | |
37 #include "SDL_x11video.h" | |
38 #include "SDL_x11wm_c.h" | |
39 #include "SDL_x11modes_c.h" | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
40 #include "SDL_x11image_c.h" |
0 | 41 |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
42 #ifdef HAVE_XINERAMA |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
43 #include <XFree86/extensions/Xinerama.h> |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
44 #endif |
0 | 45 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
46 #define MAX(a, b) (a > b ? a : b) |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
47 |
0 | 48 #ifdef XFREE86_VM |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
49 Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info) |
0 | 50 { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
51 SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock); |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
52 return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, &info->dotclock, l); |
0 | 53 } |
54 #endif /* XFREE86_VM */ | |
55 | |
56 #ifdef XFREE86_VM | |
57 static void save_mode(_THIS) | |
58 { | |
59 memset(&saved_mode, 0, sizeof(saved_mode)); | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
60 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
|
61 SDL_NAME(XF86VidModeGetViewPort)(SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y); |
0 | 62 } |
63 #endif | |
64 | |
65 #ifdef XFREE86_VM | |
66 static void restore_mode(_THIS) | |
67 { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
68 SDL_NAME(XF86VidModeModeLine) mode; |
0 | 69 int unused; |
70 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
71 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
0 | 72 if ( (saved_mode.hdisplay != mode.hdisplay) || |
73 (saved_mode.vdisplay != mode.vdisplay) ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
74 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, &saved_mode); |
0 | 75 } |
76 } | |
77 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
|
78 SDL_NAME(XF86VidModeSetViewPort)(SDL_Display, SDL_Screen, saved_view.x, saved_view.y); |
0 | 79 } |
80 } | |
81 #endif | |
82 | |
83 #ifdef XFREE86_VM | |
84 static int cmpmodes(const void *va, const void *vb) | |
85 { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
86 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
|
87 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; |
0 | 88 if(a->hdisplay > b->hdisplay) |
89 return -1; | |
90 return b->vdisplay - a->vdisplay; | |
91 } | |
92 #endif | |
93 | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
94 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
|
95 |
0 | 96 static void set_best_resolution(_THIS, int width, int height) |
97 { | |
98 #ifdef XFREE86_VM | |
99 if ( use_vidmode ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
100 SDL_NAME(XF86VidModeModeLine) mode; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
101 SDL_NAME(XF86VidModeModeInfo) **modes; |
0 | 102 int i; |
103 int nmodes; | |
104 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
105 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
106 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){ |
0 | 107 qsort(modes, nmodes, sizeof *modes, cmpmodes); |
108 #ifdef XFREE86_DEBUG | |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
109 printf("Available modes:\n"); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
110 for ( i = 0; i < nmodes; ++i ) { |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
111 printf("Mode %d: %dx%d\n", i, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
112 modes[i]->hdisplay, modes[i]->vdisplay); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
113 } |
0 | 114 #endif |
115 for ( i = nmodes-1; i > 0 ; --i ) { | |
604
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
116 if ( (modes[i]->hdisplay == width) && |
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
117 (modes[i]->vdisplay == height) ) |
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
118 goto match; |
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
119 } |
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
120 for ( i = nmodes-1; i > 0 ; --i ) { |
0 | 121 if ( (modes[i]->hdisplay >= width) && |
122 (modes[i]->vdisplay >= height) ) | |
123 break; | |
124 } | |
604
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
125 match: |
0 | 126 if ( (modes[i]->hdisplay != mode.hdisplay) || |
127 (modes[i]->vdisplay != mode.vdisplay) ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
128 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); |
0 | 129 } |
130 XFree(modes); | |
131 } | |
132 } | |
133 #endif /* XFREE86_VM */ | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
134 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
135 /* XiG */ |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
136 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
137 #ifdef XIG_DEBUG |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
138 fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n", |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
139 width, height); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
140 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
141 if ( 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
|
142 int i; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
143 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
144 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
|
145 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
|
146 (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
|
147 break; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
148 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
149 } |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
150 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
151 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
|
152 int w, h; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
153 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
154 /* 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
|
155 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
|
156 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
157 if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) { |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
158 # ifdef XIG_DEBUG |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
159 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
|
160 "XiGMiscChangeResolution: %d %d\n", |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
161 SDL_modelist[s]->w, SDL_modelist[s]->h); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
162 # endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
163 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
|
164 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
165 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
166 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
|
167 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
|
168 0); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
169 XSync(SDL_Display, False); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
170 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
171 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
172 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
173 #endif /* HAVE_XIGXME */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
174 |
0 | 175 } |
176 | |
177 static void get_real_resolution(_THIS, int* w, int* h) | |
178 { | |
179 #ifdef XFREE86_VM | |
180 if ( use_vidmode ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
181 SDL_NAME(XF86VidModeModeLine) mode; |
0 | 182 int unused; |
183 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
184 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
0 | 185 *w = mode.hdisplay; |
186 *h = mode.vdisplay; | |
187 return; | |
188 } | |
189 } | |
190 #endif | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
191 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
192 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
193 if ( use_xme ) { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
194 int ractive; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
195 XiGMiscResolutionInfo *modelist; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
196 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
197 XiGMiscQueryResolutions(SDL_Display, SDL_Screen, |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
198 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
199 &ractive, &modelist); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
200 *w = modelist[ractive].width; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
201 *h = modelist[ractive].height; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
202 #ifdef XIG_DEBUG |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
203 fprintf(stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
204 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
205 XFree(modelist); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
206 return; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
207 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
208 #endif /* XIG_XME */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
209 |
0 | 210 *w = DisplayWidth(SDL_Display, SDL_Screen); |
211 *h = DisplayHeight(SDL_Display, SDL_Screen); | |
212 } | |
213 | |
214 /* Called after mapping a window - waits until the window is mapped */ | |
215 void X11_WaitMapped(_THIS, Window win) | |
216 { | |
217 XEvent event; | |
218 do { | |
219 XMaskEvent(SDL_Display, StructureNotifyMask, &event); | |
220 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); | |
221 } | |
222 | |
223 /* Called after unmapping a window - waits until the window is unmapped */ | |
224 void X11_WaitUnmapped(_THIS, Window win) | |
225 { | |
226 XEvent event; | |
227 do { | |
228 XMaskEvent(SDL_Display, StructureNotifyMask, &event); | |
229 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); | |
230 } | |
231 | |
232 static void move_cursor_to(_THIS, int x, int y) | |
233 { | |
234 XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); | |
235 } | |
236 | |
237 static int add_visual(_THIS, int depth, int class) | |
238 { | |
239 XVisualInfo vi; | |
240 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
|
241 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
|
242 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
|
243 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
|
244 this->hidden->nvisuals++; |
0 | 245 } |
246 return(this->hidden->nvisuals); | |
247 } | |
248 static int add_visual_byid(_THIS, const char *visual_id) | |
249 { | |
250 XVisualInfo *vi, template; | |
251 int nvis; | |
252 | |
253 if ( visual_id ) { | |
254 memset(&template, 0, (sizeof template)); | |
255 template.visualid = strtol(visual_id, NULL, 0); | |
256 vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); | |
257 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
|
258 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
|
259 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
|
260 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
|
261 this->hidden->nvisuals++; |
0 | 262 XFree(vi); |
263 } | |
264 } | |
265 return(this->hidden->nvisuals); | |
266 } | |
267 | |
268 /* Global for the error handler */ | |
269 int vm_event, vm_error = -1; | |
270 | |
271 int X11_GetVideoModes(_THIS) | |
272 { | |
273 #ifdef XFREE86_VM | |
274 int buggy_X11; | |
275 int vm_major, vm_minor; | |
276 int nmodes; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
277 SDL_NAME(XF86VidModeModeInfo) **modes; |
0 | 278 #endif |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
279 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
280 int xme_major, xme_minor; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
281 int ractive, nummodes; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
282 XiGMiscResolutionInfo *modelist; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
283 #endif |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
284 int i, n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
285 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
286 int screen_h; |
0 | 287 |
288 vm_error = -1; | |
289 use_vidmode = 0; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
290 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
291 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
292 |
0 | 293 #ifdef XFREE86_VM |
294 /* Metro-X 4.3.0 and earlier has a broken implementation of | |
295 XF86VidModeGetAllModeLines() - it hangs the client. | |
296 */ | |
297 buggy_X11 = 0; | |
298 if ( strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { | |
299 FILE *metro_fp; | |
300 | |
301 metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); | |
302 if ( metro_fp != NULL ) { | |
303 int major, minor, patch, version; | |
304 major = 0; minor = 0; patch = 0; | |
305 fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch); | |
306 version = major*100+minor*10+patch; | |
307 if ( version < 431 ) { | |
308 buggy_X11 = 1; | |
309 } | |
310 fclose(metro_fp); | |
311 } | |
312 } | |
313 #if defined(__alpha__) || defined(__powerpc__) | |
314 /* The alpha and PPC XFree86 servers are also buggy */ | |
315 buggy_X11 = 1; | |
316 #endif | |
317 /* Enumerate the available fullscreen modes */ | |
318 if ( ! buggy_X11 ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
319 if ( SDL_NAME(XF86VidModeQueryExtension)(SDL_Display, &vm_event, &vm_error) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
320 SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, &vm_major, &vm_minor) ) { |
0 | 321 #ifdef BROKEN_XFREE86_4001 |
322 #ifdef X_XF86VidModeGetDotClocks /* Compiled under XFree86 4.0 */ | |
323 /* Earlier X servers hang when doing vidmode */ | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
324 if ( vm_major < 2 ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
325 #ifdef XFREE86_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
326 printf("Compiled under XFree86 4.0, server is XFree86 3.X\n"); |
0 | 327 #endif |
328 buggy_X11 = 1; | |
329 } | |
330 #else | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
331 /* XFree86 3.X code works with XFree86 4.0 servers */; |
0 | 332 #endif /* XFree86 4.0 */ |
333 #endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */ | |
334 } else { | |
335 buggy_X11 = 1; | |
336 } | |
337 } | |
338 if ( ! buggy_X11 && | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
339 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) { |
0 | 340 |
341 qsort(modes, nmodes, sizeof *modes, cmpmodes); | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
342 SDL_modelist = (SDL_Rect **)malloc((nmodes+2)*sizeof(SDL_Rect *)); |
0 | 343 if ( SDL_modelist ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
344 n = 0; |
0 | 345 for ( i=0; i<nmodes; ++i ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
346 int w, h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
347 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
348 /* Check to see if we should add the screen size (Xinerama) */ |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
349 w = modes[i]->hdisplay; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
350 h = modes[i]->vdisplay; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
351 if ( (screen_w * screen_h) >= (w * h) ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
352 if ( (screen_w != w) || (screen_h != h) ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
353 SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
354 if ( SDL_modelist[n] ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
355 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
356 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
357 SDL_modelist[n]->w = screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
358 SDL_modelist[n]->h = screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
359 ++n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
360 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
361 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
362 screen_w = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
363 screen_h = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
364 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
365 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
366 /* Add the size from the video mode list */ |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
367 SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
368 if ( SDL_modelist[n] == NULL ) { |
0 | 369 break; |
370 } | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
371 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
372 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
373 SDL_modelist[n]->w = w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
374 SDL_modelist[n]->h = h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
375 ++n; |
0 | 376 } |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
377 SDL_modelist[n] = NULL; |
0 | 378 } |
379 XFree(modes); | |
380 | |
100
a1c973c35fef
Fixed using the video mode extension on older servers
Sam Lantinga <slouken@lokigames.com>
parents:
98
diff
changeset
|
381 use_vidmode = vm_major * 100 + vm_minor; |
0 | 382 save_mode(this); |
383 } | |
384 #endif /* XFREE86_VM */ | |
385 | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
386 /* XiG */ |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
387 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
388 /* first lets make sure we have the extension, and it's at least v2.0 */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
389 if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
390 #ifdef XIG_DEBUG |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
391 fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n", |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
392 xme_major, xme_minor); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
393 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
394 /* work around a XiGMisc bogosity in our version of libXext */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
395 if (xme_major == 0 && xme_major == 0) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
396 /* Ideally libxme would spit this out, but the problem is that |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
397 the right Query func will never be called if using the bogus |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
398 libXext version. |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
399 */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
400 fprintf(stderr, |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
401 "XME: If you are using Xi Graphics CDE and a Summit server, you need to\n" |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
402 "XME: get the libXext update from our ftp site before fullscreen switching\n" |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
403 "XME: will work. Fullscreen switching is only supported on Summit Servers\n"); |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
404 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
405 } else { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
406 /* not there. Bummer. */ |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
407 xme_major = xme_minor = 0; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
408 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
409 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
410 modelist = NULL; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
411 if (xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display, |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
412 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
413 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
414 &ractive, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
415 &modelist)) > 1) |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
416 { /* 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
|
417 int j; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
418 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
419 #ifdef XIG_DEBUG |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
420 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
|
421 nummodes, ractive); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
422 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
423 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
424 SDL_modelist = (SDL_Rect **)malloc((nummodes+1)*sizeof(SDL_Rect *)); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
425 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
426 /* we get the list already sorted in */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
427 /* descending order. We'll copy it in */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
428 /* reverse order so SDL is happy */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
429 if (SDL_modelist) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
430 for ( i=0, j=nummodes-1; j>=0; i++, j-- ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
431 if ((SDL_modelist[i] = |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
432 (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL) |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
433 break; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
434 #ifdef XIG_DEBUG |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
435 fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n", |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
436 i, modelist[i].width, modelist[i].height); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
437 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
438 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
439 SDL_modelist[i]->x = 0; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
440 SDL_modelist[i]->y = 0; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
441 SDL_modelist[i]->w = modelist[j].width; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
442 SDL_modelist[i]->h = modelist[j].height; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
443 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
444 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
445 SDL_modelist[i] = NULL; /* terminator */ |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
446 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
447 use_xme = 1; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
448 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
|
449 } else { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
450 use_xme = 0; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
451 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
452 if ( modelist ) { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
453 XFree(modelist); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
454 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
455 #endif /* HAVE_XIGXME */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
456 |
0 | 457 { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
458 static int depth_list[] = { 32, 24, 16, 15, 8 }; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
459 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
|
460 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
|
461 XPixmapFormatValues *pf; |
0 | 462 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
463 /* 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
|
464 will be the richest one */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
465 if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
466 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
|
467 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
468 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
|
469 if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
470 for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
471 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
|
472 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
|
473 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
|
474 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
475 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
|
476 } else { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
477 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
|
478 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
|
479 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
480 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
481 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
482 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
|
483 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
|
484 return -1; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
485 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
486 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
487 /* look up the pixel quantum for each depth */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
488 pf = XListPixmapFormats(SDL_Display, &np); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 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
|
493 break; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
494 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
|
495 } |
0 | 496 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
497 XFree(pf); |
0 | 498 } |
499 | |
500 if ( SDL_modelist == NULL ) { | |
501 SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); | |
502 if ( SDL_modelist ) { | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
503 n = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
504 SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
505 if ( SDL_modelist[n] ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
506 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
507 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
508 SDL_modelist[n]->w = screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
509 SDL_modelist[n]->h = screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
510 ++n; |
0 | 511 } |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
512 SDL_modelist[n] = NULL; |
0 | 513 } |
514 } | |
515 | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
516 #if defined(XFREE86_DEBUG) || defined(XIG_DEBUG) |
0 | 517 if ( use_vidmode ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
518 printf("XFree86 VidMode is enabled\n"); |
0 | 519 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
520 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
521 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
522 if ( use_xme ) |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
523 printf("Xi Graphics XME fullscreen is enabled\n"); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
524 else |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
525 printf("Xi Graphics XME fullscreen is not available\n"); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
526 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
527 |
0 | 528 if ( SDL_modelist ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
529 printf("X11 video mode list:\n"); |
0 | 530 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
|
531 printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h); |
0 | 532 } |
533 } | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
534 #endif /* XFREE86_DEBUG || XIG_DEBUG */ |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
535 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
536 /* The default X/Y fullscreen offset is 0/0 */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
537 xinerama_x = 0; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
538 xinerama_y = 0; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
539 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
540 #ifdef HAVE_XINERAMA |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
541 /* Query Xinerama extention */ |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
542 if ( SDL_NAME(XineramaQueryExtension)(SDL_Display, &i, &i) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
543 SDL_NAME(XineramaIsActive)(SDL_Display) ) { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
544 /* Find out which screen is the desired one */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
545 int desired = 0; |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
546 int screens; |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
547 SDL_NAME(XineramaScreenInfo) *xinerama; |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
548 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
549 #ifdef XINERAMA_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
550 printf("X11 detected Xinerama:\n"); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
551 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
552 #if 0 /* Apparently the vidmode extension doesn't work with Xinerama */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
553 const char *variable = getenv("SDL_VIDEO_X11_XINERAMA_SCREEN"); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
554 if ( variable ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
555 desired = atoi(variable); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
556 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
557 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
558 xinerama = SDL_NAME(XineramaQueryScreens)(SDL_Display, &screens); |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
559 for ( i = 0; i < screens; i++ ) { |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
560 #ifdef XINERAMA_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
561 printf("xinerama %d: %dx%d+%d+%d\n", |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
562 xinerama[i].screen_number, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
563 xinerama[i].width, xinerama[i].height, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
564 xinerama[i].x_org, xinerama[i].y_org); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
565 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
566 if ( xinerama[i].screen_number == desired ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
567 xinerama_x = xinerama[i].x_org; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
568 xinerama_y = xinerama[i].y_org; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
569 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
570 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
571 XFree(xinerama); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
572 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
573 #endif /* HAVE_XINERAMA */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
574 |
0 | 575 return 0; |
576 } | |
577 | |
578 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) | |
579 { | |
580 int i; | |
581 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
|
582 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
|
583 return 1; |
0 | 584 return 0; |
585 } | |
586 | |
587 SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
588 { | |
589 if ( X11_SupportedVisual(this, format) ) { | |
590 if ( flags & SDL_FULLSCREEN ) { | |
591 return(SDL_modelist); | |
592 } else { | |
593 return((SDL_Rect **)-1); | |
594 } | |
595 } else { | |
596 return((SDL_Rect **)0); | |
597 } | |
598 } | |
599 | |
600 void X11_FreeVideoModes(_THIS) | |
601 { | |
602 int i; | |
603 | |
604 if ( SDL_modelist ) { | |
605 for ( i=0; SDL_modelist[i]; ++i ) { | |
606 free(SDL_modelist[i]); | |
607 } | |
608 free(SDL_modelist); | |
609 SDL_modelist = NULL; | |
610 } | |
611 } | |
612 | |
613 int X11_ResizeFullScreen(_THIS) | |
614 { | |
615 int x, y; | |
616 int real_w, real_h; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
617 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
618 int screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
619 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
620 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
621 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
0 | 622 |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
623 x = xinerama_x; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
624 y = xinerama_y; |
0 | 625 if ( currently_fullscreen ) { |
626 /* 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
|
627 move_cursor_to(this, x, y); |
0 | 628 set_best_resolution(this, current_w, current_h); |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
629 move_cursor_to(this, x, y); |
0 | 630 get_real_resolution(this, &real_w, &real_h); |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
631 if ( current_w > real_w ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
632 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
633 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
634 if ( current_h > real_h ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
635 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
636 } |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
637 XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); |
0 | 638 move_cursor_to(this, real_w/2, real_h/2); |
639 | |
640 /* Center and reparent the drawing window */ | |
641 x = (real_w - current_w)/2; | |
642 y = (real_h - current_h)/2; | |
643 XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); | |
644 /* FIXME: move the mouse to the old relative location */ | |
645 XSync(SDL_Display, True); /* Flush spurious mode change events */ | |
646 } | |
647 return(1); | |
648 } | |
649 | |
650 void X11_QueueEnterFullScreen(_THIS) | |
651 { | |
652 switch_waiting = 0x01 | SDL_FULLSCREEN; | |
653 switch_time = SDL_GetTicks() + 1500; | |
654 #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ | |
655 XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); | |
656 #endif | |
657 } | |
658 | |
659 int X11_EnterFullScreen(_THIS) | |
660 { | |
661 int okay; | |
662 #if 0 | |
663 Window tmpwin, *windows; | |
664 int i, nwindows; | |
665 #endif | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
666 int real_w, real_h; |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
667 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
668 int screen_h; |
0 | 669 |
670 okay = 1; | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
671 if ( currently_fullscreen ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
672 return(okay); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
673 } |
0 | 674 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
675 /* 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
|
676 X11_GrabInputNoLock(this, SDL_GRAB_OFF); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
677 |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
678 /* 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
|
679 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
680 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
|
681 get_real_resolution(this, &real_w, &real_h); |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
682 if ( current_w > real_w ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
683 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
684 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
685 if ( current_h > real_h ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
686 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
687 } |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
688 XMoveResizeWindow(SDL_Display, FSwindow, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
689 xinerama_x, xinerama_y, real_w, real_h); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
690 XMapRaised(SDL_Display, FSwindow); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
691 X11_WaitMapped(this, FSwindow); |
0 | 692 |
693 #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
|
694 /* Make sure we got to the top of the window stack */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
695 if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
696 &windows, &nwindows) && windows ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
697 /* 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
|
698 if ( windows[nwindows-1] != FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
699 tmpwin = windows[nwindows-1]; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
700 for ( i=0; i<nwindows; ++i ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
701 if ( windows[i] == FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
702 memcpy(&windows[i], &windows[i+1], |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
703 (nwindows-i-1)*sizeof(windows[i])); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
704 break; |
0 | 705 } |
706 } | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
707 windows[nwindows-1] = FSwindow; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
708 XRestackWindows(SDL_Display, windows, nwindows); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
709 XSync(SDL_Display, False); |
0 | 710 } |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
711 XFree(windows); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
712 } |
0 | 713 #else |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
714 XRaiseWindow(SDL_Display, FSwindow); |
0 | 715 #endif |
716 | |
717 #ifdef XFREE86_VM | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
718 /* Save the current video mode */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
719 if ( use_vidmode ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
720 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, True); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
721 } |
0 | 722 #endif |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
723 currently_fullscreen = 1; |
0 | 724 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
725 /* Set the new resolution */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
726 okay = X11_ResizeFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
727 if ( ! okay ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
728 X11_LeaveFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
729 } |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
730 /* Set the colormap */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
731 if ( SDL_XColorMap ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
732 XInstallColormap(SDL_Display, SDL_XColorMap); |
0 | 733 } |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
734 if ( okay ) |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
735 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
736 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
737 /* 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
|
738 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
|
739 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
740 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
741 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
742 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
743 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
744 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
745 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
746 |
0 | 747 return(okay); |
748 } | |
749 | |
750 int X11_LeaveFullScreen(_THIS) | |
751 { | |
752 if ( currently_fullscreen ) { | |
753 XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); | |
754 #ifdef XFREE86_VM | |
755 if ( use_vidmode ) { | |
756 restore_mode(this); | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
757 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); |
0 | 758 } |
759 #endif | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
760 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
761 #ifdef HAVE_XIGXME |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
762 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
|
763 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
|
764 |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
765 /* 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
|
766 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
|
767 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
768 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
|
769 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
|
770 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
771 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
772 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
|
773 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
|
774 0); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
775 XSync(SDL_Display, False); |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
776 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
777 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
778 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
779 |
0 | 780 XUnmapWindow(SDL_Display, FSwindow); |
781 X11_WaitUnmapped(this, FSwindow); | |
782 XSync(SDL_Display, True); /* Flush spurious mode change events */ | |
783 currently_fullscreen = 0; | |
784 } | |
785 /* If we get popped out of fullscreen mode for some reason, input_grab | |
786 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only | |
787 temporary. In this case, release the grab unless the input has been | |
788 explicitly grabbed. | |
789 */ | |
790 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
|
791 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
792 /* 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
|
793 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
|
794 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
795 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
796 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
797 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
798 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
799 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
800 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
801 |
0 | 802 return(0); |
803 } |