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