author | Sam Lantinga <slouken@libsdl.org> |
Thu, 19 Jul 2012 09:36:58 -0700 | |
changeset 6373 | 494e0436525f |
parent 6370 | 93187f7f7d5d |
child 6422 | fd0ac1b56115 |
permissions | -rwxr-xr-x |
1951
7177581dc9fa
Initial work on X11 window code in.
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:
5531
diff
changeset
|
2 |
Simple DirectMedia Layer |
6138 | 3 |
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> |
1951
7177581dc9fa
Initial work on X11 window code in.
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:
5531
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:
5531
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:
5531
diff
changeset
|
7 |
arising from the use of this software. |
1951
7177581dc9fa
Initial work on X11 window code in.
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:
5531
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:
5531
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:
5531
diff
changeset
|
11 |
freely, subject to the following restrictions: |
1951
7177581dc9fa
Initial work on X11 window code in.
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:
5531
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:
5531
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:
5531
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:
5531
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5531
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:
5531
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:
5531
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
7177581dc9fa
Initial work on X11 window code in.
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:
5478
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:
5478
diff
changeset
|
24 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
#include "../SDL_sysvideo.h" |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
26 |
#include "../SDL_pixels_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
#include "../../events/SDL_keyboard_c.h" |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset
|
28 |
#include "../../events/SDL_mouse_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
#include "SDL_x11video.h" |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset
|
31 |
#include "SDL_x11mouse.h" |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
3697
diff
changeset
|
32 |
#include "SDL_x11shape.h" |
6316
a89c79a3f0cd
1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6275
diff
changeset
|
33 |
#include "SDL_x11xinput2.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
35 |
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
36 |
#include "SDL_x11opengles.h" |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
37 |
#endif |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
38 |
|
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
39 |
#include "SDL_timer.h" |
3241
08c5964f2a34
Fixed a few issues compiling with Mac OS X 10.6
Sam Lantinga <slouken@libsdl.org>
parents:
3225
diff
changeset
|
40 |
#include "SDL_syswm.h" |
08c5964f2a34
Fixed a few issues compiling with Mac OS X 10.6
Sam Lantinga <slouken@libsdl.org>
parents:
3225
diff
changeset
|
41 |
|
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
42 |
#define _NET_WM_STATE_REMOVE 0l |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
43 |
#define _NET_WM_STATE_ADD 1l |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
44 |
#define _NET_WM_STATE_TOGGLE 2l |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
45 |
|
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
46 |
static SDL_bool |
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
47 |
X11_IsWindowOldFullscreen(_THIS, SDL_Window * window) |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
48 |
{ |
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
49 |
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
50 |
|
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
51 |
/* ICCCM2.0-compliant window managers can handle fullscreen windows */ |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
52 |
if ((window->flags & SDL_WINDOW_FULLSCREEN) && !videodata->net_wm) { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
53 |
return SDL_TRUE; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
54 |
} else { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
55 |
return SDL_FALSE; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
56 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
57 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
58 |
|
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
59 |
static SDL_bool |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
60 |
X11_IsWindowMapped(_THIS, SDL_Window * window) |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
61 |
{ |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
62 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
63 |
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
64 |
XWindowAttributes attr; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
65 |
|
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
66 |
XGetWindowAttributes(videodata->display, data->xwindow, &attr); |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
67 |
if (attr.map_state != IsUnmapped) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
68 |
return SDL_TRUE; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
69 |
} else { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
70 |
return SDL_FALSE; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
71 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
72 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
73 |
|
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
74 |
static int |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
75 |
X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3]) |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
76 |
{ |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
77 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
78 |
int count = 0; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
79 |
|
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
80 |
if (window->flags & SDL_WINDOW_FULLSCREEN) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
81 |
atoms[count++] = data->_NET_WM_STATE_FULLSCREEN; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
82 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
83 |
if (window->flags & SDL_WINDOW_MAXIMIZED) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
84 |
atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_VERT; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
85 |
atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_HORZ; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
86 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
87 |
return count; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
88 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
89 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
static int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
SDL_WindowData *data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
int numwindows = videodata->numwindows; |
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
|
96 |
int windowlistlength = videodata->windowlistlength; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
SDL_WindowData **windowlist = videodata->windowlist; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
/* Allocate the window data */ |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
100 |
data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
if (!data) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
} |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
105 |
data->window = window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
106 |
data->xwindow = w; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
#ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
data->ic = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
XNInputStyle, XIMPreeditNothing | XIMStatusNothing, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
XNResourceName, videodata->classname, XNResourceClass, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
videodata->classname, NULL); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
data->created = created; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
data->videodata = videodata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
|
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
119 |
/* Associate the data with the window */ |
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
|
120 |
|
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
121 |
if (numwindows < windowlistlength) { |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
122 |
windowlist[numwindows] = data; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
123 |
videodata->numwindows++; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
124 |
} else { |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
125 |
windowlist = |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
126 |
(SDL_WindowData **) SDL_realloc(windowlist, |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
127 |
(numwindows + |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
128 |
1) * sizeof(*windowlist)); |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
129 |
if (!windowlist) { |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
130 |
SDL_OutOfMemory(); |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
131 |
SDL_free(data); |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
132 |
return -1; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
133 |
} |
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
|
134 |
windowlist[numwindows] = data; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
135 |
videodata->numwindows++; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
136 |
videodata->windowlistlength++; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
137 |
videodata->windowlist = windowlist; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
138 |
} |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
139 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
/* Fill in the SDL window with the window data */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 |
XWindowAttributes attrib; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
XGetWindowAttributes(data->videodata->display, w, &attrib); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
window->x = attrib.x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
window->y = attrib.y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 |
window->w = attrib.width; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
window->h = attrib.height; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
if (attrib.map_state != IsUnmapped) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
window->flags |= SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
} else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
window->flags &= ~SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
} |
5182
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5088
diff
changeset
|
154 |
data->visual = attrib.visual; |
5466 | 155 |
data->colormap = attrib.colormap; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
} |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
157 |
|
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
158 |
{ |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
159 |
Atom _NET_WM_STATE = data->videodata->_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:
4510
diff
changeset
|
160 |
Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_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:
4510
diff
changeset
|
161 |
Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_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:
4510
diff
changeset
|
162 |
Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
163 |
Atom actualType; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
164 |
int actualFormat; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
165 |
unsigned long i, numItems, bytesAfter; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
166 |
unsigned char *propertyValue = NULL; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
167 |
long maxLength = 1024; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
168 |
|
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
169 |
if (XGetWindowProperty(data->videodata->display, w, _NET_WM_STATE, |
3078 | 170 |
0l, maxLength, False, XA_ATOM, &actualType, |
171 |
&actualFormat, &numItems, &bytesAfter, |
|
172 |
&propertyValue) == Success) { |
|
173 |
Atom *atoms = (Atom *) propertyValue; |
|
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
174 |
int maximized = 0; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
175 |
int fullscreen = 0; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
176 |
|
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
177 |
for (i = 0; i < numItems; ++i) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
178 |
if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
179 |
maximized |= 1; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
180 |
} else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
181 |
maximized |= 2; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
182 |
} else if ( atoms[i] == _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:
4510
diff
changeset
|
183 |
fullscreen = 1; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
184 |
} |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
185 |
} |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
186 |
if (maximized == 3) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
187 |
window->flags |= SDL_WINDOW_MAXIMIZED; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
188 |
} else if (fullscreen == 1) { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
189 |
window->flags |= SDL_WINDOW_FULLSCREEN; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
190 |
} |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
191 |
XFree(propertyValue); |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
192 |
} |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
193 |
} |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
194 |
|
6024
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
195 |
{ |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
196 |
Window FocalWindow; |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
197 |
int RevertTo=0; |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
198 |
XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
199 |
if (FocalWindow==w) |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
200 |
{ |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
201 |
window->flags |= SDL_WINDOW_INPUT_FOCUS; |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
202 |
SDL_SetKeyboardFocus(data->window); |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
203 |
} |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
204 |
|
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
205 |
if (window->flags & SDL_WINDOW_INPUT_GRABBED) { |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
206 |
/* Tell x11 to clip mouse */ |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
207 |
} |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
208 |
} |
38e2f4644548
Set up window focus correctly when using an existing X11 window.
Ryan C. Gordon <icculus@icculus.org>
parents:
6023
diff
changeset
|
209 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 |
/* FIXME: How can I tell? |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 |
DWORD style = GetWindowLong(hwnd, GWL_STYLE); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
if (style & WS_VISIBLE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
if (style & (WS_BORDER | WS_THICKFRAME)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 |
window->flags &= ~SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
} else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 |
window->flags |= SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 |
if (style & WS_THICKFRAME) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
window->flags |= SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
} else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
window->flags &= ~SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
if (style & WS_MINIMIZE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
window->flags |= SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 |
} else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
window->flags &= ~SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
if (GetFocus() == hwnd) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
int index = data->videodata->keyboard; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 |
window->flags |= SDL_WINDOW_INPUT_FOCUS; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
233 |
SDL_SetKeyboardFocus(index, data->window); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
if (window->flags & SDL_WINDOW_INPUT_GRABBED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
RECT rect; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
GetClientRect(hwnd, &rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
ClientToScreen(hwnd, (LPPOINT) & rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
ClientToScreen(hwnd, (LPPOINT) & rect + 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 |
ClipCursor(&rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
*/ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
/* All done! */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
window->driverdata = data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 |
return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
X11_CreateWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
SDL_DisplayData *displaydata = |
5246
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5243
diff
changeset
|
255 |
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
256 |
Display *display = data->display; |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
257 |
int screen = displaydata->screen; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 |
Visual *visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
int depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
XSetWindowAttributes xattr; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 |
Window w; |
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
262 |
XSizeHints sizehints; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
263 |
XWMHints wmhints; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
264 |
XClassHint classhints; |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
265 |
Atom _NET_WM_WINDOW_TYPE; |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
266 |
Atom _NET_WM_WINDOW_TYPE_NORMAL; |
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
267 |
Atom _NET_WM_PID; |
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
268 |
int wmstate_count; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
269 |
Atom wmstate_atoms[3]; |
6045
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
270 |
Uint32 fevent = 0; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
271 |
|
6369
a92fbd27127b
Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Sam Lantinga <slouken@libsdl.org>
parents:
6343
diff
changeset
|
272 |
#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 |
if (window->flags & SDL_WINDOW_OPENGL) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
274 |
XVisualInfo *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
275 |
|
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
276 |
#if 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
|
277 |
if (_this->gl_config.use_egl == 1) { |
6369
a92fbd27127b
Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Sam Lantinga <slouken@libsdl.org>
parents:
6343
diff
changeset
|
278 |
vinfo = X11_GLES_GetVisual(_this, display, screen); |
a92fbd27127b
Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Sam Lantinga <slouken@libsdl.org>
parents:
6343
diff
changeset
|
279 |
} else |
a92fbd27127b
Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Sam Lantinga <slouken@libsdl.org>
parents:
6343
diff
changeset
|
280 |
#endif |
a92fbd27127b
Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Sam Lantinga <slouken@libsdl.org>
parents:
6343
diff
changeset
|
281 |
{ |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
282 |
#if SDL_VIDEO_OPENGL_GLX |
6369
a92fbd27127b
Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Sam Lantinga <slouken@libsdl.org>
parents:
6343
diff
changeset
|
283 |
vinfo = X11_GL_GetVisual(_this, display, screen); |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6369
diff
changeset
|
284 |
#endif |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
285 |
} |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
286 |
if (!vinfo) { |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
287 |
return -1; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
288 |
} |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
289 |
visual = vinfo->visual; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
290 |
depth = vinfo->depth; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
291 |
XFree(vinfo); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
292 |
} else |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
293 |
#endif |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
294 |
{ |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 |
visual = displaydata->visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 |
depth = displaydata->depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
|
5386
762e67f81fc7
Simplified the X11 window creation
Sam Lantinga <slouken@libsdl.org>
parents:
5305
diff
changeset
|
299 |
xattr.override_redirect = False; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 |
xattr.background_pixel = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 |
xattr.border_pixel = 0; |
5466 | 302 |
|
303 |
if (visual->class == DirectColor) { |
|
304 |
XColor *colorcells; |
|
305 |
int i; |
|
306 |
int ncolors; |
|
307 |
int rmax, gmax, bmax; |
|
308 |
int rmask, gmask, bmask; |
|
309 |
int rshift, gshift, bshift; |
|
310 |
||
311 |
xattr.colormap = |
|
312 |
XCreateColormap(display, RootWindow(display, screen), |
|
313 |
visual, AllocAll); |
|
314 |
||
315 |
/* If we can't create a colormap, then we must die */ |
|
316 |
if (!xattr.colormap) { |
|
317 |
SDL_SetError("Could not create writable colormap"); |
|
318 |
return -1; |
|
319 |
} |
|
320 |
||
321 |
/* OK, we got a colormap, now fill it in as best as we can */ |
|
322 |
colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); |
|
323 |
if (!colorcells) { |
|
324 |
SDL_OutOfMemory(); |
|
325 |
return -1; |
|
326 |
} |
|
327 |
ncolors = visual->map_entries; |
|
328 |
rmax = 0xffff; |
|
329 |
gmax = 0xffff; |
|
330 |
bmax = 0xffff; |
|
331 |
||
332 |
rshift = 0; |
|
333 |
rmask = visual->red_mask; |
|
334 |
while (0 == (rmask & 1)) { |
|
335 |
rshift++; |
|
336 |
rmask >>= 1; |
|
337 |
} |
|
338 |
||
339 |
gshift = 0; |
|
340 |
gmask = visual->green_mask; |
|
341 |
while (0 == (gmask & 1)) { |
|
342 |
gshift++; |
|
343 |
gmask >>= 1; |
|
344 |
} |
|
345 |
||
346 |
bshift = 0; |
|
347 |
bmask = visual->blue_mask; |
|
348 |
while (0 == (bmask & 1)) { |
|
349 |
bshift++; |
|
350 |
bmask >>= 1; |
|
351 |
} |
|
352 |
||
353 |
/* build the color table pixel values */ |
|
354 |
for (i = 0; i < ncolors; i++) { |
|
355 |
Uint32 red = (rmax * i) / (ncolors - 1); |
|
356 |
Uint32 green = (gmax * i) / (ncolors - 1); |
|
357 |
Uint32 blue = (bmax * i) / (ncolors - 1); |
|
358 |
||
359 |
Uint32 rbits = (rmask * i) / (ncolors - 1); |
|
360 |
Uint32 gbits = (gmask * i) / (ncolors - 1); |
|
361 |
Uint32 bbits = (bmask * i) / (ncolors - 1); |
|
362 |
||
363 |
Uint32 pix = |
|
364 |
(rbits << rshift) | (gbits << gshift) | (bbits << bshift); |
|
365 |
||
366 |
colorcells[i].pixel = pix; |
|
367 |
||
368 |
colorcells[i].red = red; |
|
369 |
colorcells[i].green = green; |
|
370 |
colorcells[i].blue = blue; |
|
371 |
||
372 |
colorcells[i].flags = DoRed | DoGreen | DoBlue; |
|
373 |
} |
|
374 |
||
375 |
XStoreColors(display, xattr.colormap, colorcells, ncolors); |
|
376 |
||
377 |
SDL_free(colorcells); |
|
378 |
} else { |
|
379 |
xattr.colormap = |
|
380 |
XCreateColormap(display, RootWindow(display, screen), |
|
381 |
visual, AllocNone); |
|
382 |
} |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 |
|
5386
762e67f81fc7
Simplified the X11 window creation
Sam Lantinga <slouken@libsdl.org>
parents:
5305
diff
changeset
|
384 |
w = XCreateWindow(display, RootWindow(display, screen), |
762e67f81fc7
Simplified the X11 window creation
Sam Lantinga <slouken@libsdl.org>
parents:
5305
diff
changeset
|
385 |
window->x, window->y, window->w, window->h, |
762e67f81fc7
Simplified the X11 window creation
Sam Lantinga <slouken@libsdl.org>
parents:
5305
diff
changeset
|
386 |
0, depth, InputOutput, visual, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 |
(CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
CWColormap), &xattr); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
389 |
if (!w) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
390 |
SDL_SetError("Couldn't create window"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
391 |
return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
392 |
} |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
393 |
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 |
6373
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
394 |
if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) { |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
395 |
if (!_this->gles_data) { |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
396 |
XDestroyWindow(display, w); |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
397 |
return -1; |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
398 |
} |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
399 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
400 |
/* Create the GLES window surface */ |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
401 |
_this->gles_data->egl_surface = |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
402 |
_this->gles_data->eglCreateWindowSurface(_this->gles_data-> |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
403 |
egl_display, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
404 |
_this->gles_data->egl_config, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
405 |
(NativeWindowType) w, NULL); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
406 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
407 |
if (_this->gles_data->egl_surface == EGL_NO_SURFACE) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
408 |
SDL_SetError("Could not create GLES window surface"); |
6373
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
409 |
XDestroyWindow(display, w); |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
410 |
return -1; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6167
diff
changeset
|
411 |
} |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
412 |
} |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
413 |
#endif |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
|
5386
762e67f81fc7
Simplified the X11 window creation
Sam Lantinga <slouken@libsdl.org>
parents:
5305
diff
changeset
|
415 |
if (window->flags & SDL_WINDOW_BORDERLESS) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 |
SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 |
Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 |
/* We haven't modified the window manager hints yet */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 |
set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 |
/* First try to set MWM hints */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
423 |
WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 |
if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 |
/* Hints used by Motif compliant window managers */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 |
struct |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 |
unsigned long flags; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 |
unsigned long functions; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 |
unsigned long decorations; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 |
long input_mode; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 |
unsigned long status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 |
} MWMHints = { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 |
(1L << 1), 0, 0, 0, 0}; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
|
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
436 |
XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 |
PropModeReplace, (unsigned char *) &MWMHints, |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
438 |
sizeof(MWMHints) / 4); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 |
set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 |
/* Now try to set KWM hints */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
442 |
WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 |
if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 |
long KWMHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 |
|
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
446 |
XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 |
PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 |
(unsigned char *) &KWMHints, |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
449 |
sizeof(KWMHints) / 4); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 |
set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 |
/* Now try to set GNOME hints */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
453 |
WM_HINTS = XInternAtom(display, "_WIN_HINTS", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 |
long GNOMEHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 |
|
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
457 |
XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 |
PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 |
(unsigned char *) &GNOMEHints, |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
460 |
sizeof(GNOMEHints) / 4); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 |
set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 |
/* Finally set the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 |
if (!set) { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
465 |
XSetTransientForHint(display, w, RootWindow(display, screen)); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
} else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 |
SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 |
Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 |
/* We haven't modified the window manager hints yet */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 |
set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
/* First try to unset MWM hints */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
475 |
WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 |
if (WM_HINTS != None) { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
477 |
XDeleteProperty(display, w, WM_HINTS); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 |
/* Now try to unset KWM hints */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
481 |
WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 |
if (WM_HINTS != None) { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
483 |
XDeleteProperty(display, w, WM_HINTS); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 |
set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 |
/* Now try to unset GNOME hints */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
487 |
WM_HINTS = XInternAtom(display, "_WIN_HINTS", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 |
if (WM_HINTS != None) { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
489 |
XDeleteProperty(display, w, WM_HINTS); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 |
/* Finally unset the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 |
if (!set) { |
4555 | 494 |
XDeleteProperty(display, w, XA_WM_TRANSIENT_FOR); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 |
|
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
498 |
/* Setup the normal size hints */ |
6275
963497e37d34
Fixed bug 1403 - Creating a window with resizable flags may crash
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
499 |
sizehints.flags = 0; |
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
500 |
if (!(window->flags & SDL_WINDOW_RESIZABLE)) { |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
501 |
sizehints.min_width = sizehints.max_width = window->w; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
502 |
sizehints.min_height = sizehints.max_height = window->h; |
6275
963497e37d34
Fixed bug 1403 - Creating a window with resizable flags may crash
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
503 |
sizehints.flags |= (PMaxSize | PMinSize); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 |
} |
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
505 |
sizehints.x = window->x; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
506 |
sizehints.y = window->y; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
507 |
sizehints.flags |= USPosition; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 |
|
6167
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
509 |
/* Setup the input hints so we get keyboard input */ |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
510 |
wmhints.input = True; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
511 |
wmhints.flags = InputHint; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
512 |
|
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
513 |
/* Setup the class hints so we can get an icon (AfterStep) */ |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
514 |
classhints.res_name = data->classname; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
515 |
classhints.res_class = data->classname; |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
516 |
|
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
517 |
/* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */ |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
518 |
XSetWMProperties(display, w, NULL, NULL, NULL, 0, &sizehints, &wmhints, &classhints); |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
519 |
|
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
520 |
/* Set the PID related to the window for the given hostname, if possible */ |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
521 |
if (data->pid > 0) { |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
522 |
_NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False); |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
523 |
XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, |
c071e1372341
X11: Move to XSetWMProperties and add support to _NET_WM_PID
Marco Trevisan (Treviño) <mail@3v1n0.net>
parents:
6138
diff
changeset
|
524 |
(unsigned char *)&data->pid, 1); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 |
|
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
527 |
/* Set the window manager state */ |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
528 |
wmstate_count = X11_GetWMStateProperty(_this, window, wmstate_atoms); |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
529 |
if (wmstate_count > 0) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
530 |
XChangeProperty(display, w, data->_NET_WM_STATE, XA_ATOM, 32, |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
531 |
PropModeReplace, |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
532 |
(unsigned char *)wmstate_atoms, wmstate_count); |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
533 |
} else { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
534 |
XDeleteProperty(display, w, data->_NET_WM_STATE); |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
535 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
536 |
|
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
537 |
/* Let the window manager know we're a "normal" window */ |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
538 |
_NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
539 |
_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
540 |
XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
541 |
PropModeReplace, |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
542 |
(unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1); |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
543 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 |
/* Allow the window to be deleted by the window manager */ |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
545 |
XSetWMProtocols(display, w, &data->WM_DELETE_WINDOW, 1); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 |
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
548 |
XDestroyWindow(display, w); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 |
return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 |
} |
5386
762e67f81fc7
Simplified the X11 window creation
Sam Lantinga <slouken@libsdl.org>
parents:
5305
diff
changeset
|
551 |
|
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
552 |
#ifdef X_HAVE_UTF8_STRING |
6045
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
553 |
if (SDL_X11_HAVE_UTF8) { |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
554 |
pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
555 |
XNFilterEvents, &fevent, NULL); |
2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset
|
556 |
} |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
557 |
#endif |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
558 |
|
6316
a89c79a3f0cd
1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6275
diff
changeset
|
559 |
X11_Xinput2SelectTouch(_this, window); |
a89c79a3f0cd
1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6275
diff
changeset
|
560 |
|
6045
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
561 |
XSelectInput(display, w, |
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
562 |
(FocusChangeMask | EnterWindowMask | LeaveWindowMask | |
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
563 |
ExposureMask | ButtonPressMask | ButtonReleaseMask | |
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
564 |
PointerMotionMask | KeyPressMask | KeyReleaseMask | |
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
565 |
PropertyChangeMask | StructureNotifyMask | |
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
566 |
KeymapStateMask | fevent)); |
b8e995dab018
Fix crash on X servers without UTF-8 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
6024
diff
changeset
|
567 |
|
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
568 |
XFlush(display); |
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
569 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 |
return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 |
int |
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
|
574 |
X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 |
Window w = (Window) data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 |
|
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
578 |
window->title = X11_GetWindowTitle(_this, w); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 |
if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 |
return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 |
return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 |
|
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
586 |
char * |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
587 |
X11_GetWindowTitle(_THIS, Window xwindow) |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
588 |
{ |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
589 |
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:
4510
diff
changeset
|
590 |
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:
4510
diff
changeset
|
591 |
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:
4510
diff
changeset
|
592 |
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:
4510
diff
changeset
|
593 |
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:
4510
diff
changeset
|
594 |
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:
4510
diff
changeset
|
595 |
char *title = NULL; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
596 |
|
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
597 |
status = XGetWindowProperty(display, xwindow, data->_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:
4510
diff
changeset
|
598 |
0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
599 |
&items_read, &items_left, &propdata); |
6023
6279958d571d
XGetWindowProperty() can report success but still give you a NULL pointer.
Ryan C. Gordon <icculus@icculus.org>
parents:
5981
diff
changeset
|
600 |
if (status == Success && propdata) { |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
601 |
title = SDL_strdup(SDL_static_cast(char*, propdata)); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
602 |
XFree(propdata); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
603 |
} else { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
604 |
status = XGetWindowProperty(display, xwindow, XA_WM_NAME, |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
605 |
0L, 8192L, False, XA_STRING, &real_type, &real_format, |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
606 |
&items_read, &items_left, &propdata); |
6023
6279958d571d
XGetWindowProperty() can report success but still give you a NULL pointer.
Ryan C. Gordon <icculus@icculus.org>
parents:
5981
diff
changeset
|
607 |
if (status == Success && propdata) { |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
608 |
title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
609 |
} else { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
610 |
title = SDL_strdup(""); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
611 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
612 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
613 |
return title; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
614 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
615 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 |
X11_SetWindowTitle(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 |
Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 |
XTextProperty titleprop, iconprop; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 |
Status status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 |
const char *title = window->title; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 |
const char *icon = NULL; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 |
#ifdef X_HAVE_UTF8_STRING |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
627 |
Atom _NET_WM_NAME = data->videodata->_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:
4510
diff
changeset
|
628 |
Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 |
if (title != NULL) { |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
632 |
char *title_locale = SDL_iconv_utf8_locale(title); |
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
633 |
if (!title_locale) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 |
SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 |
return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 |
} |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
637 |
status = XStringListToTextProperty(&title_locale, 1, &titleprop); |
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
638 |
SDL_free(title_locale); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 |
if (status) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
640 |
XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 |
XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 |
#ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 |
if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 |
status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 |
Xutf8TextListToTextProperty(display, (char **) &title, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 |
XUTF8StringStyle, &titleprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 |
if (status == Success) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
649 |
XSetTextProperty(display, data->xwindow, &titleprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 |
_NET_WM_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 |
XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 |
if (icon != NULL) { |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
657 |
char *icon_locale = SDL_iconv_utf8_locale(icon); |
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
658 |
if (!icon_locale) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 |
SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
660 |
return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
661 |
} |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
662 |
status = XStringListToTextProperty(&icon_locale, 1, &iconprop); |
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
663 |
SDL_free(icon_locale); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 |
if (status) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
665 |
XSetTextProperty(display, data->xwindow, &iconprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 |
XA_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 |
XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 |
#ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 |
if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 |
status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 |
Xutf8TextListToTextProperty(display, (char **) &icon, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 |
XUTF8StringStyle, &iconprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 |
if (status == Success) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
675 |
XSetTextProperty(display, data->xwindow, &iconprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 |
_NET_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 |
XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
679 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 |
} |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
682 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 |
void |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
686 |
X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
687 |
{ |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
688 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
689 |
Display *display = data->videodata->display; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
690 |
Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
691 |
|
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
692 |
if (icon) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
693 |
SDL_PixelFormat format; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
694 |
SDL_Surface *surface; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
695 |
int propsize; |
4528 | 696 |
long *propdata; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
697 |
|
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
698 |
/* Convert the icon to ARGB for modern window managers */ |
5288 | 699 |
SDL_InitFormat(&format, SDL_PIXELFORMAT_ARGB8888); |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
700 |
surface = SDL_ConvertSurface(icon, &format, 0); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
701 |
if (!surface) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
702 |
return; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
703 |
} |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
704 |
|
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
705 |
/* Set the _NET_WM_ICON property */ |
2990 | 706 |
propsize = 2 + (icon->w * icon->h); |
4566
40c833d951a1
Fixed memory corruption on AMD64
Sam Lantinga <slouken@libsdl.org>
parents:
4555
diff
changeset
|
707 |
propdata = SDL_malloc(propsize * sizeof(long)); |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
708 |
if (propdata) { |
4528 | 709 |
int x, y; |
710 |
Uint32 *src; |
|
711 |
long *dst; |
|
712 |
||
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
713 |
propdata[0] = icon->w; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
714 |
propdata[1] = icon->h; |
4528 | 715 |
dst = &propdata[2]; |
716 |
for (y = 0; y < icon->h; ++y) { |
|
717 |
src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch); |
|
718 |
for (x = 0; x < icon->w; ++x) { |
|
719 |
*dst++ = *src++; |
|
720 |
} |
|
721 |
} |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
722 |
XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, |
2990 | 723 |
32, PropModeReplace, (unsigned char *) propdata, |
724 |
propsize); |
|
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
725 |
} |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
726 |
SDL_FreeSurface(surface); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
727 |
} else { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
728 |
XDeleteProperty(display, data->xwindow, _NET_WM_ICON); |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
729 |
} |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
730 |
XFlush(display); |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
731 |
} |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
732 |
|
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
733 |
void |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 |
X11_SetWindowPosition(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 |
Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 |
|
5478
6b65ff3cee62
Fixed bug 1167 (SDL_WINDOWPOS_CENTERED doesn't work if used right after fullscreen -> windowed switch)
Sam Lantinga <slouken@libsdl.org>
parents:
5466
diff
changeset
|
739 |
XMoveWindow(display, data->xwindow, window->x, window->y); |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
740 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 |
X11_SetWindowSize(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 |
Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 |
|
4937
24d44c7c4c63
Don't crash when resizing non-shaped windows
Sam Lantinga <slouken@libsdl.org>
parents:
4902
diff
changeset
|
749 |
if (SDL_IsShapedWindow(window)) |
4782
b6930aefd008
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
3697
diff
changeset
|
750 |
X11_ResizeWindowShape(window); |
5531
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
751 |
if (!(window->flags & SDL_WINDOW_RESIZABLE)) { |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
752 |
/* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
753 |
we must set the size hints to adjust the window size.*/ |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
754 |
XSizeHints *sizehints = XAllocSizeHints(); |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
755 |
long userhints; |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
756 |
|
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
757 |
XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
758 |
|
6343
e94f912d20b9
Fix SDL_SetWindowSize with X11 non-RESIZABLE windows, patch by Pierre-Loup.
Sam Lantinga <slouken@libsdl.org>
parents:
6336
diff
changeset
|
759 |
sizehints->min_width = sizehints->max_width = window->w; |
5531
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
760 |
sizehints->min_height = sizehints->max_height = window->h; |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
761 |
|
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
762 |
XSetWMNormalHints(display, data->xwindow, sizehints); |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
763 |
|
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
764 |
XFree(sizehints); |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
765 |
} else |
477f550f6efd
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
766 |
XResizeWindow(display, data->xwindow, window->w, window->h); |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
767 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
768 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
769 |
|
6336
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
770 |
static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win) |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
771 |
{ |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
772 |
return ev->type == MapNotify && ev->xmap.window == *((Window*)win); |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
773 |
} |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
774 |
static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win) |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
775 |
{ |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
776 |
return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win); |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
777 |
} |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
778 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
779 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
780 |
X11_ShowWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
783 |
Display *display = data->videodata->display; |
6336
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
784 |
XEvent event; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
785 |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
786 |
XMapRaised(display, data->xwindow); |
6336
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
787 |
/* Blocking wait for "MapNotify" event. |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
788 |
* We use XIfEvent because XWindowEvent takes a mask rather than a type, |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
789 |
* and XCheckTypedWindowEvent doesn't block */ |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
790 |
XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
791 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
795 |
X11_HideWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
796 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
797 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
798 |
Display *display = data->videodata->display; |
6336
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
799 |
XEvent event; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
800 |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
801 |
XUnmapWindow(display, data->xwindow); |
6336
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
802 |
/* Blocking wait for "UnmapNotify" event */ |
6e6163b6ba69
Fixed issue with tiling window managers (bug 1246)
Sam Lantinga <slouken@libsdl.org>
parents:
6331
diff
changeset
|
803 |
XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
804 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
806 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
807 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
808 |
X11_RaiseWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
809 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
810 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
811 |
Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
812 |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
813 |
XRaiseWindow(display, data->xwindow); |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
814 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
815 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
816 |
|
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
817 |
static void |
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
818 |
SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
819 |
{ |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
820 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
821 |
SDL_DisplayData *displaydata = |
5246
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5243
diff
changeset
|
822 |
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
823 |
Display *display = data->videodata->display; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
824 |
Atom _NET_WM_STATE = data->videodata->_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:
4510
diff
changeset
|
825 |
Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_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:
4510
diff
changeset
|
826 |
Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; |
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
827 |
Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
828 |
|
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
829 |
if (X11_IsWindowMapped(_this, window)) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
830 |
XEvent e; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
831 |
|
4524
a256e1dadf3f
Zero any fields not explicitly filled in.
Sam Lantinga <slouken@libsdl.org>
parents:
4522
diff
changeset
|
832 |
SDL_zero(e); |
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
833 |
e.xany.type = ClientMessage; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
834 |
e.xclient.message_type = _NET_WM_STATE; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
835 |
e.xclient.format = 32; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
836 |
e.xclient.window = data->xwindow; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
837 |
e.xclient.data.l[0] = |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
838 |
maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
839 |
e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
840 |
e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
841 |
e.xclient.data.l[3] = 0l; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
842 |
|
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
843 |
XSendEvent(display, RootWindow(display, displaydata->screen), 0, |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
844 |
SubstructureNotifyMask | SubstructureRedirectMask, &e); |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
845 |
} else { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
846 |
int count = 0; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
847 |
Atom atoms[3]; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
848 |
|
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
849 |
if (window->flags & SDL_WINDOW_FULLSCREEN) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
850 |
atoms[count++] = _NET_WM_STATE_FULLSCREEN; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
851 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
852 |
if (maximized) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
853 |
atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
854 |
atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ; |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
855 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
856 |
if (count > 0) { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
857 |
XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32, |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
858 |
PropModeReplace, (unsigned char *)atoms, count); |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
859 |
} else { |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
860 |
XDeleteProperty(display, data->xwindow, _NET_WM_STATE); |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
861 |
} |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
862 |
} |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
863 |
XFlush(display); |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
864 |
} |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
865 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
866 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
867 |
X11_MaximizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
868 |
{ |
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
869 |
SetWindowMaximized(_this, window, SDL_TRUE); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
871 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
872 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
873 |
X11_MinimizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
874 |
{ |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
875 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
876 |
SDL_DisplayData *displaydata = |
5246
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5243
diff
changeset
|
877 |
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
878 |
Display *display = data->videodata->display; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
879 |
|
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
880 |
XIconifyWindow(display, data->xwindow, displaydata->screen); |
5031
5e3291605ad0
Added XFlush() so changes happen immediately instead of waiting for the next event loop.
Sam Lantinga <slouken@libsdl.org>
parents:
4937
diff
changeset
|
881 |
XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
X11_RestoreWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 |
{ |
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
887 |
SetWindowMaximized(_this, window, SDL_FALSE); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 |
X11_ShowWindow(_this, window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
889 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
890 |
|
5305
75f5ff92ad08
Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents:
5302
diff
changeset
|
891 |
void |
75f5ff92ad08
Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents:
5302
diff
changeset
|
892 |
X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen) |
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
893 |
{ |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
894 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
5305
75f5ff92ad08
Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents:
5302
diff
changeset
|
895 |
SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata; |
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
896 |
Display *display = data->videodata->display; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
897 |
Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
898 |
Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
899 |
Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
900 |
Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
901 |
|
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
902 |
if (X11_IsWindowMapped(_this, window)) { |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
903 |
XEvent e; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
904 |
|
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
905 |
SDL_zero(e); |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
906 |
e.xany.type = ClientMessage; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
907 |
e.xclient.message_type = _NET_WM_STATE; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
908 |
e.xclient.format = 32; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
909 |
e.xclient.window = data->xwindow; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
910 |
e.xclient.data.l[0] = |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
911 |
fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
912 |
e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
913 |
e.xclient.data.l[3] = 0l; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
914 |
|
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
915 |
XSendEvent(display, RootWindow(display, displaydata->screen), 0, |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
916 |
SubstructureNotifyMask | SubstructureRedirectMask, &e); |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
917 |
} else { |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
918 |
int count = 0; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
919 |
Atom atoms[3]; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
920 |
|
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
921 |
if (fullscreen) { |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
922 |
atoms[count++] = _NET_WM_STATE_FULLSCREEN; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
923 |
} |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
924 |
if (window->flags & SDL_WINDOW_MAXIMIZED) { |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
925 |
atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
926 |
atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ; |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
927 |
} |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
928 |
if (count > 0) { |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
929 |
XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32, |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
930 |
PropModeReplace, (unsigned char *)atoms, count); |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
931 |
} else { |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
932 |
XDeleteProperty(display, data->xwindow, _NET_WM_STATE); |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
933 |
} |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
934 |
} |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
935 |
XFlush(display); |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
936 |
} |
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
937 |
|
5466 | 938 |
int |
939 |
X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) |
|
940 |
{ |
|
941 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
|
942 |
Display *display = data->videodata->display; |
|
943 |
Visual *visual = data->visual; |
|
944 |
Colormap colormap = data->colormap; |
|
945 |
XColor *colorcells; |
|
946 |
int ncolors; |
|
947 |
int rmask, gmask, bmask; |
|
948 |
int rshift, gshift, bshift; |
|
5981
75caa8a7d559
Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents:
5535
diff
changeset
|
949 |
int i; |
5466 | 950 |
|
951 |
if (visual->class != DirectColor) { |
|
952 |
SDL_SetError("Window doesn't have DirectColor visual"); |
|
953 |
return -1; |
|
954 |
} |
|
955 |
||
956 |
ncolors = visual->map_entries; |
|
957 |
colorcells = SDL_malloc(ncolors * sizeof(XColor)); |
|
958 |
if (!colorcells) { |
|
959 |
SDL_OutOfMemory(); |
|
960 |
return -1; |
|
961 |
} |
|
962 |
||
963 |
rshift = 0; |
|
964 |
rmask = visual->red_mask; |
|
965 |
while (0 == (rmask & 1)) { |
|
966 |
rshift++; |
|
967 |
rmask >>= 1; |
|
968 |
} |
|
969 |
||
970 |
gshift = 0; |
|
971 |
gmask = visual->green_mask; |
|
972 |
while (0 == (gmask & 1)) { |
|
973 |
gshift++; |
|
974 |
gmask >>= 1; |
|
975 |
} |
|
976 |
||
977 |
bshift = 0; |
|
978 |
bmask = visual->blue_mask; |
|
979 |
while (0 == (bmask & 1)) { |
|
980 |
bshift++; |
|
981 |
bmask >>= 1; |
|
982 |
} |
|
983 |
||
984 |
/* build the color table pixel values */ |
|
985 |
for (i = 0; i < ncolors; i++) { |
|
986 |
Uint32 rbits = (rmask * i) / (ncolors - 1); |
|
987 |
Uint32 gbits = (gmask * i) / (ncolors - 1); |
|
988 |
Uint32 bbits = (bmask * i) / (ncolors - 1); |
|
989 |
Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift); |
|
990 |
||
991 |
colorcells[i].pixel = pix; |
|
992 |
||
993 |
colorcells[i].red = ramp[(0 * 256) + i]; |
|
994 |
colorcells[i].green = ramp[(1 * 256) + i]; |
|
995 |
colorcells[i].blue = ramp[(2 * 256) + i]; |
|
996 |
||
997 |
colorcells[i].flags = DoRed | DoGreen | DoBlue; |
|
998 |
} |
|
999 |
||
1000 |
XStoreColors(display, colormap, colorcells, ncolors); |
|
1001 |
XFlush(display); |
|
1002 |
SDL_free(colorcells); |
|
1003 |
||
1004 |
return 0; |
|
1005 |
} |
|
1006 |
||
5302
b1b9ec9874ba
Implemented X11 fullscreen toggling with modern window managers
Sam Lantinga <slouken@libsdl.org>
parents:
5288
diff
changeset
|
1007 |
void |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1008 |
X11_SetWindowGrab(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1009 |
{ |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1010 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1011 |
Display *display = data->videodata->display; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
1012 |
SDL_bool oldstyle_fullscreen; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1013 |
|
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
1014 |
/* ICCCM2.0-compliant window managers can handle fullscreen windows */ |
4522
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
1015 |
oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
1016 |
|
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
1017 |
if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen) |
2876 | 1018 |
&& (window->flags & SDL_WINDOW_INPUT_FOCUS)) { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1019 |
/* Try to grab the mouse */ |
2876 | 1020 |
for (;;) { |
1021 |
int result = |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
1022 |
XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
1023 |
GrabModeAsync, data->xwindow, None, CurrentTime); |
2876 | 1024 |
if (result == GrabSuccess) { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1025 |
break; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1026 |
} |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1027 |
SDL_Delay(100); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1028 |
} |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1029 |
|
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1030 |
/* Raise the window if we grab the mouse */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
1031 |
XRaiseWindow(display, data->xwindow); |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1032 |
|
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1033 |
/* Now grab the keyboard */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
1034 |
XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, |
2876 | 1035 |
GrabModeAsync, CurrentTime); |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1036 |
} else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1037 |
XUngrabPointer(display, CurrentTime); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1038 |
XUngrabKeyboard(display, CurrentTime); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1039 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1040 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1041 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1042 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1043 |
X11_DestroyWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1044 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1045 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1046 |
window->driverdata = NULL; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1047 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1048 |
if (data) { |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1049 |
SDL_VideoData *videodata = (SDL_VideoData *) data->videodata; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1050 |
Display *display = videodata->display; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1051 |
int numwindows = videodata->numwindows; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1052 |
SDL_WindowData **windowlist = videodata->windowlist; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1053 |
int i; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1054 |
|
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1055 |
if (windowlist) { |
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
|
1056 |
for (i = 0; i < numwindows; ++i) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3241
diff
changeset
|
1057 |
if (windowlist[i] && (windowlist[i]->window == window)) { |
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
|