0
|
1 /*
|
|
2 SDL - Simple DirectMedia Layer
|
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
|
4
|
|
5 This library is free software; you can redistribute it and/or
|
|
6 modify it under the terms of the GNU Library General Public
|
|
7 License as published by the Free Software Foundation; either
|
|
8 version 2 of the License, or (at your option) any later version.
|
|
9
|
|
10 This library is distributed in the hope that it will be useful,
|
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 Library General Public License for more details.
|
|
14
|
|
15 You should have received a copy of the GNU Library General Public
|
|
16 License along with this library; if not, write to the Free
|
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
|
19 Sam Lantinga
|
|
20 slouken@devolution.com
|
|
21 */
|
|
22
|
|
23 #ifdef SAVE_RCSID
|
|
24 static char rcsid =
|
|
25 "@(#) $Id$";
|
|
26 #endif
|
|
27
|
|
28 #ifndef _SDL_x11video_h
|
|
29 #define _SDL_x11video_h
|
|
30
|
|
31 #include <X11/Xlib.h>
|
|
32 #include <X11/Xutil.h>
|
|
33 #include <X11/Xatom.h>
|
|
34 #ifndef NO_SHARED_MEMORY
|
|
35 #include <sys/ipc.h>
|
|
36 #include <sys/shm.h>
|
|
37 #include <X11/extensions/XShm.h>
|
|
38 #endif
|
|
39 #ifdef XFREE86_DGAMOUSE
|
|
40 #include <X11/extensions/xf86dga.h>
|
|
41 #endif
|
|
42 #ifdef XFREE86_VM
|
|
43 #include <X11/extensions/xf86vmode.h>
|
|
44 #ifdef XFREE86_VM_DYNAMIC_HACK
|
|
45 #define XVidMode(func, args) XF40VidMode##func args
|
|
46 #else
|
|
47 #define XVidMode(func, args) XF86VidMode##func args
|
|
48 #endif
|
|
49 #endif /* XFREE86_VM */
|
|
50 #include <string.h>
|
|
51
|
|
52 #include "SDL_mouse.h"
|
|
53 #include "SDL_sysvideo.h"
|
|
54
|
|
55 /* Hidden "this" pointer for the video functions */
|
|
56 #define _THIS SDL_VideoDevice *this
|
|
57
|
|
58 /* Private display data */
|
|
59 struct SDL_PrivateVideoData {
|
|
60 int local_X11; /* Flag: true if local display */
|
|
61 Display *X11_Display; /* Used for events and window management */
|
|
62 Display *GFX_Display; /* Used for graphics and colormap stuff */
|
|
63 Visual *SDL_Visual; /* The visual used by our window */
|
|
64 Window WMwindow; /* Input window, managed by window manager */
|
|
65 Window FSwindow; /* Fullscreen window, completely unmanaged */
|
|
66 Window SDL_Window; /* Shared by both displays (no X security?) */
|
|
67 Atom WM_DELETE_WINDOW; /* "close-window" protocol atom */
|
|
68 WMcursor *BlankCursor; /* The invisible cursor */
|
|
69
|
|
70 char *SDL_windowid; /* Flag: true if we have been passed a window */
|
|
71
|
|
72 /* Direct Graphics Access extension information */
|
|
73 int using_dga;
|
|
74
|
|
75 #ifndef NO_SHARED_MEMORY
|
|
76 /* MIT shared memory extension information */
|
|
77 int use_mitshm;
|
|
78 XShmSegmentInfo shminfo;
|
|
79 #endif
|
|
80
|
|
81 /* The variables used for displaying graphics */
|
|
82 XImage *Ximage; /* The X image for our window */
|
|
83 GC gc; /* The graphic context for drawing */
|
|
84 int swap_pixels; /* Flag: true if display is swapped endian */
|
|
85
|
|
86 /* The current width and height of the fullscreen mode */
|
|
87 int current_w;
|
|
88 int current_h;
|
|
89
|
|
90 /* Support for internal mouse warping */
|
|
91 struct {
|
|
92 int x;
|
|
93 int y;
|
|
94 } mouse_last;
|
|
95 struct {
|
|
96 int numerator;
|
|
97 int denominator;
|
|
98 int threshold;
|
|
99 } mouse_accel;
|
|
100 int mouse_relative;
|
|
101
|
|
102 /* The current list of available video modes */
|
|
103 SDL_Rect **modelist;
|
|
104
|
|
105 /* available visuals of interest to us, sorted deepest first */
|
|
106 struct {
|
|
107 Visual *visual;
|
|
108 int depth; /* number of significant bits/pixel */
|
|
109 int bpp; /* pixel quantum in bits */
|
|
110 } visuals[2*5]; /* at most 2 entries for 8, 15, 16, 24, 32 */
|
|
111 int nvisuals;
|
|
112
|
|
113 Visual *vis; /* current visual in use */
|
|
114 int depth; /* current visual depth (not bpp) */
|
|
115
|
|
116 /* Variables used by the X11 video mode code */
|
|
117 #ifdef XFREE86_VM
|
|
118 XF86VidModeModeInfo saved_mode;
|
|
119 struct {
|
|
120 int x, y;
|
|
121 } saved_view;
|
|
122 #endif
|
|
123 int use_vidmode;
|
|
124 int currently_fullscreen;
|
|
125
|
|
126 /* Automatic mode switching support (entering/leaving fullscreen) */
|
|
127 Uint32 switch_waiting;
|
|
128 Uint32 switch_time;
|
|
129
|
|
130 /* Prevent too many XSync() calls */
|
|
131 int blit_queued;
|
|
132
|
|
133 /* Colormap handling */
|
|
134 Colormap DisplayColormap; /* The default display colormap */
|
|
135 Colormap XColorMap; /* The current window colormap */
|
|
136 int *XPixels; /* pixels value allocation counts */
|
|
137 float gamma_saved[3]; /* Saved gamma values for VidMode gamma */
|
|
138 int gamma_changed; /* flag: has VidMode gamma been modified? */
|
|
139
|
|
140 short *iconcolors; /* List of colors used by the icon */
|
|
141 };
|
|
142
|
|
143 /* Old variable names */
|
|
144 #define local_X11 (this->hidden->local_X11)
|
|
145 #define SDL_Display (this->hidden->X11_Display)
|
|
146 #define GFX_Display (this->hidden->GFX_Display)
|
|
147 #define SDL_Screen DefaultScreen(this->hidden->X11_Display)
|
|
148
|
|
149 #define SDL_Visual (this->hidden->vis)
|
|
150
|
|
151 #define SDL_Root RootWindow(SDL_Display, SDL_Screen)
|
|
152 #define WMwindow (this->hidden->WMwindow)
|
|
153 #define FSwindow (this->hidden->FSwindow)
|
|
154 #define SDL_Window (this->hidden->SDL_Window)
|
|
155 #define WM_DELETE_WINDOW (this->hidden->WM_DELETE_WINDOW)
|
|
156 #define SDL_BlankCursor (this->hidden->BlankCursor)
|
|
157 #define SDL_windowid (this->hidden->SDL_windowid)
|
|
158 #define using_dga (this->hidden->using_dga)
|
|
159 #define use_mitshm (this->hidden->use_mitshm)
|
|
160 #define shminfo (this->hidden->shminfo)
|
|
161 #define SDL_Ximage (this->hidden->Ximage)
|
|
162 #define SDL_GC (this->hidden->gc)
|
|
163 #define swap_pixels (this->hidden->swap_pixels)
|
|
164 #define current_w (this->hidden->current_w)
|
|
165 #define current_h (this->hidden->current_h)
|
|
166 #define mouse_last (this->hidden->mouse_last)
|
|
167 #define mouse_accel (this->hidden->mouse_accel)
|
|
168 #define mouse_relative (this->hidden->mouse_relative)
|
|
169 #define SDL_modelist (this->hidden->modelist)
|
|
170 #define saved_mode (this->hidden->saved_mode)
|
|
171 #define saved_view (this->hidden->saved_view)
|
|
172 #define use_vidmode (this->hidden->use_vidmode)
|
|
173 #define currently_fullscreen (this->hidden->currently_fullscreen)
|
|
174 #define switch_waiting (this->hidden->switch_waiting)
|
|
175 #define switch_time (this->hidden->switch_time)
|
|
176 #define blit_queued (this->hidden->blit_queued)
|
|
177 #define SDL_DisplayColormap (this->hidden->DisplayColormap)
|
|
178 #define SDL_PrivateColormap (this->hidden->PrivateColormap)
|
|
179 #define SDL_XColorMap (this->hidden->XColorMap)
|
|
180 #define SDL_XPixels (this->hidden->XPixels)
|
|
181 #define gamma_saved (this->hidden->gamma_saved)
|
|
182 #define gamma_changed (this->hidden->gamma_changed)
|
|
183 #define SDL_iconcolors (this->hidden->iconcolors)
|
|
184
|
|
185 /* Some versions of XFree86 have bugs - detect if this is one of them */
|
|
186 #define BUGGY_XFREE86(condition, buggy_version) \
|
|
187 ((strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
|
|
188 (VendorRelease(SDL_Display) condition buggy_version))
|
|
189
|
|
190 #endif /* _SDL_x11video_h */
|