annotate src/video/x11/SDL_x11modes.c @ 410:365f57b7c4ac

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