annotate src/video/x11/SDL_x11modes.c @ 4159:a1b03ba2fcd0 SDL-1.2

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