annotate src/video/x11/SDL_x11window.c @ 4630:02895e9c796b

Added some comments.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Mon, 02 Aug 2010 17:14:09 +0530
parents 844b5ef4b149
children fad859023468
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
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
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"
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
31 #include "SDL_x11gamma.h"
2185
2032348afed1 This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents: 2143
diff changeset
32 #include "../Xext/extensions/StdCmap.h"
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
34 #ifdef SDL_VIDEO_DRIVER_PANDORA
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
35 #include "SDL_x11opengles.h"
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
36 #endif
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
37
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
38 #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
39 #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
40
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
41 #define _NET_WM_STATE_REMOVE 0l
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
42 #define _NET_WM_STATE_ADD 1l
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
43 #define _NET_WM_STATE_TOGGLE 2l
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
44
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
45 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
46 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
47 {
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
48 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
49
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 /* 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
51 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
52 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
53 } 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
54 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
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 }
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4510
diff changeset
57
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
58 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
59 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
60 {
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_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
62 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
63 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
64
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 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
66 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
67 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
68 } 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
69 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
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
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 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
74 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
75 {
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 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
77 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
78
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 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
80 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
81 }
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 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
83 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
84 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
85 }
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 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
87 }
a4da6b906abb Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents: 4521
diff changeset
88
2931
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
89 static void
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
90 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
91 {
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
92 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
93 SDL_DisplayData *displaydata =
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
94 (SDL_DisplayData *) window->display->driverdata;
2931
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
95 XWindowAttributes attr;
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
96
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
97 XGetWindowAttributes(data->display, RootWindow(data->display,
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
98 displaydata->screen),
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
99 &attr);
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
100 if (w) {
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
101 *w = attr.width;
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
102 }
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
103 if (h) {
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
104 *h = attr.height;
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
105 }
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
106 }
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
107
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 static int
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 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
110 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 SDL_WindowData *data;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 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
114 int windowlistlength = videodata->windowlistlength;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 SDL_WindowData **windowlist = videodata->windowlist;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 /* Allocate the window data */
2323
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
118 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
119 if (!data) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 SDL_OutOfMemory();
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 return -1;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 }
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
123 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
124 data->xwindow = w;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 #ifdef X_HAVE_UTF8_STRING
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 if (SDL_X11_HAVE_UTF8) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 data->ic =
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 XNResourceName, videodata->classname, XNResourceClass,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 videodata->classname, NULL);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 data->created = created;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 data->videodata = videodata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
2323
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
137 /* 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
138
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2323
diff changeset
139 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
140 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
141 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
142 } 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
143 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
144 (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
145 (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
146 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
147 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
148 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
149 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
150 return -1;
2323
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
151 }
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
152 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
153 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
154 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
155 videodata->windowlist = windowlist;
2323
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
156 }
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
157
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 /* 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
159 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 XWindowAttributes attrib;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 XGetWindowAttributes(data->videodata->display, w, &attrib);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 window->x = attrib.x;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 window->y = attrib.y;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 window->w = attrib.width;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 window->h = attrib.height;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 if (attrib.map_state != IsUnmapped) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 window->flags |= SDL_WINDOW_SHOWN;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 window->flags &= ~SDL_WINDOW_SHOWN;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 }
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
173
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
174 {
4518
a956a315fe67 Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents: 4510
diff changeset
175 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
176 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
177 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
178 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
179 Atom actualType;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
180 int actualFormat;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
181 unsigned long i, numItems, bytesAfter;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
182 unsigned char *propertyValue = NULL;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
183 long maxLength = 1024;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
184
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
185 if (XGetWindowProperty(data->videodata->display, w, _NET_WM_STATE,
3078
Sam Lantinga <slouken@libsdl.org>
parents: 3077
diff changeset
186 0l, maxLength, False, XA_ATOM, &actualType,
Sam Lantinga <slouken@libsdl.org>
parents: 3077
diff changeset
187 &actualFormat, &numItems, &bytesAfter,
Sam Lantinga <slouken@libsdl.org>
parents: 3077
diff changeset
188 &propertyValue) == Success) {
Sam Lantinga <slouken@libsdl.org>
parents: 3077
diff changeset
189 Atom *atoms = (Atom *) propertyValue;
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
190 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
191 int fullscreen = 0;
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
192
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
193 for (i = 0; i < numItems; ++i) {
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
194 if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
195 maximized |= 1;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
196 } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
197 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
198 } 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
199 fullscreen = 1;
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
200 }
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
201 }
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
202 if (maximized == 3) {
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
203 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
204 } 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
205 window->flags |= SDL_WINDOW_FULLSCREEN;
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 XFree(propertyValue);
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
208 }
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
209 }
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
210
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 /* FIXME: How can I tell?
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 DWORD style = GetWindowLong(hwnd, GWL_STYLE);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 if (style & WS_VISIBLE) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 if (style & (WS_BORDER | WS_THICKFRAME)) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 window->flags &= ~SDL_WINDOW_BORDERLESS;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 window->flags |= SDL_WINDOW_BORDERLESS;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 if (style & WS_THICKFRAME) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 window->flags |= SDL_WINDOW_RESIZABLE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 window->flags &= ~SDL_WINDOW_RESIZABLE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 if (style & WS_MINIMIZE) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 window->flags |= SDL_WINDOW_MINIMIZED;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 window->flags &= ~SDL_WINDOW_MINIMIZED;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 if (GetFocus() == hwnd) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 int index = data->videodata->keyboard;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 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
234 SDL_SetKeyboardFocus(index, data->window);
1951
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 if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 RECT rect;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 GetClientRect(hwnd, &rect);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 ClientToScreen(hwnd, (LPPOINT) & rect);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 ClipCursor(&rect);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 /* All done! */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 window->driverdata = data;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 return 0;
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 int
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 X11_CreateWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 SDL_DisplayData *displaydata =
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
256 (SDL_DisplayData *) window->display->driverdata;
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
257 Display *display = data->display;
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
258 int screen = displaydata->screen;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 Visual *visual;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 int depth;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 XSetWindowAttributes xattr;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 int x, y;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 Window w;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 XSizeHints *sizehints;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 XWMHints *wmhints;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 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
267 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
268 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
269 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
270 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
271 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
272
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 /* 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
274 oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 #if SDL_VIDEO_DRIVER_X11_XINERAMA
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 /* FIXME
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 if ( use_xinerama ) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 x = xinerama_info.x_org;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 y = xinerama_info.y_org;
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 */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 #endif
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
284 #ifdef SDL_VIDEO_OPENGL_GLX
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 if (window->flags & SDL_WINDOW_OPENGL) {
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
286 XVisualInfo *vinfo;
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
287
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
288 vinfo = X11_GL_GetVisual(_this, display, screen);
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
289 if (!vinfo) {
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
290 return -1;
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
291 }
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
292 visual = vinfo->visual;
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
293 depth = vinfo->depth;
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
294 XFree(vinfo);
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
295 } else
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
296 #endif
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
297 #ifdef SDL_VIDEO_DRIVER_PANDORA
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
298 if (window->flags & SDL_WINDOW_OPENGL) {
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
299 XVisualInfo *vinfo;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
300
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
301 vinfo = X11_GLES_GetVisual(_this, display, screen);
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
302 if (!vinfo) {
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
303 return -1;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
304 }
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
305 visual = vinfo->visual;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
306 depth = vinfo->depth;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
307 XFree(vinfo);
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
308 } else
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
309 #endif
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
310 {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 visual = displaydata->visual;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 depth = displaydata->depth;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314
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
315 if (oldstyle_fullscreen) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 xattr.override_redirect = True;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 xattr.override_redirect = False;
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 xattr.background_pixel = 0;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 xattr.border_pixel = 0;
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
322
2945
e38423786728 Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents: 2942
diff changeset
323 if (visual->class == PseudoColor) {
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
324 printf("asking for PseudoColor\n");
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
325
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
326 /* Status status; */
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
327 XColor *colorcells;
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
328 Colormap colormap;
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
329 Sint32 pix;
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
330 Sint32 ncolors;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
331 Sint32 nbits;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
332 Sint32 rmax, gmax, bmax;
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
333 Sint32 rwidth, gwidth, bwidth;
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
334 Sint32 rmask, gmask, bmask;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
335 Sint32 rshift, gshift, bshift;
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
336 Sint32 r, g, b;
2185
2032348afed1 This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents: 2143
diff changeset
337
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
338 /* Is the colormap we need already registered in SDL? */
4505
f78a602ac135 Fixed compiler warning
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
339 if ((colormap =
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
340 X11_LookupColormap(display, screen, visual->visualid))) {
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
341 xattr.colormap = colormap;
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
342 /* printf("found existing colormap\n"); */
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
343 } else {
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
344 /* The colormap is not known to SDL so we will create it */
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
345 colormap = XCreateColormap(display, RootWindow(display, screen),
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
346 visual, AllocAll);
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
347 /* printf("colormap = %x\n", colormap); */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
348
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
349 /* If we can't create a colormap, then we must die */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
350 if (!colormap) {
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
351 SDL_SetError
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
352 ("Couldn't create window: Could not create writable colormap");
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
353 return -1;
2185
2032348afed1 This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents: 2143
diff changeset
354 }
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2211
diff changeset
355
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
356 /* OK, we got a colormap, now fill it in as best as we can */
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
357
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
358 colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
359 if (NULL == colorcells) {
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
360 SDL_SetError("out of memory in X11_CreateWindow");
2185
2032348afed1 This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents: 2143
diff changeset
361 return -1;
2032348afed1 This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents: 2143
diff changeset
362 }
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
363
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
364 ncolors = visual->map_entries;
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
365 nbits = visual->bits_per_rgb;
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
366
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
367 /* printf("ncolors = %d nbits = %d\n", ncolors, nbits); */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
368
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
369 /* what if ncolors != (1 << nbits)? That can happen on a
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
370 true PseudoColor display. I'm assuming that we will
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
371 always have ncolors == (1 << nbits) */
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
372
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
373 /* I'm making a lot of assumptions here. */
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
374
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
375 /* Compute the width of each field. If there is one extra
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
376 bit, give it to green. If there are two extra bits give
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
377 them to red and greed. We can get extra bits when the
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
378 number of bits per pixel is not a multiple of 3. For
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
379 example when we have 16 bits per pixel and need a 5/6/5
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
380 layout for the RGB fields */
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
381
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
382 rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
383 gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
384 bwidth = (nbits / 3);
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
385
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
386 rshift = gwidth + bwidth;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
387 gshift = bwidth;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
388 bshift = 0;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
389
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
390 rmax = 1 << rwidth;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
391 gmax = 1 << gwidth;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
392 bmax = 1 << bwidth;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
393
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
394 rmask = rmax - 1;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
395 gmask = gmax - 1;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
396 bmask = bmax - 1;
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
397
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
398 /* printf("red mask = %4x shift = %4d width = %d\n", rmask, rshift, rwidth); */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
399 /* printf("green mask = %4x shift = %4d width = %d\n", gmask, gshift, gwidth); */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
400 /* printf("blue mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
401
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
402 /* build the color table pixel values */
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
403 pix = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
404 for (r = 0; r < rmax; r++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
405 for (g = 0; g < gmax; g++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
406 for (b = 0; b < bmax; b++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
407 colorcells[pix].pixel =
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
408 (r << rshift) | (g << gshift) | (b << bshift);
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
409 colorcells[pix].red = (0xffff * r) / rmask;
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
410 colorcells[pix].green = (0xffff * g) / gmask;
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
411 colorcells[pix].blue = (0xffff * b) / bmask;
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
412 /* printf("%4x:%4x [%4x %4x %4x]\n", */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
413 /* pix, */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
414 /* colorcells[pix].pixel, */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
415 /* colorcells[pix].red, */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
416 /* colorcells[pix].green, */
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
417 /* colorcells[pix].blue); */
3052
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
418 pix++;
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
419 }
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
420 }
Sam Lantinga <slouken@libsdl.org>
parents: 3044
diff changeset
421 }
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
422
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
423 /* status = */
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
424 /* XStoreColors(display, colormap, colorcells, ncolors); */
2214
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
425
e7164a4dac62 Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
426 xattr.colormap = colormap;
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
427 X11_TrackColormap(display, screen, colormap, visual, NULL);
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
428
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
429 SDL_free(colorcells);
2185
2032348afed1 This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents: 2143
diff changeset
430 }
2945
e38423786728 Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents: 2942
diff changeset
431 } else if (visual->class == DirectColor) {
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
432 Status status;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
433 XColor *colorcells;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
434 Colormap colormap;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
435 int i;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
436 int ncolors;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
437 int rmax, gmax, bmax;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
438 int rmask, gmask, bmask;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
439 int rshift, gshift, bshift;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
440
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
441 /* Is the colormap we need already registered in SDL? */
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
442 if ((colormap =
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
443 X11_LookupColormap(display, screen, visual->visualid))) {
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
444 xattr.colormap = colormap;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
445 /* printf("found existing colormap\n"); */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
446 } else {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
447 /* The colormap is not known to SDL so we will create it */
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
448 colormap = XCreateColormap(display, RootWindow(display, screen),
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
449 visual, AllocAll);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
450 /* printf("colormap = %x\n", colormap); */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
451
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
452 /* If we can't create a colormap, then we must die */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
453 if (!colormap) {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
454 SDL_SetError
3044
b36579172f27 Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents: 3009
diff changeset
455 ("Couldn't create window: Could not create writable colormap");
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
456 return -1;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
457 }
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
458
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
459 /* OK, we got a colormap, now fill it in as best as we can */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
460 colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
461 if (NULL == colorcells) {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
462 SDL_SetError("out of memory in X11_CreateWindow");
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
463 return -1;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
464 }
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
465 ncolors = visual->map_entries;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
466 rmax = 0xffff;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
467 gmax = 0xffff;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
468 bmax = 0xffff;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
469
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
470 rshift = 0;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
471 rmask = visual->red_mask;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
472 while (0 == (rmask & 1)) {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
473 rshift++;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
474 rmask >>= 1;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
475 }
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
476
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
477 /* printf("rmask = %4x rshift = %4d\n", rmask, rshift); */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
478
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
479 gshift = 0;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
480 gmask = visual->green_mask;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
481 while (0 == (gmask & 1)) {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
482 gshift++;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
483 gmask >>= 1;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
484 }
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
485
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
486 /* printf("gmask = %4x gshift = %4d\n", gmask, gshift); */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
487
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
488 bshift = 0;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
489 bmask = visual->blue_mask;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
490 while (0 == (bmask & 1)) {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
491 bshift++;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
492 bmask >>= 1;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
493 }
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
494
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
495 /* printf("bmask = %4x bshift = %4d\n", bmask, bshift); */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
496
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
497 /* build the color table pixel values */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
498 for (i = 0; i < ncolors; i++) {
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
499 Uint32 red = (rmax * i) / (ncolors - 1);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
500 Uint32 green = (gmax * i) / (ncolors - 1);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
501 Uint32 blue = (bmax * i) / (ncolors - 1);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
502
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
503 Uint32 rbits = (rmask * i) / (ncolors - 1);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
504 Uint32 gbits = (gmask * i) / (ncolors - 1);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
505 Uint32 bbits = (bmask * i) / (ncolors - 1);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
506
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
507 Uint32 pix =
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
508 (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
509
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
510 colorcells[i].pixel = pix;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
511
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
512 colorcells[i].red = red;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
513 colorcells[i].green = green;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
514 colorcells[i].blue = blue;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
515
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
516 colorcells[i].flags = DoRed | DoGreen | DoBlue;
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
517 /* printf("%2d:%4x [%4x %4x %4x]\n", i, pix, red, green, blue); */
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
518 }
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
519
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
520 status =
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
521 XStoreColors(display, colormap, colorcells, ncolors);
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
522
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
523 xattr.colormap = colormap;
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
524 X11_TrackColormap(display, screen, colormap, visual, colorcells);
3009
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
525
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
526 SDL_free(colorcells);
546c022a9ae5 Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents: 2990
diff changeset
527 }
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 xattr.colormap =
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
530 XCreateColormap(display, RootWindow(display, screen),
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 visual, AllocNone);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533
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
534 if (oldstyle_fullscreen
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
535 || window->x == SDL_WINDOWPOS_CENTERED) {
2931
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
536 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
537 x = (x - window->w) / 2;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 x = 0;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 x = window->x;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 }
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
543 if (oldstyle_fullscreen
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
544 || window->y == SDL_WINDOWPOS_CENTERED) {
2931
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
545 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
546 y = (y - window->h) / 2;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 y = 0;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 y = window->y;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
553 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
554 window->w, window->h, 0, depth, InputOutput, visual,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 CWColormap), &xattr);
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
557 if (!w) {
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
558 SDL_SetError("Couldn't create window");
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
559 return -1;
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
560 }
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
561 #if SDL_VIDEO_DRIVER_PANDORA
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
562 /* Create the GLES window surface */
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
563 _this->gles_data->egl_surface =
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
564 _this->gles_data->eglCreateWindowSurface(_this->gles_data->
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
565 egl_display,
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
566 _this->gles_data->egl_config,
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
567 (NativeWindowType) w, NULL);
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
568
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
569 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
570 SDL_SetError("Could not create GLES window surface");
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
571 return -1;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
572 }
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3078
diff changeset
573 #endif
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 sizehints = XAllocSizeHints();
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 if (sizehints) {
3225
5859d0a0c519 Removed arbitrary window size limitation
Sam Lantinga <slouken@libsdl.org>
parents: 3161
diff changeset
577 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
578 || oldstyle_fullscreen) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 sizehints->min_width = sizehints->max_width = window->w;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 sizehints->min_height = sizehints->max_height = window->h;
3225
5859d0a0c519 Removed arbitrary window size limitation
Sam Lantinga <slouken@libsdl.org>
parents: 3161
diff changeset
581 sizehints->flags = PMaxSize | PMinSize;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 }
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
583 if (!oldstyle_fullscreen
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 && window->x != SDL_WINDOWPOS_UNDEFINED
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 && window->y != SDL_WINDOWPOS_UNDEFINED) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 sizehints->x = x;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 sizehints->y = y;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 sizehints->flags |= USPosition;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 }
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
590 XSetWMNormalHints(display, w, sizehints);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 XFree(sizehints);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593
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
594 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
595 SDL_bool set;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 Atom WM_HINTS;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 /* 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
599 set = SDL_FALSE;
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 /* 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
602 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
603 if (WM_HINTS != None) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 /* Hints used by Motif compliant window managers */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 struct
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 unsigned long flags;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608 unsigned long functions;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 unsigned long decorations;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 long input_mode;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 unsigned long status;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 } MWMHints = {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 (1L << 1), 0, 0, 0, 0};
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
615 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
616 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
617 sizeof(MWMHints) / 4);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 set = SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 /* 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
621 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
622 if (WM_HINTS != None) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 long KWMHints = 0;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
625 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
626 PropModeReplace,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 (unsigned char *) &KWMHints,
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
628 sizeof(KWMHints) / 4);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 set = SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 /* 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
632 WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 if (WM_HINTS != None) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 long GNOMEHints = 0;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
636 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
637 PropModeReplace,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 (unsigned char *) &GNOMEHints,
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
639 sizeof(GNOMEHints) / 4);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 set = SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 /* Finally set the transient hints if necessary */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 if (!set) {
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
644 XSetTransientForHint(display, w, RootWindow(display, screen));
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 SDL_bool set;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 Atom WM_HINTS;
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 /* 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
651 set = SDL_FALSE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 /* 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
654 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
655 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
656 XDeleteProperty(display, w, WM_HINTS);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 set = SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 /* 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
660 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
661 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
662 XDeleteProperty(display, w, WM_HINTS);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 set = SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 /* 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
666 WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 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
668 XDeleteProperty(display, w, WM_HINTS);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669 set = SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671 /* Finally unset the transient hints if necessary */
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 if (!set) {
4555
9e73d17638d3 Fixed bug 1015
Sam Lantinga <slouken@libsdl.org>
parents: 4528
diff changeset
673 XDeleteProperty(display, w, XA_WM_TRANSIENT_FOR);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 /* 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
678 wmhints = XAllocWMHints();
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 if (wmhints) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 wmhints->input = True;
1956
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
681 wmhints->flags = InputHint;
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
682 XSetWMHints(display, w, wmhints);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 XFree(wmhints);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 /* 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
687 classhints = XAllocClassHint();
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 if (classhints != NULL) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 classhints->res_name = data->classname;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 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
691 XSetClassHint(display, w, classhints);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692 XFree(classhints);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694
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
695 /* 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
696 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
697 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
698 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
699 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
700 (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
701 } 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
702 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
703 }
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
704
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
705 /* 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
706 _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
707 _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
708 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
709 PropModeReplace,
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
710 (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
711
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
712 /* 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
713 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
714
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
715 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
716 XDestroyWindow(display, w);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
717 return -1;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
718 }
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
719 #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
720 {
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
721 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
722 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
723 XNFilterEvents, &fevent, NULL);
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
724 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
725 (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
726 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
727 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
728 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
729 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
730 }
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
731 #else
2718
abacf2555bb4 Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents: 2710
diff changeset
732 {
4521
50125e8aab94 Let the window manager know we're a "normal" window
Sam Lantinga <slouken@libsdl.org>
parents: 4520
diff changeset
733 XSelectInput(display, w,
2725
Sam Lantinga <slouken@libsdl.org>
parents: 2718
diff changeset
734 (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
Sam Lantinga <slouken@libsdl.org>
parents: 2718
diff changeset
735 ExposureMask | ButtonPressMask | ButtonReleaseMask |
Sam Lantinga <slouken@libsdl.org>
parents: 2718
diff changeset
736 PointerMotionMask | KeyPressMask | KeyReleaseMask |
Sam Lantinga <slouken@libsdl.org>
parents: 2718
diff changeset
737 PropertyChangeMask | StructureNotifyMask |
Sam Lantinga <slouken@libsdl.org>
parents: 2718
diff changeset
738 KeymapStateMask));
2718
abacf2555bb4 Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents: 2710
diff changeset
739 }
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
740 #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
741
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742 return 0;
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 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
746 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
747 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
748 Window w = (Window) data;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
749
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
750 window->title = X11_GetWindowTitle(_this, w);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752 if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 return -1;
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 return 0;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
756 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
757
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
758 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
759 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
760 {
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
761 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
762 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
763 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
764 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
765 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
766 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
767 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
768
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
769 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
770 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
771 &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
772 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
773 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
774 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
775 } 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
776 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
777 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
778 &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
779 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
780 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
781 } 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
782 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
783 }
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 }
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
785 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
786 }
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
787
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
788 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789 X11_SetWindowTitle(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
790 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
791 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792 Display *display = data->videodata->display;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793 XTextProperty titleprop, iconprop;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
794 Status status;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795 const char *title = window->title;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
796 const char *icon = NULL;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
797
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798 #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
799 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
800 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
801 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
802
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
803 if (title != NULL) {
2143
e906da4414a3 Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
804 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
805 if (!title_locale) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 SDL_OutOfMemory();
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 return;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808 }
2143
e906da4414a3 Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
809 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
810 SDL_free(title_locale);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811 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
812 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
813 XFree(titleprop.value);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
814 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
815 #ifdef X_HAVE_UTF8_STRING
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
816 if (SDL_X11_HAVE_UTF8) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 status =
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
818 Xutf8TextListToTextProperty(display, (char **) &title, 1,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
819 XUTF8StringStyle, &titleprop);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
820 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
821 XSetTextProperty(display, data->xwindow, &titleprop,
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
822 _NET_WM_NAME);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
823 XFree(titleprop.value);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
824 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
826 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
827 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
828 if (icon != NULL) {
2143
e906da4414a3 Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
829 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
830 if (!icon_locale) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
831 SDL_OutOfMemory();
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
832 return;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
833 }
2143
e906da4414a3 Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
834 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
835 SDL_free(icon_locale);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836 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
837 XSetTextProperty(display, data->xwindow, &iconprop,
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
838 XA_WM_ICON_NAME);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
839 XFree(iconprop.value);
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 #ifdef X_HAVE_UTF8_STRING
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
842 if (SDL_X11_HAVE_UTF8) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 status =
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 Xutf8TextListToTextProperty(display, (char **) &icon, 1,
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 XUTF8StringStyle, &iconprop);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
846 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
847 XSetTextProperty(display, data->xwindow, &iconprop,
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
848 _NET_WM_ICON_NAME);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
849 XFree(iconprop.value);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
850 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
851 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
852 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
855
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
856 void
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
857 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
858 {
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
859 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
860 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
861 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
862
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
863 if (icon) {
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
864 SDL_PixelFormat format;
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
865 SDL_Surface *surface;
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
866 int propsize;
4528
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
867 long *propdata;
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
868
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
869 /* Convert the icon to ARGB for modern window managers */
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2967
diff changeset
870 SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
Sam Lantinga <slouken@libsdl.org>
parents: 2967
diff changeset
871 0xFF000000);
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
872 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
873 if (!surface) {
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
874 return;
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
875 }
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
876
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
877 /* Set the _NET_WM_ICON property */
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2967
diff changeset
878 propsize = 2 + (icon->w * icon->h);
4566
40c833d951a1 Fixed memory corruption on AMD64
Sam Lantinga <slouken@libsdl.org>
parents: 4555
diff changeset
879 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
880 if (propdata) {
4528
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
881 int x, y;
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
882 Uint32 *src;
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
883 long *dst;
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
884
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
885 propdata[0] = icon->w;
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
886 propdata[1] = icon->h;
4528
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
887 dst = &propdata[2];
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
888 for (y = 0; y < icon->h; ++y) {
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
889 src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch);
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
890 for (x = 0; x < icon->w; ++x) {
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
891 *dst++ = *src++;
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
892 }
f06faa886423 Fixed bug 1022
Sam Lantinga <slouken@libsdl.org>
parents: 4524
diff changeset
893 }
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
894 XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2967
diff changeset
895 32, PropModeReplace, (unsigned char *) propdata,
Sam Lantinga <slouken@libsdl.org>
parents: 2967
diff changeset
896 propsize);
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
897 }
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
898 SDL_FreeSurface(surface);
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
899 } 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
900 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
901 }
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
902 }
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
903
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2945
diff changeset
904 void
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905 X11_SetWindowPosition(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
906 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908 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
909 SDL_bool oldstyle_fullscreen;
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
910 int x, y;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911
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
912 /* 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
913 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
914
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
915 if (oldstyle_fullscreen
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
916 || window->x == SDL_WINDOWPOS_CENTERED) {
2931
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
917 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
918 x = (x - window->w) / 2;
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
919 } else {
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
920 x = window->x;
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
921 }
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
922 if (oldstyle_fullscreen
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
923 || window->y == SDL_WINDOWPOS_CENTERED) {
2931
e705adf6f3dc Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
924 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
925 y = (y - window->h) / 2;
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
926 } else {
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
927 y = window->y;
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
928 }
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
929 XMoveWindow(display, data->xwindow, x, y);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 X11_SetWindowSize(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
934 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
935 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
936 Display *display = data->videodata->display;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
937
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
938 XResizeWindow(display, data->xwindow, window->w, window->h);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
939 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
940
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
941 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
942 X11_ShowWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
943 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
944 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
945 Display *display = data->videodata->display;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
946
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
947 XMapRaised(display, data->xwindow);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
948 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
949
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
950 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951 X11_HideWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
952 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
953 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
954 Display *display = data->videodata->display;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
955
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
956 XUnmapWindow(display, data->xwindow);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
957 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
958
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
960 X11_RaiseWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
961 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
962 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
963 Display *display = data->videodata->display;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
964
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
965 XRaiseWindow(display, data->xwindow);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
966 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
967
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
968 static void
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
969 X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
970 {
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
971 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
972 SDL_DisplayData *displaydata =
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
973 (SDL_DisplayData *) window->display->driverdata;
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
974 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
975 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
976 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
977 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
978 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
979
a4da6b906abb Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents: 4521
diff changeset
980 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
981 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
982
4524
a256e1dadf3f Zero any fields not explicitly filled in.
Sam Lantinga <slouken@libsdl.org>
parents: 4522
diff changeset
983 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
984 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
985 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
986 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
987 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
988 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
989 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
990 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
991 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
992 e.xclient.data.l[3] = 0l;
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
993
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
994 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
995 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
996 } 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
997 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
998 Atom atoms[3];
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
999
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
1000 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
1001 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
1002 }
a4da6b906abb Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents: 4521
diff changeset
1003 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
1004 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
1005 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
1006 }
a4da6b906abb Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents: 4521
diff changeset
1007 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
1008 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
1009 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
1010 } 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
1011 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
1012 }
a4da6b906abb Fixed setting fullscreen and maximized states for windows that haven't been mapped yet.
Sam Lantinga <slouken@libsdl.org>
parents: 4521
diff changeset
1013 }
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
1014 }
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
1015
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1016 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1017 X11_MaximizeWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1018 {
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
1019 X11_SetWindowMaximized(_this, window, SDL_TRUE);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1020 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1021
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1022 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1023 X11_MinimizeWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 {
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
1025 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
1026 SDL_DisplayData *displaydata =
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
1027 (SDL_DisplayData *) window->display->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
1028 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
1029
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
1030 XIconifyWindow(display, data->xwindow, displaydata->screen);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1031 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1032
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1033 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1034 X11_RestoreWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1035 {
3077
9b58f26ede81 Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
1036 X11_SetWindowMaximized(_this, window, SDL_FALSE);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1037 X11_ShowWindow(_this, window);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1038 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1039
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1040 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1041 X11_SetWindowGrab(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1042 {
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1043 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1044 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
1045 SDL_bool oldstyle_fullscreen;
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1046
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
1047 /* 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
1048 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
1049
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
1050 if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen)
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
1051 && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1052 /* Try to grab the mouse */
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
1053 for (;;) {
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
1054 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
1055 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
1056 GrabModeAsync, data->xwindow, None, CurrentTime);
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
1057 if (result == GrabSuccess) {
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1058 break;
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1059 }
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1060 SDL_Delay(100);
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1061 }
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1062
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1063 /* 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
1064 XRaiseWindow(display, data->xwindow);
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1065
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1066 /* 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
1067 XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
1068 GrabModeAsync, CurrentTime);
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1069 } else {
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1070 XUngrabPointer(display, CurrentTime);
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1071 XUngrabKeyboard(display, CurrentTime);
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
1072 }
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1073 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1074
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1075 void
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1076 X11_DestroyWindow(_THIS, SDL_Window * window)
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1077 {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1078 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
1079 window->driverdata = NULL;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1080
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1081 if (data) {
2323
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1082 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
1083 Display *display = videodata->display;
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1084 int numwindows = videodata->numwindows;
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1085 SDL_WindowData **windowlist = videodata->windowlist;
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1086 int i;
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1087
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1088 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
1089 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
1090 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
1091 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
1092 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
1093 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
1094 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
1095 }
2323
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1096 }
4ac07ae446d3 Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents: 2322
diff changeset
1097 }
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1098 #ifdef X_HAVE_UTF8_STRING
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1099 if (data->ic) {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1100 XDestroyIC(data->ic);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1101 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1102 #endif
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1103 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
1104 XDestroyWindow(display, data->xwindow);
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1105 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1106 SDL_free(data);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1107 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1108 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1109
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1110 SDL_bool
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1111 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
1112 {
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
1113 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
1114 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
1115
6f8175ad0335 Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents: 4505
diff changeset
1116 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
1117 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
1118 info->subsystem = SDL_SYSWM_X11;
6f8175ad0335 Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents: 4505
diff changeset
1119 info->info.x11.display = 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
1120 info->info.x11.window = data->xwindow;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1121 return SDL_TRUE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1122 } else {
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1123 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
1124 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1125 return SDL_FALSE;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1126 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1127 }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1128
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1129 /* vi: set ts=4 sw=4 expandtab: */