author | Michael Sartain <mikesart@valvesoftware.com> |
Thu, 11 Oct 2012 09:37:38 -0700 | |
changeset 6569 | 1f4e69a8e5e6 |
parent 6498 | 93d9b2a2eb0e |
child 6637 | 31e3f5b04120 |
permissions | -rw-r--r-- |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
2 |
Simple DirectMedia Layer |
6138 | 3 |
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
7 |
arising from the use of this software. |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
11 |
freely, subject to the following restrictions: |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
5481
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
23 |
#if SDL_VIDEO_DRIVER_X11 |
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
24 |
|
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
25 |
#include <unistd.h> /* For getpid() and readlink() */ |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
26 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
#include "SDL_video.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
#include "SDL_mouse.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
#include "../SDL_sysvideo.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
#include "../SDL_pixels_c.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
#include "SDL_x11video.h" |
5182
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5138
diff
changeset
|
33 |
#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
|
34 |
#include "SDL_x11shape.h" |
4923
1002d074d459
Renamed X11 touch files for consistency
Sam Lantinga <slouken@libsdl.org>
parents:
4862
diff
changeset
|
35 |
#include "SDL_x11touch.h" |
6316
a89c79a3f0cd
1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6312
diff
changeset
|
36 |
#include "SDL_x11xinput2.h" |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2324
diff
changeset
|
37 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
38 |
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 |
3218 | 39 |
#include "SDL_x11opengles.h" |
40 |
#endif |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
/* Initialization/Query functions */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
static int X11_VideoInit(_THIS); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
static void X11_VideoQuit(_THIS); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
46 |
/* 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
|
47 |
static char * |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
48 |
get_classname() |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
49 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
50 |
char *spot; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
51 |
#if defined(__LINUX__) || defined(__FREEBSD__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
52 |
char procfile[1024]; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
53 |
char linkfile[1024]; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
54 |
int linksize; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
55 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
56 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
57 |
/* First allow environment variable override */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
58 |
spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
59 |
if (spot) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
60 |
return SDL_strdup(spot); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
61 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
62 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
63 |
/* 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
|
64 |
#if defined(__LINUX__) || defined(__FREEBSD__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
65 |
#if defined(__LINUX__) |
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/exe", getpid()); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
67 |
#elif defined(__FREEBSD__) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
68 |
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
|
69 |
getpid()); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
70 |
#else |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
71 |
#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
|
72 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
73 |
linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
74 |
if (linksize > 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
75 |
linkfile[linksize] = '\0'; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
76 |
spot = SDL_strrchr(linkfile, '/'); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
77 |
if (spot) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
78 |
return SDL_strdup(spot + 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
79 |
} else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
80 |
return SDL_strdup(linkfile); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
81 |
} |
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 |
#endif /* __LINUX__ || __FREEBSD__ */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
84 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
85 |
/* 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
|
86 |
return SDL_strdup("SDL_App"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
87 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
88 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
/* X11 driver bootstrap functions */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
static int |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
X11_Available(void) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
{ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
Display *display = NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
if (SDL_X11_LoadSymbols()) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
display = XOpenDisplay(NULL); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
if (display != NULL) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
XCloseDisplay(display); |
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 |
SDL_X11_UnloadSymbols(); |
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 |
return (display != NULL); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
static void |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
X11_DeleteDevice(SDL_VideoDevice * device) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
{ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
SDL_VideoData *data = (SDL_VideoData *) device->driverdata; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
if (data->display) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
XCloseDisplay(data->display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
} |
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
|
112 |
SDL_free(data->windowlist); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
SDL_free(device->driverdata); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
SDL_free(device); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
SDL_X11_UnloadSymbols(); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
|
6498
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
119 |
/* An error handler to reset the vidmode and then call the default handler. */ |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
120 |
static SDL_bool safety_net_triggered = SDL_FALSE; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
121 |
static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
122 |
static int |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
123 |
X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
124 |
{ |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
125 |
/* if we trigger an error in our error handler, don't try again. */ |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
126 |
if (!safety_net_triggered) { |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
127 |
safety_net_triggered = SDL_TRUE; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
128 |
SDL_VideoDevice *device = SDL_GetVideoDevice(); |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
129 |
if (device != NULL) { |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
130 |
int i; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
131 |
for (i = 0; i < device->num_displays; i++) { |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
132 |
SDL_VideoDisplay *display = &device->displays[i]; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
133 |
if (SDL_memcmp(&display->current_mode, &display->desktop_mode, |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
134 |
sizeof (SDL_DisplayMode)) != 0) { |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
135 |
X11_SetDisplayMode(device, display, &display->desktop_mode); |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
136 |
} |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
137 |
} |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
138 |
} |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
139 |
} |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
140 |
|
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
141 |
if (orig_x11_errhandler != NULL) { |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
142 |
return orig_x11_errhandler(d, e); /* probably terminate. */ |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
143 |
} |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
144 |
|
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
145 |
return 0; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
146 |
} |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
147 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
static SDL_VideoDevice * |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
X11_CreateDevice(int devindex) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
{ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
SDL_VideoDevice *device; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
SDL_VideoData *data; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
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
|
154 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
if (!SDL_X11_LoadSymbols()) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
return NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
|
6569
1f4e69a8e5e6
Add XInitThreads to X11_CreateDevice.
Michael Sartain <mikesart@valvesoftware.com>
parents:
6498
diff
changeset
|
159 |
// Need for threading gl calls. This is also required for the proprietary nVidia |
1f4e69a8e5e6
Add XInitThreads to X11_CreateDevice.
Michael Sartain <mikesart@valvesoftware.com>
parents:
6498
diff
changeset
|
160 |
// driver to be threaded. |
1f4e69a8e5e6
Add XInitThreads to X11_CreateDevice.
Michael Sartain <mikesart@valvesoftware.com>
parents:
6498
diff
changeset
|
161 |
XInitThreads(); |
1f4e69a8e5e6
Add XInitThreads to X11_CreateDevice.
Michael Sartain <mikesart@valvesoftware.com>
parents:
6498
diff
changeset
|
162 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
/* Initialize all variables that we clean on shutdown */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
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
|
165 |
if (!device) { |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
166 |
SDL_OutOfMemory(); |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
167 |
return NULL; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
} |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
169 |
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
|
170 |
if (!data) { |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 |
SDL_OutOfMemory(); |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2305
diff
changeset
|
172 |
SDL_free(device); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
return NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
device->driverdata = data; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
/* FIXME: Do we need this? |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 |
if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) || |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
(SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 |
local_X11 = 1; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
} else { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
local_X11 = 0; |
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 |
*/ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
data->display = XOpenDisplay(display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
#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
|
187 |
/* 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
|
188 |
* Xlib: connection to ":0.0" refused by server |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 |
* Xlib: XDM authorization key matches an existing client! |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 |
* |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
* It succeeds if retrying 1 second later |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 |
* or if running xhost +localhost on shell. |
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 |
if (data->display == NULL) { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
SDL_Delay(1000); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
data->display = XOpenDisplay(display); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
#endif |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 |
if (data->display == NULL) { |
6367
3c1253baeaec
Fix memory leaks in X11_CreateDevice error paths
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
200 |
SDL_free(device->driverdata); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
SDL_free(device); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
SDL_SetError("Couldn't open X11 display"); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
return NULL; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
#ifdef X11_DEBUG |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
XSynchronize(data->display, True); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
#endif |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
|
6498
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
209 |
/* Hook up an X11 error handler to recover the desktop resolution. */ |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
210 |
safety_net_triggered = SDL_FALSE; |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
211 |
orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler); |
93d9b2a2eb0e
Add a safety net X11 error handler, to reset the vidmodes before crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
6484
diff
changeset
|
212 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
/* Set the function pointers */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
device->VideoInit = X11_VideoInit; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 |
device->VideoQuit = X11_VideoQuit; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
device->GetDisplayModes = X11_GetDisplayModes; |
6331
5732e1a80bde
Fixes #1522, improved Xinerama / Twinview support
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6316
diff
changeset
|
217 |
device->GetDisplayBounds = X11_GetDisplayBounds; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
device->SetDisplayMode = X11_SetDisplayMode; |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
219 |
device->SuspendScreenSaver = X11_SuspendScreenSaver; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
220 |
device->PumpEvents = X11_PumpEvents; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
device->CreateWindow = X11_CreateWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
device->CreateWindowFrom = X11_CreateWindowFrom; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
device->SetWindowTitle = X11_SetWindowTitle; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2963
diff
changeset
|
225 |
device->SetWindowIcon = X11_SetWindowIcon; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 |
device->SetWindowPosition = X11_SetWindowPosition; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
device->SetWindowSize = X11_SetWindowSize; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
device->ShowWindow = X11_ShowWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
device->HideWindow = X11_HideWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
device->RaiseWindow = X11_RaiseWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
device->MaximizeWindow = X11_MaximizeWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 |
device->MinimizeWindow = X11_MinimizeWindow; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
device->RestoreWindow = X11_RestoreWindow; |
6422
fd0ac1b56115
Added SDL_SetWindowBordered() API.
Ryan C. Gordon <icculus@icculus.org>
parents:
6370
diff
changeset
|
234 |
device->SetWindowBordered = X11_SetWindowBordered; |
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
235 |
device->SetWindowFullscreen = X11_SetWindowFullscreen; |
5466 | 236 |
device->SetWindowGammaRamp = X11_SetWindowGammaRamp; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
device->SetWindowGrab = X11_SetWindowGrab; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
device->DestroyWindow = X11_DestroyWindow; |
5182
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5138
diff
changeset
|
239 |
device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; |
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5138
diff
changeset
|
240 |
device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; |
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5138
diff
changeset
|
241 |
device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer; |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
device->GetWindowWMInfo = X11_GetWindowWMInfo; |
5182
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5138
diff
changeset
|
243 |
|
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
4459
diff
changeset
|
244 |
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
|
245 |
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
|
246 |
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; |
5182
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5138
diff
changeset
|
247 |
|
5088 | 248 |
#if SDL_VIDEO_OPENGL_GLX |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
249 |
device->GL_LoadLibrary = X11_GL_LoadLibrary; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
250 |
device->GL_GetProcAddress = X11_GL_GetProcAddress; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
251 |
device->GL_UnloadLibrary = X11_GL_UnloadLibrary; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
252 |
device->GL_CreateContext = X11_GL_CreateContext; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
253 |
device->GL_MakeCurrent = X11_GL_MakeCurrent; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
254 |
device->GL_SetSwapInterval = X11_GL_SetSwapInterval; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
255 |
device->GL_GetSwapInterval = X11_GL_GetSwapInterval; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
256 |
device->GL_SwapWindow = X11_GL_SwapWindow; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
257 |
device->GL_DeleteContext = X11_GL_DeleteContext; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
258 |
#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
259 |
device->GL_LoadLibrary = X11_GLES_LoadLibrary; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
260 |
device->GL_GetProcAddress = X11_GLES_GetProcAddress; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
261 |
device->GL_UnloadLibrary = X11_GLES_UnloadLibrary; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
262 |
device->GL_CreateContext = X11_GLES_CreateContext; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
263 |
device->GL_MakeCurrent = X11_GLES_MakeCurrent; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
264 |
device->GL_SetSwapInterval = X11_GLES_SetSwapInterval; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
265 |
device->GL_GetSwapInterval = X11_GLES_GetSwapInterval; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
266 |
device->GL_SwapWindow = X11_GLES_SwapWindow; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
267 |
device->GL_DeleteContext = X11_GLES_DeleteContext; |
3218 | 268 |
#endif |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
|
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
270 |
device->SetClipboardText = X11_SetClipboardText; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
271 |
device->GetClipboardText = X11_GetClipboardText; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
272 |
device->HasClipboardText = X11_HasClipboardText; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4472
diff
changeset
|
273 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
device->free = X11_DeleteDevice; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
return device; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
VideoBootStrap X11_bootstrap = { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
"x11", "SDL X11 video driver", |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
X11_Available, X11_CreateDevice |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 |
}; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
|
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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
{ |
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
|
288 |
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
|
289 |
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
|
290 |
} 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
|
291 |
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
|
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 |
} |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 |
|
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
|
295 |
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
|
296 |
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
|
297 |
{ |
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
|
298 |
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
|
299 |
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
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
#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
|
307 |
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
|
308 |
#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
|
309 |
|
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
|
310 |
/* 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
|
311 |
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
|
312 |
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
|
313 |
|
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
|
314 |
_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
|
315 |
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
|
316 |
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
|
317 |
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
|
318 |
} |
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
|
319 |
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
|
320 |
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
|
321 |
} |
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
|
322 |
|
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
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
} |
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
|
328 |
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
|
329 |
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
|
330 |
} |
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
|
331 |
} |
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
|
332 |
|
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
|
333 |
/* 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
|
334 |
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
|
335 |
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
|
336 |
|
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
|
337 |
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
|
338 |
#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
|
339 |
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
|
340 |
#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
|
341 |
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
|
342 |
} |
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 |
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
|
344 |
|
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 |
#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
|
346 |
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
|
347 |
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
|
348 |
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
|
349 |
#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
|
350 |
} |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 |
int |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
X11_VideoInit(_THIS) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 |
{ |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
355 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
356 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
357 |
/* 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
|
358 |
data->classname = get_classname(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
359 |
|
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
360 |
/* Get the process PID to be associated to the window */ |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
361 |
data->pid = getpid(); |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
362 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
363 |
/* 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
|
364 |
#ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
365 |
if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
366 |
data->im = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
367 |
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
|
368 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
369 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
370 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
371 |
/* 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
|
372 |
#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
|
373 |
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
|
374 |
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
|
375 |
GET_ATOM(_NET_WM_STATE_HIDDEN); |
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6466
diff
changeset
|
376 |
GET_ATOM(_NET_WM_STATE_FOCUSED); |
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
|
377 |
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
|
378 |
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
|
379 |
GET_ATOM(_NET_WM_STATE_FULLSCREEN); |
6466
ebe165c00fab
On Compiz (etc?), _NET_WM_ACTION_FULLSCREEN needs the window to be resizable.
Ryan C. Gordon <icculus@icculus.org>
parents:
6422
diff
changeset
|
380 |
GET_ATOM(_NET_WM_ALLOWED_ACTIONS); |
ebe165c00fab
On Compiz (etc?), _NET_WM_ACTION_FULLSCREEN needs the window to be resizable.
Ryan C. Gordon <icculus@icculus.org>
parents:
6422
diff
changeset
|
381 |
GET_ATOM(_NET_WM_ACTION_FULLSCREEN); |
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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
|
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
|
387 |
/* 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
|
388 |
X11_CheckWindowManager(_this); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
389 |
|
3521
76f9b76ddf0f
Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents:
3218
diff
changeset
|
390 |
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
|
391 |
return -1; |
76f9b76ddf0f
Don't add any renderers if you can't add any displays
Sam Lantinga <slouken@libsdl.org>
parents:
3218
diff
changeset
|
392 |
} |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 |
|
6316
a89c79a3f0cd
1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6312
diff
changeset
|
394 |
X11_InitXinput2(_this); |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
395 |
|
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
|
396 |
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
|
397 |
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
|
398 |
} |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
X11_InitMouse(_this); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 |
|
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
4459
diff
changeset
|
401 |
X11_InitTouch(_this); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 |
return 0; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 |
|
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 |
void |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 |
X11_VideoQuit(_THIS) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 |
{ |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
408 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
409 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
410 |
if (data->classname) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
411 |
SDL_free(data->classname); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
412 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
413 |
#ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
414 |
if (data->im) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
415 |
XCloseIM(data->im); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
416 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
417 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
418 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 |
X11_QuitModes(_this); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 |
X11_QuitKeyboard(_this); |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 |
X11_QuitMouse(_this); |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
4459
diff
changeset
|
422 |
X11_QuitTouch(_this); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 |
} |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 |
|
5466 | 425 |
SDL_bool |
426 |
X11_UseDirectColorVisuals(void) |
|
427 |
{ |
|
428 |
return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE; |
|
429 |
} |
|
430 |
||
5481
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
431 |
#endif /* SDL_VIDEO_DRIVER_X11 */ |
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
432 |
|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 |
/* vim: set ts=4 sw=4 expandtab: */ |