Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11window.c @ 5262:956d42855c92
Finished removing unused leak detection code.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Feb 2011 14:42:06 -0800 |
parents | 58265e606e4e |
children | b530ef003506 |
rev | line source |
---|---|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #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
|
25 #include "../SDL_pixels_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #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
|
27 #include "../../events/SDL_mouse_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #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
|
30 #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
|
31 #include "SDL_x11shape.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
33 #ifdef SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
34 #include "SDL_x11opengles.h" |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
35 #endif |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
36 |
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
|
37 #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
|
38 #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
|
39 |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
40 #define _NET_WM_STATE_REMOVE 0l |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
41 #define _NET_WM_STATE_ADD 1l |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
42 #define _NET_WM_STATE_TOGGLE 2l |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
43 |
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
|
44 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
|
45 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
|
46 { |
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 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
|
48 |
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
|
49 /* 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
|
50 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
|
51 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
|
52 } 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
|
53 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
|
54 } |
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 } |
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 |
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
|
57 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
|
58 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
|
59 { |
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 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
|
61 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
|
62 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
|
63 |
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 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
|
65 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
|
66 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
|
67 } 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
|
68 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
|
69 } |
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 } |
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 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
|
73 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
|
74 { |
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 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
|
76 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
|
77 |
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 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
|
79 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
|
80 } |
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 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
|
82 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
|
83 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
|
84 } |
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 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
|
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 |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
88 static void |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
89 X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
90 { |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
91 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
92 SDL_DisplayData *displaydata = |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
93 (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
94 XWindowAttributes attr; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
95 |
4628
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
96 XGetWindowAttributes(data->display, RootWindow(data->display, displaydata->screen), &attr); |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
97 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
98 /* The bounds when this window is visible is the fullscreen mode */ |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
99 SDL_DisplayMode fullscreen_mode; |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
100 if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
101 attr.width = fullscreen_mode.w; |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
102 attr.height = fullscreen_mode.h; |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
103 } |
fad859023468
When querying the display size for a fullscreen window, the display size is the size of the fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
104 } |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
105 if (w) { |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
106 *w = attr.width; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
107 } |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
108 if (h) { |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
109 *h = attr.height; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
110 } |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
111 } |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
112 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 static int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 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
|
115 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 SDL_WindowData *data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 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
|
119 int windowlistlength = videodata->windowlistlength; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 SDL_WindowData **windowlist = videodata->windowlist; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 /* Allocate the window data */ |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
123 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
|
124 if (!data) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } |
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
|
128 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
|
129 data->xwindow = w; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 data->ic = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 XNInputStyle, XIMPreeditNothing | XIMStatusNothing, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 XNResourceName, videodata->classname, XNResourceClass, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 videodata->classname, NULL); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 data->created = created; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 data->videodata = videodata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
142 /* 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
|
143 |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
144 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
|
145 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
|
146 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
|
147 } 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
|
148 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
|
149 (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
|
150 (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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 return -1; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
156 } |
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
|
157 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
|
158 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
|
159 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
|
160 videodata->windowlist = windowlist; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
161 } |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
162 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 /* 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
|
164 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 XWindowAttributes attrib; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 XGetWindowAttributes(data->videodata->display, w, &attrib); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 window->x = attrib.x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 window->y = attrib.y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 window->w = attrib.width; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 window->h = attrib.height; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 if (attrib.map_state != IsUnmapped) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 window->flags |= SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 window->flags &= ~SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 } |
5185
073b86030262
Added the X11 framebuffer implementation. Simple! :)
Sam Lantinga <slouken@libsdl.org>
parents:
5090
diff
changeset
|
177 data->visual = attrib.visual; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 } |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
179 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
180 { |
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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 Atom actualType; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
186 int actualFormat; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
187 unsigned long i, numItems, bytesAfter; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
188 unsigned char *propertyValue = NULL; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
189 long maxLength = 1024; |
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 if (XGetWindowProperty(data->videodata->display, w, _NET_WM_STATE, |
3078 | 192 0l, maxLength, False, XA_ATOM, &actualType, |
193 &actualFormat, &numItems, &bytesAfter, | |
194 &propertyValue) == Success) { | |
195 Atom *atoms = (Atom *) propertyValue; | |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
196 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
|
197 int fullscreen = 0; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
198 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
199 for (i = 0; i < numItems; ++i) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
200 if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
201 maximized |= 1; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
202 } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
203 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
|
204 } 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
|
205 fullscreen = 1; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
206 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
207 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
208 if (maximized == 3) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
209 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
|
210 } 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
|
211 window->flags |= SDL_WINDOW_FULLSCREEN; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
212 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
213 XFree(propertyValue); |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
214 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
215 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
216 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 /* FIXME: How can I tell? |
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 DWORD style = GetWindowLong(hwnd, GWL_STYLE); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 if (style & WS_VISIBLE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 if (style & (WS_BORDER | WS_THICKFRAME)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 window->flags &= ~SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 window->flags |= SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 if (style & WS_THICKFRAME) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 window->flags |= SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 window->flags &= ~SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if (style & WS_MINIMIZE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 window->flags |= SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 window->flags &= ~SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 if (GetFocus() == hwnd) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 int index = data->videodata->keyboard; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 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
|
240 SDL_SetKeyboardFocus(index, data->window); |
1951
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 if (window->flags & SDL_WINDOW_INPUT_GRABBED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 RECT rect; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 GetClientRect(hwnd, &rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 ClientToScreen(hwnd, (LPPOINT) & rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 ClientToScreen(hwnd, (LPPOINT) & rect + 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 ClipCursor(&rect); |
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 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 /* All done! */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 window->driverdata = data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 X11_CreateWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 SDL_DisplayData *displaydata = |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
262 (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
|
263 Display *display = data->display; |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
264 int screen = displaydata->screen; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 Visual *visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 int depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 XSetWindowAttributes xattr; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 int x, y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 Window w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 XSizeHints *sizehints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 XWMHints *wmhints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 XClassHint *classhints; |
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
|
273 SDL_bool oldstyle_fullscreen; |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
274 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
|
275 Atom _NET_WM_WINDOW_TYPE_NORMAL; |
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
|
276 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
|
277 Atom wmstate_atoms[3]; |
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
|
278 |
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
|
279 /* 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
|
280 oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 /* FIXME |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 if ( use_xinerama ) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 x = xinerama_info.x_org; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 y = xinerama_info.y_org; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 #endif |
5090 | 290 #if SDL_VIDEO_OPENGL_GLX |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 if (window->flags & SDL_WINDOW_OPENGL) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
292 XVisualInfo *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
293 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
294 vinfo = X11_GL_GetVisual(_this, display, screen); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
295 if (!vinfo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
296 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
297 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
298 visual = vinfo->visual; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
299 depth = vinfo->depth; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
300 XFree(vinfo); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
301 } else |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
302 #endif |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
303 #ifdef SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
304 if (window->flags & SDL_WINDOW_OPENGL) { |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
305 XVisualInfo *vinfo; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
306 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
307 vinfo = X11_GLES_GetVisual(_this, display, screen); |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
308 if (!vinfo) { |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
309 return -1; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
310 } |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
311 visual = vinfo->visual; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
312 depth = vinfo->depth; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
313 XFree(vinfo); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
314 } else |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
315 #endif |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
316 { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 visual = displaydata->visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 depth = displaydata->depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
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
|
321 if (oldstyle_fullscreen) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 xattr.override_redirect = True; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 xattr.override_redirect = False; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 xattr.background_pixel = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 xattr.border_pixel = 0; |
5248
3a8a452b49f0
Removed gamma support since it wasn't widely used and not well supported.
Sam Lantinga <slouken@libsdl.org>
parents:
5186
diff
changeset
|
328 xattr.colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocNone); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
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
|
330 if (oldstyle_fullscreen |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
331 || SDL_WINDOWPOS_ISCENTERED(window->x)) { |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
332 X11_GetDisplaySize(_this, window, &x, NULL); |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
333 x = (x - window->w) / 2; |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
334 } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 x = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 x = window->x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 } |
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
|
339 if (oldstyle_fullscreen |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
340 || SDL_WINDOWPOS_ISCENTERED(window->y)) { |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
341 X11_GetDisplaySize(_this, window, NULL, &y); |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
342 y = (y - window->h) / 2; |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
343 } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 y = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 y = window->y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
349 w = XCreateWindow(display, RootWindow(display, screen), x, y, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 window->w, window->h, 0, depth, InputOutput, visual, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 (CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 CWColormap), &xattr); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
353 if (!w) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
354 SDL_SetError("Couldn't create window"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
355 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
356 } |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
357 #if SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
358 /* Create the GLES window surface */ |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
359 _this->gles_data->egl_surface = |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
360 _this->gles_data->eglCreateWindowSurface(_this->gles_data-> |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
361 egl_display, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
362 _this->gles_data->egl_config, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
363 (NativeWindowType) w, NULL); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
364 |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
365 if (_this->gles_data->egl_surface == EGL_NO_SURFACE) { |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
366 SDL_SetError("Could not create GLES window surface"); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
367 return -1; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
368 } |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
369 #endif |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 sizehints = XAllocSizeHints(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 if (sizehints) { |
3225
5859d0a0c519
Removed arbitrary window size limitation
Sam Lantinga <slouken@libsdl.org>
parents:
3161
diff
changeset
|
373 if (!(window->flags & SDL_WINDOW_RESIZABLE) |
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
|
374 || oldstyle_fullscreen) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 sizehints->min_width = sizehints->max_width = window->w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 sizehints->min_height = sizehints->max_height = window->h; |
3225
5859d0a0c519
Removed arbitrary window size limitation
Sam Lantinga <slouken@libsdl.org>
parents:
3161
diff
changeset
|
377 sizehints->flags = PMaxSize | PMinSize; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 } |
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
|
379 if (!oldstyle_fullscreen |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
380 && !SDL_WINDOWPOS_ISUNDEFINED(window->x) |
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
381 && !SDL_WINDOWPOS_ISUNDEFINED(window->y)) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 sizehints->x = x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 sizehints->y = y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 sizehints->flags |= USPosition; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 } |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
386 XSetWMNormalHints(display, w, sizehints); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 XFree(sizehints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 |
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
|
390 if ((window->flags & SDL_WINDOW_BORDERLESS) || oldstyle_fullscreen) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 /* 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
|
395 set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 /* 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
|
398 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
|
399 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 /* Hints used by Motif compliant window managers */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 struct |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 unsigned long flags; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 unsigned long functions; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 unsigned long decorations; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 long input_mode; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 unsigned long status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 } MWMHints = { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 (1L << 1), 0, 0, 0, 0}; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
411 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
|
412 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
|
413 sizeof(MWMHints) / 4); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 /* 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
|
417 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
|
418 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 long KWMHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
421 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
|
422 PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 (unsigned char *) &KWMHints, |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
424 sizeof(KWMHints) / 4); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 /* 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
|
428 WM_HINTS = XInternAtom(display, "_WIN_HINTS", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 long GNOMEHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
432 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
|
433 PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 (unsigned char *) &GNOMEHints, |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
435 sizeof(GNOMEHints) / 4); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 /* Finally set the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 if (!set) { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
440 XSetTransientForHint(display, w, RootWindow(display, screen)); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 /* 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
|
447 set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 /* 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
|
450 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
|
451 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
|
452 XDeleteProperty(display, w, WM_HINTS); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 /* 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
|
456 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
|
457 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
|
458 XDeleteProperty(display, w, WM_HINTS); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 /* 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
|
462 WM_HINTS = XInternAtom(display, "_WIN_HINTS", True); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 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
|
464 XDeleteProperty(display, w, WM_HINTS); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 set = SDL_TRUE; |
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 /* Finally unset the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 if (!set) { |
4555 | 469 XDeleteProperty(display, w, XA_WM_TRANSIENT_FOR); |
1951
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 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 /* Set the input hints so we get keyboard input */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 wmhints = XAllocWMHints(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 if (wmhints) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 wmhints->input = True; |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
477 wmhints->flags = InputHint; |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
478 XSetWMHints(display, w, wmhints); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 XFree(wmhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 /* Set the class hints so we can get an icon (AfterStep) */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 classhints = XAllocClassHint(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 if (classhints != NULL) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 classhints->res_name = data->classname; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 classhints->res_class = data->classname; |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
487 XSetClassHint(display, w, classhints); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 XFree(classhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
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
|
491 /* 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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 (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
|
497 } 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
|
498 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
|
499 } |
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
|
500 |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
501 /* 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
|
502 _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
|
503 _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
|
504 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
|
505 PropModeReplace, |
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
506 (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
|
507 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 /* 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
|
509 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
|
510 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 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
|
512 XDestroyWindow(display, w); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 } |
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
|
515 #ifdef X_HAVE_UTF8_STRING |
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
|
516 { |
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
|
517 Uint32 fevent = 0; |
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
|
518 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
|
519 XNFilterEvents, &fevent, NULL); |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
520 XSelectInput(display, w, |
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
|
521 (FocusChangeMask | EnterWindowMask | LeaveWindowMask | |
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
|
522 ExposureMask | ButtonPressMask | ButtonReleaseMask | |
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
|
523 PointerMotionMask | KeyPressMask | KeyReleaseMask | |
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
|
524 PropertyChangeMask | StructureNotifyMask | |
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
|
525 KeymapStateMask | fevent)); |
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
|
526 } |
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
|
527 #else |
2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset
|
528 { |
4521
50125e8aab94
Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
529 XSelectInput(display, w, |
2725 | 530 (FocusChangeMask | EnterWindowMask | LeaveWindowMask | |
531 ExposureMask | ButtonPressMask | ButtonReleaseMask | | |
532 PointerMotionMask | KeyPressMask | KeyReleaseMask | | |
533 PropertyChangeMask | StructureNotifyMask | | |
534 KeymapStateMask)); | |
2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset
|
535 } |
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
|
536 #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
|
537 |
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
|
538 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
|
539 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 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
|
544 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
|
545 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 Window w = (Window) data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 |
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
|
548 window->title = X11_GetWindowTitle(_this, w); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 |
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
|
556 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
|
557 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
|
558 { |
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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 |
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
|
567 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
|
568 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
|
569 &items_read, &items_left, &propdata); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
570 if (status == Success) { |
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
|
571 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
|
572 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
|
573 } 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
|
574 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
|
575 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
|
576 &items_read, &items_left, &propdata); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
577 if (status == Success) { |
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 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
|
579 } 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
|
580 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
|
581 } |
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
|
582 } |
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
|
583 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
|
584 } |
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
|
585 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 X11_SetWindowTitle(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 XTextProperty titleprop, iconprop; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 Status status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 const char *title = window->title; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 const char *icon = NULL; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 #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
|
597 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
|
598 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
|
599 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 if (title != NULL) { |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
602 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
|
603 if (!title_locale) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 } |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
607 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
|
608 SDL_free(title_locale); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 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
|
610 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
|
611 XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 Xutf8TextListToTextProperty(display, (char **) &title, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 XUTF8StringStyle, &titleprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 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
|
619 XSetTextProperty(display, data->xwindow, &titleprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 _NET_WM_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 #endif |
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 if (icon != NULL) { |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
627 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
|
628 if (!icon_locale) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 } |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
632 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
|
633 SDL_free(icon_locale); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 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
|
635 XSetTextProperty(display, data->xwindow, &iconprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 XA_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 Xutf8TextListToTextProperty(display, (char **) &icon, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 XUTF8StringStyle, &iconprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 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
|
645 XSetTextProperty(display, data->xwindow, &iconprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 _NET_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 } |
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
|
652 XFlush(display); |
1951
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 void |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
656 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
|
657 { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
658 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
|
659 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
|
660 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
|
661 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
662 if (icon) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
663 SDL_PixelFormat format; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
664 SDL_Surface *surface; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
665 int propsize; |
4528 | 666 long *propdata; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
667 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
668 /* Convert the icon to ARGB for modern window managers */ |
2990 | 669 SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, |
670 0xFF000000); | |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
671 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
|
672 if (!surface) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
673 return; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
674 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
675 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
676 /* Set the _NET_WM_ICON property */ |
2990 | 677 propsize = 2 + (icon->w * icon->h); |
4566
40c833d951a1
Fixed memory corruption on AMD64
Sam Lantinga <slouken@libsdl.org>
parents:
4555
diff
changeset
|
678 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
|
679 if (propdata) { |
4528 | 680 int x, y; |
681 Uint32 *src; | |
682 long *dst; | |
683 | |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
684 propdata[0] = icon->w; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
685 propdata[1] = icon->h; |
4528 | 686 dst = &propdata[2]; |
687 for (y = 0; y < icon->h; ++y) { | |
688 src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch); | |
689 for (x = 0; x < icon->w; ++x) { | |
690 *dst++ = *src++; | |
691 } | |
692 } | |
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
|
693 XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, |
2990 | 694 32, PropModeReplace, (unsigned char *) propdata, |
695 propsize); | |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
696 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
697 SDL_FreeSurface(surface); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
698 } 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
|
699 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
|
700 } |
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
|
701 XFlush(display); |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
702 } |
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 void |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 X11_SetWindowPosition(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 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
|
709 SDL_bool oldstyle_fullscreen; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
710 int x, y; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 |
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
|
712 /* 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
|
713 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
|
714 |
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
|
715 if (oldstyle_fullscreen |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
716 || SDL_WINDOWPOS_ISCENTERED(window->x)) { |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
717 X11_GetDisplaySize(_this, window, &x, NULL); |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
718 x = (x - window->w) / 2; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
719 } else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
720 x = window->x; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
721 } |
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
|
722 if (oldstyle_fullscreen |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
723 || SDL_WINDOWPOS_ISCENTERED(window->y)) { |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
724 X11_GetDisplaySize(_this, window, NULL, &y); |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
725 y = (y - window->h) / 2; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
726 } else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
727 y = window->y; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
728 } |
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
|
729 XMoveWindow(display, data->xwindow, x, 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
|
730 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
732 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 X11_SetWindowSize(_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 |
4937
24d44c7c4c63
Don't crash when resizing non-shaped windows
Sam Lantinga <slouken@libsdl.org>
parents:
4902
diff
changeset
|
739 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
|
740 X11_ResizeWindowShape(window); |
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
|
741 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
|
742 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 X11_ShowWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 |
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
|
751 XMapRaised(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
|
752 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
753 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
754 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
755 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
756 X11_HideWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
757 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
758 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
759 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
760 |
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
|
761 XUnmapWindow(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
|
762 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
763 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
764 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
765 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
766 X11_RaiseWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
767 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
768 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
769 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
770 |
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
|
771 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
|
772 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
773 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
774 |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
775 static void |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
776 X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
777 { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
778 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
779 SDL_DisplayData *displaydata = |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
780 (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
781 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
|
782 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
|
783 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
|
784 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
|
785 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
|
786 |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
787 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
|
788 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
|
789 |
4524
a256e1dadf3f
Zero any fields not explicitly filled in.
Sam Lantinga <slouken@libsdl.org>
parents:
4522
diff
changeset
|
790 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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 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
|
799 e.xclient.data.l[3] = 0l; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
800 |
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
|
801 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
|
802 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
|
803 } 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
|
804 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
|
805 Atom atoms[3]; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
806 |
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
|
807 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
|
808 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
|
809 } |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
810 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
|
811 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
|
812 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
|
813 } |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
814 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
|
815 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
|
816 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
|
817 } 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
|
818 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
|
819 } |
a4da6b906abb
Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents:
4521
diff
changeset
|
820 } |
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
|
821 XFlush(display); |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
822 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
823 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 X11_MaximizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 { |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
827 X11_SetWindowMaximized(_this, window, SDL_TRUE); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
828 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
830 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 X11_MinimizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
832 { |
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
|
833 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
|
834 SDL_DisplayData *displaydata = |
5251
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5248
diff
changeset
|
835 (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
|
836 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
|
837 |
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
|
838 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
|
839 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
840 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
841 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
842 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
843 X11_RestoreWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
844 { |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
845 X11_SetWindowMaximized(_this, window, SDL_FALSE); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
846 X11_ShowWindow(_this, window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
847 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
848 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
849 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 X11_SetWindowGrab(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
852 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
853 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
|
854 SDL_bool oldstyle_fullscreen; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
855 |
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
|
856 /* 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
|
857 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
|
858 |
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
|
859 if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen) |
2876 | 860 && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
861 /* Try to grab the mouse */ |
2876 | 862 for (;;) { |
863 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
|
864 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
|
865 GrabModeAsync, data->xwindow, None, CurrentTime); |
2876 | 866 if (result == GrabSuccess) { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
867 break; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
868 } |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
869 SDL_Delay(100); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
870 } |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
871 |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
872 /* 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
|
873 XRaiseWindow(display, data->xwindow); |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
874 |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
875 /* 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
|
876 XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, |
2876 | 877 GrabModeAsync, CurrentTime); |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
878 } else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
879 XUngrabPointer(display, CurrentTime); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
880 XUngrabKeyboard(display, CurrentTime); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
881 } |
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_DestroyWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
887 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
|
888 window->driverdata = NULL; |
1951
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 if (data) { |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
891 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
|
892 Display *display = videodata->display; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
893 int numwindows = videodata->numwindows; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
894 SDL_WindowData **windowlist = videodata->windowlist; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
895 int i; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
896 |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
897 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
|
898 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
|
899 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
changeset
|
900 windowlist[i] = windowlist[numwindows - 1]; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
901 windowlist[numwindows - 1] = NULL; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
902 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
|
903 break; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
904 } |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
905 } |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
906 } |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 if (data->ic) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 XDestroyIC(data->ic); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 if (data->created) { |
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
|
913 XDestroyWindow(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
|
914 XFlush(display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 SDL_free(data); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
917 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
919 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
920 SDL_bool |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
922 { |
4510
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
923 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
924 Display *display = data->videodata->display; |
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
925 |
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
926 if (info->version.major == SDL_MAJOR_VERSION && |
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
927 info->version.minor == SDL_MINOR_VERSION) { |
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
928 info->subsystem = SDL_SYSWM_X11; |
5056
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
5031
diff
changeset
|
929 info->info.x11.display = display; |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
5031
diff
changeset
|
930 info->info.x11.window = data->xwindow; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
931 return SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
932 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
933 SDL_SetError("Application not compiled with SDL %d.%d\n", |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
934 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
935 return SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 /* vi: set ts=4 sw=4 expandtab: */ |