Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11modes.c @ 1306:0c105755b110
Changed references to XFree86 to Xext to match change in directory structure.
Reference Bugzilla #116.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 31 Jan 2006 18:39:32 +0000 |
parents | 09164d2b8373 |
children | c9b51268668f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
713
diff
changeset
|
3 Copyright (C) 1997-2004 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 |
1306
0c105755b110
Changed references to XFree86 to Xext to match change in directory structure.
Ryan C. Gordon <icculus@icculus.org>
parents:
1262
diff
changeset
|
43 #include <Xext/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); |
1196
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
52 return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, (int*)&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; |
966
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
88 if ( a->hdisplay == b->hdisplay ) |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
89 return b->vdisplay - a->vdisplay; |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
90 else |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
91 return b->hdisplay - a->hdisplay; |
0 | 92 } |
93 #endif | |
94 | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
95 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
|
96 |
0 | 97 static void set_best_resolution(_THIS, int width, int height) |
98 { | |
99 #ifdef XFREE86_VM | |
100 if ( use_vidmode ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
101 SDL_NAME(XF86VidModeModeLine) mode; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
102 SDL_NAME(XF86VidModeModeInfo) **modes; |
0 | 103 int i; |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
104 int best_width = 0, best_height = 0; |
0 | 105 int nmodes; |
106 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
107 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) && |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
108 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){ |
0 | 109 #ifdef XFREE86_DEBUG |
641
df178851293b
Date: 28 Jun 2003 22:42:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
637
diff
changeset
|
110 printf("Available modes (unsorted):\n"); |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
111 for ( i = 0; i < nmodes; ++i ) { |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
112 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
|
113 modes[i]->hdisplay, modes[i]->vdisplay, |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
114 1000 * modes[i]->dotclock / (modes[i]->htotal * |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
115 modes[i]->vtotal) ); |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
116 } |
0 | 117 #endif |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
118 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
|
119 if ( (modes[i]->hdisplay == width) && |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
120 (modes[i]->vdisplay == height) ) |
604
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
121 goto match; |
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
122 } |
641
df178851293b
Date: 28 Jun 2003 22:42:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
637
diff
changeset
|
123 qsort(modes, nmodes, sizeof *modes, cmpmodes); |
713
7c8deec1659c
Fixed X11 mode line crash with only one video mode (thanks Alan!)
Sam Lantinga <slouken@libsdl.org>
parents:
641
diff
changeset
|
124 for ( i = nmodes-1; i > 0 ; i-- ) { |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
125 if ( ! best_width ) { |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
126 if ( (modes[i]->hdisplay >= width) && |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
127 (modes[i]->vdisplay >= height) ) { |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
128 best_width = modes[i]->hdisplay; |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
129 best_height = modes[i]->vdisplay; |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
130 } |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
131 } else { |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
132 if ( (modes[i]->hdisplay != best_width) || |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
133 (modes[i]->vdisplay != best_height) ) { |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
134 i++; |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
135 break; |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
136 } |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
137 } |
0 | 138 } |
604
31d3af76488b
Date: Mon, 24 Feb 2003 16:31:25 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
499
diff
changeset
|
139 match: |
0 | 140 if ( (modes[i]->hdisplay != mode.hdisplay) || |
141 (modes[i]->vdisplay != mode.vdisplay) ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
142 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); |
0 | 143 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
144 pXFree(modes); |
0 | 145 } |
146 } | |
147 #endif /* XFREE86_VM */ | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
148 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
149 /* XiG */ |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
150 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
151 #ifdef XIG_DEBUG |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
152 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
|
153 width, height); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
154 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
155 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
|
156 int i; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
157 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
158 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
|
159 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
|
160 (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
|
161 break; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
162 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
163 } |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
164 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
165 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
|
166 int w, h; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
167 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
168 /* 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
|
169 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
|
170 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
171 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
|
172 # 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
|
173 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
|
174 "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
|
175 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
|
176 # endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 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
|
178 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
179 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
180 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
|
181 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
|
182 0); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
183 pXSync(SDL_Display, False); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
184 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
185 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
186 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
187 #endif /* HAVE_XIGXME */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
188 |
0 | 189 } |
190 | |
191 static void get_real_resolution(_THIS, int* w, int* h) | |
192 { | |
193 #ifdef XFREE86_VM | |
194 if ( use_vidmode ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
195 SDL_NAME(XF86VidModeModeLine) mode; |
0 | 196 int unused; |
197 | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
198 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
0 | 199 *w = mode.hdisplay; |
200 *h = mode.vdisplay; | |
201 return; | |
202 } | |
203 } | |
204 #endif | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
205 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
206 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
207 if ( use_xme ) { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
208 int ractive; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
209 XiGMiscResolutionInfo *modelist; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
210 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
211 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
|
212 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
213 &ractive, &modelist); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
214 *w = modelist[ractive].width; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
215 *h = modelist[ractive].height; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
216 #ifdef XIG_DEBUG |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
217 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
|
218 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
219 XFree(modelist); |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
220 return; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
221 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
222 #endif /* XIG_XME */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
223 |
0 | 224 *w = DisplayWidth(SDL_Display, SDL_Screen); |
225 *h = DisplayHeight(SDL_Display, SDL_Screen); | |
226 } | |
227 | |
228 /* Called after mapping a window - waits until the window is mapped */ | |
229 void X11_WaitMapped(_THIS, Window win) | |
230 { | |
231 XEvent event; | |
232 do { | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
233 pXMaskEvent(SDL_Display, StructureNotifyMask, &event); |
0 | 234 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); |
235 } | |
236 | |
237 /* Called after unmapping a window - waits until the window is unmapped */ | |
238 void X11_WaitUnmapped(_THIS, Window win) | |
239 { | |
240 XEvent event; | |
241 do { | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
242 pXMaskEvent(SDL_Display, StructureNotifyMask, &event); |
0 | 243 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); |
244 } | |
245 | |
246 static void move_cursor_to(_THIS, int x, int y) | |
247 { | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
248 pXWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); |
0 | 249 } |
250 | |
251 static int add_visual(_THIS, int depth, int class) | |
252 { | |
253 XVisualInfo vi; | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
254 if(pXMatchVisualInfo(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
|
255 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
|
256 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
|
257 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
|
258 this->hidden->nvisuals++; |
0 | 259 } |
260 return(this->hidden->nvisuals); | |
261 } | |
262 static int add_visual_byid(_THIS, const char *visual_id) | |
263 { | |
264 XVisualInfo *vi, template; | |
265 int nvis; | |
266 | |
267 if ( visual_id ) { | |
268 memset(&template, 0, (sizeof template)); | |
269 template.visualid = strtol(visual_id, NULL, 0); | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
270 vi = pXGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); |
0 | 271 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
|
272 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
|
273 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
|
274 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
|
275 this->hidden->nvisuals++; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
276 pXFree(vi); |
0 | 277 } |
278 } | |
279 return(this->hidden->nvisuals); | |
280 } | |
281 | |
282 /* Global for the error handler */ | |
283 int vm_event, vm_error = -1; | |
284 | |
285 int X11_GetVideoModes(_THIS) | |
286 { | |
287 #ifdef XFREE86_VM | |
288 int buggy_X11; | |
289 int vm_major, vm_minor; | |
290 int nmodes; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
291 SDL_NAME(XF86VidModeModeInfo) **modes; |
0 | 292 #endif |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
293 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
294 int xme_major, xme_minor; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
295 int ractive, nummodes; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
296 XiGMiscResolutionInfo *modelist; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
297 #endif |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
298 int i, n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
299 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
300 int screen_h; |
0 | 301 |
302 vm_error = -1; | |
303 use_vidmode = 0; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
304 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
305 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
306 |
0 | 307 #ifdef XFREE86_VM |
308 /* Metro-X 4.3.0 and earlier has a broken implementation of | |
309 XF86VidModeGetAllModeLines() - it hangs the client. | |
310 */ | |
311 buggy_X11 = 0; | |
312 if ( strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { | |
313 FILE *metro_fp; | |
314 | |
315 metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); | |
316 if ( metro_fp != NULL ) { | |
317 int major, minor, patch, version; | |
318 major = 0; minor = 0; patch = 0; | |
319 fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch); | |
320 version = major*100+minor*10+patch; | |
321 if ( version < 431 ) { | |
322 buggy_X11 = 1; | |
323 } | |
324 fclose(metro_fp); | |
325 } | |
326 } | |
1262
09164d2b8373
Hopefully the X servers have been fixed (in 5 years) :)
Sam Lantinga <slouken@libsdl.org>
parents:
1196
diff
changeset
|
327 #if 0 /* Let's try this again... hopefully X servers have improved... */ |
607
f8710950cddc
Date: Sat, 1 Mar 2003 16:13:57 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
604
diff
changeset
|
328 #if defined(__alpha__) || defined(__sparc64__) || defined(__powerpc__) |
f8710950cddc
Date: Sat, 1 Mar 2003 16:13:57 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
604
diff
changeset
|
329 /* The alpha, sparc64 and PPC XFree86 servers are also buggy */ |
0 | 330 buggy_X11 = 1; |
331 #endif | |
1262
09164d2b8373
Hopefully the X servers have been fixed (in 5 years) :)
Sam Lantinga <slouken@libsdl.org>
parents:
1196
diff
changeset
|
332 #endif |
0 | 333 /* Enumerate the available fullscreen modes */ |
334 if ( ! buggy_X11 ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
335 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
|
336 SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, &vm_major, &vm_minor) ) { |
0 | 337 #ifdef BROKEN_XFREE86_4001 |
338 #ifdef X_XF86VidModeGetDotClocks /* Compiled under XFree86 4.0 */ | |
339 /* 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
|
340 if ( vm_major < 2 ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
341 #ifdef XFREE86_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
342 printf("Compiled under XFree86 4.0, server is XFree86 3.X\n"); |
0 | 343 #endif |
344 buggy_X11 = 1; | |
345 } | |
346 #else | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
347 /* XFree86 3.X code works with XFree86 4.0 servers */; |
0 | 348 #endif /* XFree86 4.0 */ |
349 #endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */ | |
350 } else { | |
351 buggy_X11 = 1; | |
352 } | |
353 } | |
354 if ( ! buggy_X11 && | |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
355 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) { |
0 | 356 |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
357 #ifdef XFREE86_DEBUG |
641
df178851293b
Date: 28 Jun 2003 22:42:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
637
diff
changeset
|
358 printf("Available modes: (sorted)\n"); |
637
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
359 for ( i = 0; i < nmodes; ++i ) { |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
360 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
|
361 modes[i]->hdisplay, modes[i]->vdisplay, |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
362 1000 * modes[i]->dotclock / (modes[i]->htotal * |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
363 modes[i]->vtotal) ); |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
364 } |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
365 #endif |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
366 |
6862d4294870
te: 27 Jun 2003 21:16:01 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
614
diff
changeset
|
367 qsort(modes, nmodes, sizeof *modes, cmpmodes); |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
368 SDL_modelist = (SDL_Rect **)malloc((nmodes+2)*sizeof(SDL_Rect *)); |
0 | 369 if ( SDL_modelist ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
370 n = 0; |
0 | 371 for ( i=0; i<nmodes; ++i ) { |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
372 int w, h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
373 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
374 /* 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
|
375 w = modes[i]->hdisplay; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
376 h = modes[i]->vdisplay; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
377 if ( (screen_w * screen_h) >= (w * h) ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
378 if ( (screen_w != w) || (screen_h != h) ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
379 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
|
380 if ( SDL_modelist[n] ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
381 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
382 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
383 SDL_modelist[n]->w = screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
384 SDL_modelist[n]->h = screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
385 ++n; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
386 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
387 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
388 screen_w = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
389 screen_h = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
390 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
391 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
392 /* Add the size from the video mode list */ |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
393 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
|
394 if ( SDL_modelist[n] == NULL ) { |
0 | 395 break; |
396 } | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
397 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
398 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
399 SDL_modelist[n]->w = w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
400 SDL_modelist[n]->h = h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
401 ++n; |
0 | 402 } |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
403 SDL_modelist[n] = NULL; |
0 | 404 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
405 pXFree(modes); |
0 | 406 |
100
a1c973c35fef
Fixed using the video mode extension on older servers
Sam Lantinga <slouken@lokigames.com>
parents:
98
diff
changeset
|
407 use_vidmode = vm_major * 100 + vm_minor; |
0 | 408 save_mode(this); |
409 } | |
410 #endif /* XFREE86_VM */ | |
411 | |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
412 /* XiG */ |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
413 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
414 /* 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
|
415 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
|
416 #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
|
417 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
|
418 xme_major, xme_minor); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
419 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
420 /* 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
|
421 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
|
422 /* 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
|
423 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
|
424 libXext version. |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
425 */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
426 fprintf(stderr, |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
427 "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
|
428 "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
|
429 "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
|
430 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
431 } else { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
432 /* 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
|
433 xme_major = xme_minor = 0; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
434 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
435 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
436 modelist = NULL; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
437 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
|
438 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
439 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
440 &ractive, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
441 &modelist)) > 1) |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
442 { /* 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
|
443 int j; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
444 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
445 #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
|
446 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
|
447 nummodes, ractive); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
448 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
449 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
450 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
|
451 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
452 /* 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
|
453 /* 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
|
454 /* 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
|
455 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
|
456 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
|
457 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
|
458 (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
|
459 break; |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
460 #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
|
461 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
|
462 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
|
463 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
464 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
465 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
|
466 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
|
467 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
|
468 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
|
469 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
470 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
471 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
|
472 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
473 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
|
474 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
|
475 } else { |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
476 use_xme = 0; |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
477 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
478 if ( modelist ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
479 pXFree(modelist); |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
480 } |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
481 #endif /* HAVE_XIGXME */ |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
482 |
0 | 483 { |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
484 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
|
485 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
|
486 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
|
487 XPixmapFormatValues *pf; |
0 | 488 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
489 /* 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
|
490 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
|
491 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
|
492 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
|
493 } |
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->nvisuals = 0; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
495 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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
501 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
|
502 } else { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
503 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
|
504 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
|
505 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
506 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
507 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
508 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
|
509 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
|
510 return -1; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
511 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
512 |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
513 /* look up the pixel quantum for each depth */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
514 pf = pXListPixmapFormats(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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 break; |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
520 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
|
521 } |
0 | 522 |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
523 pXFree(pf); |
0 | 524 } |
525 | |
526 if ( SDL_modelist == NULL ) { | |
527 SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); | |
528 if ( SDL_modelist ) { | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
529 n = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
530 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
|
531 if ( SDL_modelist[n] ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
532 SDL_modelist[n]->x = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
533 SDL_modelist[n]->y = 0; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
534 SDL_modelist[n]->w = screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
535 SDL_modelist[n]->h = screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
536 ++n; |
0 | 537 } |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
538 SDL_modelist[n] = NULL; |
0 | 539 } |
540 } | |
541 | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
542 #if defined(XFREE86_DEBUG) || defined(XIG_DEBUG) |
0 | 543 if ( use_vidmode ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
544 printf("XFree86 VidMode is enabled\n"); |
0 | 545 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
546 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
547 #ifdef HAVE_XIGXME |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
548 if ( use_xme ) |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
549 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
|
550 else |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
551 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
|
552 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
553 |
0 | 554 if ( SDL_modelist ) { |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
555 printf("X11 video mode list:\n"); |
0 | 556 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
|
557 printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h); |
0 | 558 } |
559 } | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
560 #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
|
561 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
562 /* 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
|
563 xinerama_x = 0; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
564 xinerama_y = 0; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
565 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
566 #ifdef HAVE_XINERAMA |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
567 /* Query Xinerama extention */ |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
568 if ( SDL_NAME(XineramaQueryExtension)(SDL_Display, &i, &i) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
569 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
|
570 /* 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
|
571 int desired = 0; |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
572 int screens; |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
573 SDL_NAME(XineramaScreenInfo) *xinerama; |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
574 |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
575 #ifdef XINERAMA_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
576 printf("X11 detected Xinerama:\n"); |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
577 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
578 #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
|
579 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
|
580 if ( variable ) { |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
581 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
|
582 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
583 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
584 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
|
585 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
|
586 #ifdef XINERAMA_DEBUG |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
587 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
|
588 xinerama[i].screen_number, |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
589 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
|
590 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
|
591 #endif |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
592 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
|
593 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
|
594 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
|
595 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
596 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
597 pXFree(xinerama); |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
598 } |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
599 #endif /* HAVE_XINERAMA */ |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
600 |
0 | 601 return 0; |
602 } | |
603 | |
604 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) | |
605 { | |
606 int i; | |
607 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
|
608 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
|
609 return 1; |
0 | 610 return 0; |
611 } | |
612 | |
613 SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
614 { | |
615 if ( X11_SupportedVisual(this, format) ) { | |
616 if ( flags & SDL_FULLSCREEN ) { | |
617 return(SDL_modelist); | |
618 } else { | |
619 return((SDL_Rect **)-1); | |
620 } | |
621 } else { | |
622 return((SDL_Rect **)0); | |
623 } | |
624 } | |
625 | |
626 void X11_FreeVideoModes(_THIS) | |
627 { | |
628 int i; | |
629 | |
630 if ( SDL_modelist ) { | |
631 for ( i=0; SDL_modelist[i]; ++i ) { | |
632 free(SDL_modelist[i]); | |
633 } | |
634 free(SDL_modelist); | |
635 SDL_modelist = NULL; | |
636 } | |
637 } | |
638 | |
639 int X11_ResizeFullScreen(_THIS) | |
640 { | |
641 int x, y; | |
642 int real_w, real_h; | |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
643 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
644 int screen_h; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
645 |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
646 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
647 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
0 | 648 |
227
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
649 x = xinerama_x; |
24878c14b391
Added X11 Xinerama support - fullscreen starts on screen 0
Sam Lantinga <slouken@libsdl.org>
parents:
100
diff
changeset
|
650 y = xinerama_y; |
0 | 651 if ( currently_fullscreen ) { |
652 /* 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
|
653 move_cursor_to(this, x, y); |
0 | 654 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
|
655 move_cursor_to(this, x, y); |
0 | 656 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
|
657 if ( current_w > real_w ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
658 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
659 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
660 if ( current_h > real_h ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
661 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
662 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
663 pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); |
0 | 664 move_cursor_to(this, real_w/2, real_h/2); |
665 | |
666 /* Center and reparent the drawing window */ | |
667 x = (real_w - current_w)/2; | |
668 y = (real_h - current_h)/2; | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
669 pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); |
0 | 670 /* FIXME: move the mouse to the old relative location */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
671 pXSync(SDL_Display, True); /* Flush spurious mode change events */ |
0 | 672 } |
673 return(1); | |
674 } | |
675 | |
676 void X11_QueueEnterFullScreen(_THIS) | |
677 { | |
678 switch_waiting = 0x01 | SDL_FULLSCREEN; | |
679 switch_time = SDL_GetTicks() + 1500; | |
680 #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
681 pXSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); |
0 | 682 #endif |
683 } | |
684 | |
685 int X11_EnterFullScreen(_THIS) | |
686 { | |
687 int okay; | |
688 #if 0 | |
689 Window tmpwin, *windows; | |
690 int i, nwindows; | |
691 #endif | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
692 int real_w, real_h; |
230
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
693 int screen_w; |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
694 int screen_h; |
0 | 695 |
696 okay = 1; | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
697 if ( currently_fullscreen ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
698 return(okay); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
699 } |
0 | 700 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
701 /* 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
|
702 X11_GrabInputNoLock(this, SDL_GRAB_OFF); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
703 |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
704 /* 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
|
705 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
706 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
|
707 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
|
708 if ( current_w > real_w ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
709 real_w = MAX(real_w, screen_w); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
710 } |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
711 if ( current_h > real_h ) { |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
712 real_h = MAX(real_h, screen_h); |
275a934573a7
Greatly improved Xinerama video mode support
Sam Lantinga <slouken@libsdl.org>
parents:
227
diff
changeset
|
713 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
714 pXMoveResizeWindow(SDL_Display, FSwindow, |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
715 xinerama_x, xinerama_y, real_w, real_h); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
716 pXMapRaised(SDL_Display, FSwindow); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
717 X11_WaitMapped(this, FSwindow); |
0 | 718 |
719 #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
|
720 /* Make sure we got to the top of the window stack */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
721 if ( pXQueryTree(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
|
722 &windows, &nwindows) && windows ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
723 /* 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
|
724 if ( windows[nwindows-1] != FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
725 tmpwin = windows[nwindows-1]; |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
726 for ( i=0; i<nwindows; ++i ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
727 if ( windows[i] == FSwindow ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
728 memcpy(&windows[i], &windows[i+1], |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
729 (nwindows-i-1)*sizeof(windows[i])); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
730 break; |
0 | 731 } |
732 } | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
733 windows[nwindows-1] = FSwindow; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
734 pXRestackWindows(SDL_Display, windows, nwindows); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
735 pXSync(SDL_Display, False); |
0 | 736 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
737 pXFree(windows); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
738 } |
0 | 739 #else |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
740 pXRaiseWindow(SDL_Display, FSwindow); |
0 | 741 #endif |
742 | |
743 #ifdef XFREE86_VM | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
744 /* Save the current video mode */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
745 if ( use_vidmode ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
746 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
|
747 } |
0 | 748 #endif |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
749 currently_fullscreen = 1; |
0 | 750 |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
751 /* Set the new resolution */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
752 okay = X11_ResizeFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
753 if ( ! okay ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
754 X11_LeaveFullScreen(this); |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
755 } |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
756 /* Set the colormap */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
91
diff
changeset
|
757 if ( SDL_XColorMap ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
758 pXInstallColormap(SDL_Display, SDL_XColorMap); |
0 | 759 } |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
760 if ( okay ) |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
761 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
|
762 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
763 /* 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
|
764 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
|
765 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
766 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
767 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
768 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
769 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
770 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
771 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
772 |
0 | 773 return(okay); |
774 } | |
775 | |
776 int X11_LeaveFullScreen(_THIS) | |
777 { | |
778 if ( currently_fullscreen ) { | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
779 pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); |
0 | 780 #ifdef XFREE86_VM |
781 if ( use_vidmode ) { | |
782 restore_mode(this); | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
783 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); |
0 | 784 } |
785 #endif | |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
786 |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
787 #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
|
788 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
|
789 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
|
790 |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
791 /* 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
|
792 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
|
793 |
499
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
794 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
|
795 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
|
796 SDL_Screen, |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
797 0, /* view */ |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
798 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
|
799 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
|
800 0); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
801 pXSync(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
|
802 } |
f480ecd70499
Added an aborted try at making fullscreen work on Xinerama screen != 0
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
803 } |
242
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
804 #endif |
4bcb29d3769c
Added support for Xi Graphics XME fullscreen extension
Sam Lantinga <slouken@libsdl.org>
parents:
230
diff
changeset
|
805 |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
806 pXUnmapWindow(SDL_Display, FSwindow); |
0 | 807 X11_WaitUnmapped(this, FSwindow); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
966
diff
changeset
|
808 pXSync(SDL_Display, True); /* Flush spurious mode change events */ |
0 | 809 currently_fullscreen = 0; |
810 } | |
811 /* If we get popped out of fullscreen mode for some reason, input_grab | |
812 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only | |
813 temporary. In this case, release the grab unless the input has been | |
814 explicitly grabbed. | |
815 */ | |
816 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
|
817 |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
818 /* 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
|
819 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
|
820 if ( this->screen ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
821 if ( this->screen->flags & SDL_OPENGL ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
822 SDL_PrivateExpose(); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
823 } else { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
824 X11_RefreshDisplay(this); |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
825 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
826 } |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
827 |
0 | 828 return(0); |
829 } |