Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11video.c @ 5187:d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 04 Feb 2011 19:50:56 -0800 |
parents | 073b86030262 |
children | 3a8a452b49f0 |
rev | line source |
---|---|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
24 #include <unistd.h> /* For getpid() and readlink() */ |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
25 |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_video.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "SDL_mouse.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "../SDL_sysvideo.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../SDL_pixels_c.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #include "SDL_x11video.h" |
5185
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
32 #include "SDL_x11framebuffer.h" |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4459
diff
changeset
|
33 #include "SDL_x11shape.h" |
4923
1002d074d459
Renamed X11 touch files for consistency
Sam Lantinga <slouken@libsdl.org>
parents:
4862
diff
changeset
|
34 #include "SDL_x11touch.h" |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
35 |
3218 | 36 #if SDL_VIDEO_DRIVER_PANDORA |
37 #include "SDL_x11opengles.h" | |
38 #endif | |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 /* Initialization/Query functions */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 static int X11_VideoInit(_THIS); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 static void X11_VideoQuit(_THIS); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
44 /* Find out what class name we should use */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
45 static char * |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
46 get_classname() |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
47 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
48 char *spot; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
49 #if defined(__LINUX__) || defined(__FREEBSD__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
50 char procfile[1024]; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
51 char linkfile[1024]; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
52 int linksize; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
53 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
54 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
55 /* First allow environment variable override */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
56 spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
57 if (spot) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
58 return SDL_strdup(spot); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
59 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
60 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
61 /* Next look at the application's executable name */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
62 #if defined(__LINUX__) || defined(__FREEBSD__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
63 #if defined(__LINUX__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
64 SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid()); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
65 #elif defined(__FREEBSD__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
66 SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
67 getpid()); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
68 #else |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
69 #error Where can we find the executable name? |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
70 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
71 linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
72 if (linksize > 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
73 linkfile[linksize] = '\0'; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
74 spot = SDL_strrchr(linkfile, '/'); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
75 if (spot) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
76 return SDL_strdup(spot + 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
77 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
78 return SDL_strdup(linkfile); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
79 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
80 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
81 #endif /* __LINUX__ || __FREEBSD__ */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
82 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
83 /* Finally use the default we've used forever */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
84 return SDL_strdup("SDL_App"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
85 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
86 |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 /* X11 driver bootstrap functions */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 static int |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 X11_Available(void) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 Display *display = NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 if (SDL_X11_LoadSymbols()) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 display = XOpenDisplay(NULL); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 if (display != NULL) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 XCloseDisplay(display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 SDL_X11_UnloadSymbols(); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 return (display != NULL); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 static void |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 X11_DeleteDevice(SDL_VideoDevice * device) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 SDL_VideoData *data = (SDL_VideoData *) device->driverdata; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 if (data->display) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 XCloseDisplay(data->display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 } |
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
110 SDL_free(data->windowlist); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 SDL_free(device->driverdata); |
3218 | 112 #if SDL_VIDEO_DRIVER_PANDORA |
113 SDL_free(device->gles_data); | |
114 #endif | |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 SDL_free(device); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 SDL_X11_UnloadSymbols(); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 static SDL_VideoDevice * |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 X11_CreateDevice(int devindex) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 SDL_VideoDevice *device; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 SDL_VideoData *data; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 const char *display = NULL; /* Use the DISPLAY environment variable */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 if (!SDL_X11_LoadSymbols()) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 return NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 /* Initialize all variables that we clean on shutdown */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
133 if (!device) { |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
134 SDL_OutOfMemory(); |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
135 return NULL; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 } |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
137 data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
138 if (!data) { |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 SDL_OutOfMemory(); |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
140 SDL_free(device); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 return NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 device->driverdata = data; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
3218 | 145 #if SDL_VIDEO_DRIVER_PANDORA |
146 device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData)); | |
147 if (!device->gles_data) { | |
148 SDL_OutOfMemory(); | |
149 return NULL; | |
150 } | |
151 #endif | |
152 | |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 /* FIXME: Do we need this? |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) || |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 local_X11 = 1; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 } else { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 local_X11 = 0; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 data->display = XOpenDisplay(display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 /* On Tru64 if linking without -lX11, it fails and you get following message. |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 * Xlib: connection to ":0.0" refused by server |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 * Xlib: XDM authorization key matches an existing client! |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 * |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 * It succeeds if retrying 1 second later |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 * or if running xhost +localhost on shell. |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 if (data->display == NULL) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 SDL_Delay(1000); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 data->display = XOpenDisplay(display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 #endif |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 if (data->display == NULL) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 SDL_free(device); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 SDL_SetError("Couldn't open X11 display"); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 return NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 #ifdef X11_DEBUG |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 XSynchronize(data->display, True); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 #endif |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 /* Set the function pointers */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 device->VideoInit = X11_VideoInit; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 device->VideoQuit = X11_VideoQuit; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 device->GetDisplayModes = X11_GetDisplayModes; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 device->SetDisplayMode = X11_SetDisplayMode; |
2162
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
1952
diff
changeset
|
189 device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp; |
1d23870d8c49
Added stubs for x11 gamma functions and enabled them in SDL_x11video.c
Bob Pendleton <bob@pendleton.com>
parents:
1952
diff
changeset
|
190 device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp; |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
191 device->SuspendScreenSaver = X11_SuspendScreenSaver; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
192 device->PumpEvents = X11_PumpEvents; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 device->CreateWindow = X11_CreateWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 device->CreateWindowFrom = X11_CreateWindowFrom; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 device->SetWindowTitle = X11_SetWindowTitle; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2963
diff
changeset
|
197 device->SetWindowIcon = X11_SetWindowIcon; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 device->SetWindowPosition = X11_SetWindowPosition; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 device->SetWindowSize = X11_SetWindowSize; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 device->ShowWindow = X11_ShowWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 device->HideWindow = X11_HideWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 device->RaiseWindow = X11_RaiseWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 device->MaximizeWindow = X11_MaximizeWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 device->MinimizeWindow = X11_MinimizeWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 device->RestoreWindow = X11_RestoreWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 device->SetWindowGrab = X11_SetWindowGrab; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 device->DestroyWindow = X11_DestroyWindow; |
5185
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
208 device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; |
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
209 device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; |
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
210 device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 device->GetWindowWMInfo = X11_GetWindowWMInfo; |
5185
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
212 |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4459
diff
changeset
|
213 device->shape_driver.CreateShaper = X11_CreateShaper; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4459
diff
changeset
|
214 device->shape_driver.SetWindowShape = X11_SetWindowShape; |
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4459
diff
changeset
|
215 device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; |
5185
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
216 |
5090 | 217 #if SDL_VIDEO_OPENGL_GLX |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 device->GL_LoadLibrary = X11_GL_LoadLibrary; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 device->GL_GetProcAddress = X11_GL_GetProcAddress; |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
220 device->GL_UnloadLibrary = X11_GL_UnloadLibrary; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 device->GL_CreateContext = X11_GL_CreateContext; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 device->GL_MakeCurrent = X11_GL_MakeCurrent; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 device->GL_SetSwapInterval = X11_GL_SetSwapInterval; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 device->GL_GetSwapInterval = X11_GL_GetSwapInterval; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 device->GL_SwapWindow = X11_GL_SwapWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 device->GL_DeleteContext = X11_GL_DeleteContext; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 #endif |
3218 | 228 #if SDL_VIDEO_DRIVER_PANDORA |
229 device->GL_LoadLibrary = X11_GLES_LoadLibrary; | |
230 device->GL_GetProcAddress = X11_GLES_GetProcAddress; | |
231 device->GL_UnloadLibrary = X11_GLES_UnloadLibrary; | |
232 device->GL_CreateContext = X11_GLES_CreateContext; | |
233 device->GL_MakeCurrent = X11_GLES_MakeCurrent; | |
234 device->GL_SetSwapInterval = X11_GLES_SetSwapInterval; | |
235 device->GL_GetSwapInterval = X11_GLES_GetSwapInterval; | |
236 device->GL_SwapWindow = X11_GLES_SwapWindow; | |
237 device->GL_DeleteContext = X11_GLES_DeleteContext; | |
238 #endif | |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
240 device->SetClipboardText = X11_SetClipboardText; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
241 device->GetClipboardText = X11_GetClipboardText; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
242 device->HasClipboardText = X11_HasClipboardText; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
243 |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 device->free = X11_DeleteDevice; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 return device; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 VideoBootStrap X11_bootstrap = { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 "x11", "SDL X11 video driver", |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 X11_Available, X11_CreateDevice |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 }; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
4559
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
254 static int (*handler) (Display *, XErrorEvent *) = NULL; |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
255 static int |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
256 X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e) |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
257 { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
258 if (e->error_code == BadWindow) { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
259 return (0); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
260 } else { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
261 return (handler(d, e)); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
262 } |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
263 } |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
265 static void |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
266 X11_CheckWindowManager(_THIS) |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
267 { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
268 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
269 Display *display = data->display; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
270 Atom _NET_SUPPORTING_WM_CHECK; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
271 int status, real_format; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
272 Atom real_type; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
273 unsigned long items_read, items_left; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
274 unsigned char *propdata; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
275 Window wm_window = 0; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
276 #ifdef DEBUG_WINDOW_MANAGER |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
277 char *wm_name; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
278 #endif |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
279 |
4559
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
280 /* Set up a handler to gracefully catch errors */ |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
281 XSync(display, False); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
282 handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
283 |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
284 _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
285 status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
286 if (status == Success && items_read) { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
287 wm_window = ((Window*)propdata)[0]; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
288 } |
4559
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
289 if (propdata) { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
290 XFree(propdata); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
291 } |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
292 |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
293 if (wm_window) { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
294 status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
295 if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
296 wm_window = None; |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
297 } |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
298 if (propdata) { |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
299 XFree(propdata); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
300 } |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
301 } |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
302 |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
303 /* Reset the error handler, we're done checking */ |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
304 XSync(display, False); |
f8c3870af5a2
Fixed X11 error when running under window managers that don't support the _NET_SUPPORTING_WM_CHECK protocol.
Sam Lantinga <slouken@libsdl.org>
parents:
4518
diff
changeset
|
305 XSetErrorHandler(handler); |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
306 |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
307 if (!wm_window) { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
308 #ifdef DEBUG_WINDOW_MANAGER |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
309 printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n"); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
310 #endif |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
311 return; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
312 } |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
313 data->net_wm = SDL_TRUE; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
314 |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
315 #ifdef DEBUG_WINDOW_MANAGER |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
316 wm_name = X11_GetWindowTitle(_this, wm_window); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
317 printf("Window manager: %s\n", wm_name); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
318 SDL_free(wm_name); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
319 #endif |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
320 } |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 int |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 X11_VideoInit(_THIS) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
325 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
326 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
327 /* Get the window class name, usually the name of the application */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
328 data->classname = get_classname(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
329 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
330 /* Open a connection to the X input manager */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
331 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
332 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
333 data->im = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
334 XOpenIM(data->display, NULL, data->classname, data->classname); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
335 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
336 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
337 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
338 /* Look up some useful Atoms */ |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
339 #define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
340 GET_ATOM(WM_DELETE_WINDOW); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
341 GET_ATOM(_NET_WM_STATE); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
342 GET_ATOM(_NET_WM_STATE_HIDDEN); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
343 GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
344 GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
345 GET_ATOM(_NET_WM_STATE_FULLSCREEN); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
346 GET_ATOM(_NET_WM_NAME); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
347 GET_ATOM(_NET_WM_ICON_NAME); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
348 GET_ATOM(_NET_WM_ICON); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
349 GET_ATOM(UTF8_STRING); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
350 |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
351 /* Detect the window manager */ |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
352 X11_CheckWindowManager(_this); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
353 |
3521
76f9b76ddf0f
Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents:
3218
diff
changeset
|
354 if (X11_InitModes(_this) < 0) { |
76f9b76ddf0f
Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents:
3218
diff
changeset
|
355 return -1; |
76f9b76ddf0f
Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents:
3218
diff
changeset
|
356 } |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
2295
dbc6d1893869
Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents:
2162
diff
changeset
|
358 if (X11_InitKeyboard(_this) != 0) { |
dbc6d1893869
Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents:
2162
diff
changeset
|
359 return -1; |
dbc6d1893869
Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents:
2162
diff
changeset
|
360 } |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 X11_InitMouse(_this); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
4459
diff
changeset
|
363 X11_InitTouch(_this); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 return 0; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 void |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 X11_VideoQuit(_THIS) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
370 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
371 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
372 if (data->classname) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
373 SDL_free(data->classname); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
374 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
375 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
376 if (data->im) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
377 XCloseIM(data->im); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
378 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
379 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
380 |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 X11_QuitModes(_this); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 X11_QuitKeyboard(_this); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 X11_QuitMouse(_this); |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
4459
diff
changeset
|
384 X11_QuitTouch(_this); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 |
2963
ee331407574f
Don't use DirectColor visuals until we implement DirectColor colormap support
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
387 SDL_bool |
4472
791b3256fb22
Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents:
4459
diff
changeset
|
388 X11_UseDirectColorVisuals(void) |
2963
ee331407574f
Don't use DirectColor visuals until we implement DirectColor colormap support
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
389 { |
3013
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
390 /* Once we implement DirectColor colormaps and gamma ramp support... |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
391 return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE; |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
392 */ |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
393 return SDL_FALSE; |
2963
ee331407574f
Don't use DirectColor visuals until we implement DirectColor colormap support
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
394 } |
ee331407574f
Don't use DirectColor visuals until we implement DirectColor colormap support
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
395 |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 /* vim: set ts=4 sw=4 expandtab: */ |