Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11window.c @ 4518:a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Unfortunately, this doesn't work. I also noticed that maximizing doesn't work as well. Also xprop hangs when trying to list properties of SDL windows.... ???
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 13 Jul 2010 23:11:10 -0700 |
parents | 6f8175ad0335 |
children | 0c67c4328678 |
rev | line source |
---|---|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "../SDL_sysvideo.h" |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
25 #include "../SDL_pixels_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "../../events/SDL_keyboard_c.h" |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset
|
27 #include "../../events/SDL_mouse_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "SDL_x11video.h" |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset
|
30 #include "SDL_x11mouse.h" |
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 |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
46 X11_WindowIsOldstyleFullscreen(SDL_Window * window) |
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 { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
48 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
|
49 SDL_VideoData *videodata = (SDL_VideoData *) data->videodata; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
50 |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
51 /* ICCCM2.0-compliant window managers can handle fullscreen windows */ |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
52 if ((window->flags & SDL_WINDOW_FULLSCREEN) && !videodata->net_wm) { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
53 return SDL_TRUE; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
54 } else { |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
55 return SDL_FALSE; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
56 } |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
57 } |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
58 |
2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
59 static void |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
60 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
|
61 { |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
62 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
|
63 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
|
64 (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
|
65 XWindowAttributes attr; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
66 |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
67 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
|
68 displaydata->screen), |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
69 &attr); |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
70 if (w) { |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
71 *w = attr.width; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
72 } |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
73 if (h) { |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
74 *h = attr.height; |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
75 } |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
76 } |
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
77 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 static int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 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
|
80 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_WindowData *data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 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
|
84 int windowlistlength = videodata->windowlistlength; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 SDL_WindowData **windowlist = videodata->windowlist; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 /* Allocate the window data */ |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
88 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
|
89 if (!data) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 } |
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
|
93 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
|
94 data->xwindow = w; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 data->ic = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 XNInputStyle, XIMPreeditNothing | XIMStatusNothing, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 XNResourceName, videodata->classname, XNResourceClass, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 videodata->classname, NULL); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 data->created = created; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 data->videodata = videodata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
107 /* 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
|
108 |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 } 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
|
113 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
|
114 (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
|
115 (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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 return -1; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
121 } |
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
|
122 windowlist[numwindows] = data; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
123 videodata->numwindows++; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
124 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
|
125 videodata->windowlist = windowlist; |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
126 } |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
127 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 /* 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
|
129 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 XWindowAttributes attrib; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 XGetWindowAttributes(data->videodata->display, w, &attrib); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 window->x = attrib.x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 window->y = attrib.y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 window->w = attrib.width; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 window->h = attrib.height; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 if (attrib.map_state != IsUnmapped) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 window->flags |= SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 window->flags &= ~SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
143 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
144 { |
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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 Atom actualType; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
150 int actualFormat; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
151 unsigned long i, numItems, bytesAfter; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
152 unsigned char *propertyValue = NULL; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
153 long maxLength = 1024; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
154 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
155 if (XGetWindowProperty(data->videodata->display, w, _NET_WM_STATE, |
3078 | 156 0l, maxLength, False, XA_ATOM, &actualType, |
157 &actualFormat, &numItems, &bytesAfter, | |
158 &propertyValue) == Success) { | |
159 Atom *atoms = (Atom *) propertyValue; | |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
160 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
|
161 int fullscreen = 0; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
162 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
163 for (i = 0; i < numItems; ++i) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
164 if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
165 maximized |= 1; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
166 } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
167 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
|
168 } 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
|
169 fullscreen = 1; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
170 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
171 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
172 if (maximized == 3) { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
173 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
|
174 } 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
|
175 window->flags |= SDL_WINDOW_FULLSCREEN; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
176 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
177 XFree(propertyValue); |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
178 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
179 } |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
180 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 /* FIXME: How can I tell? |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 DWORD style = GetWindowLong(hwnd, GWL_STYLE); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 if (style & WS_VISIBLE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 if (style & (WS_BORDER | WS_THICKFRAME)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 window->flags &= ~SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 window->flags |= SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 if (style & WS_THICKFRAME) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 window->flags |= SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 window->flags &= ~SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 if (style & WS_MINIMIZE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 window->flags |= SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 window->flags &= ~SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 if (GetFocus() == hwnd) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 int index = data->videodata->keyboard; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 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
|
204 SDL_SetKeyboardFocus(index, data->window); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 if (window->flags & SDL_WINDOW_INPUT_GRABBED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 RECT rect; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 GetClientRect(hwnd, &rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 ClientToScreen(hwnd, (LPPOINT) & rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 ClientToScreen(hwnd, (LPPOINT) & rect + 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 ClipCursor(&rect); |
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 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 /* All done! */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 window->driverdata = data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 return 0; |
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 X11_CreateWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 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
|
226 (SDL_DisplayData *) window->display->driverdata; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 Visual *visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 int depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 XSetWindowAttributes xattr; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 int x, y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 Window w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 XSizeHints *sizehints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 XWMHints *wmhints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 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
|
235 SDL_bool oldstyle_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
|
236 |
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
|
237 /* 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
|
238 if ((window->flags & SDL_WINDOW_FULLSCREEN) && !data->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
|
239 oldstyle_fullscreen = 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
|
240 } 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
|
241 oldstyle_fullscreen = 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
|
242 } |
1951
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 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 /* FIXME |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 if ( use_xinerama ) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 x = xinerama_info.x_org; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 y = xinerama_info.y_org; |
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 #endif |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
252 #ifdef SDL_VIDEO_OPENGL_GLX |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 if (window->flags & SDL_WINDOW_OPENGL) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
254 XVisualInfo *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
255 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
256 vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
257 if (!vinfo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
258 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
259 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
260 visual = vinfo->visual; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
261 depth = vinfo->depth; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
262 XFree(vinfo); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
263 } else |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
264 #endif |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
265 #ifdef SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
266 if (window->flags & SDL_WINDOW_OPENGL) { |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
267 XVisualInfo *vinfo; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
268 |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
269 vinfo = X11_GLES_GetVisual(_this, data->display, displaydata->screen); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
270 if (!vinfo) { |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
271 return -1; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
272 } |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
273 visual = vinfo->visual; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
274 depth = vinfo->depth; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
275 XFree(vinfo); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
276 } else |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
277 #endif |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
278 { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 visual = displaydata->visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 depth = displaydata->depth; |
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 |
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
|
283 if (oldstyle_fullscreen) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 xattr.override_redirect = True; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 xattr.override_redirect = False; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 xattr.background_pixel = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 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
|
290 |
2945
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset
|
291 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
|
292 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
|
293 |
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
|
294 /* Status status; */ |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
295 XColor *colorcells; |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
296 Colormap colormap; |
3052 | 297 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
|
298 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
|
299 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
|
300 Sint32 rmax, gmax, bmax; |
3052 | 301 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
|
302 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
|
303 Sint32 rshift, gshift, bshift; |
3052 | 304 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
|
305 |
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
|
306 /* Is the colormap we need already registered in SDL? */ |
4505 | 307 if ((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
|
308 X11_LookupColormap(data->display, |
4505 | 309 displaydata->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
|
310 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
|
311 /* 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
|
312 } 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
|
313 /* The colormap is not known to SDL so we will create it */ |
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
|
314 colormap = XCreateColormap(data->display, |
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
|
315 RootWindow(data->display, |
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
|
316 displaydata->screen), |
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
|
317 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
|
318 /* 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
|
319 |
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
|
320 /* 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
|
321 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
|
322 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
|
323 ("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
|
324 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
|
325 } |
2213 | 326 |
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
|
327 /* 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
|
328 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
329 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
|
330 if (NULL == colorcells) { |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
331 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
|
332 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
|
333 } |
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 |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
335 ncolors = visual->map_entries; |
3052 | 336 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
|
337 |
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 /* 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
|
339 |
3052 | 340 /* what if ncolors != (1 << nbits)? That can happen on a |
341 true PseudoColor display. I'm assuming that we will | |
342 always have ncolors == (1 << nbits) */ | |
343 | |
344 /* 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
|
345 |
3052 | 346 /* Compute the width of each field. If there is one extra |
347 bit, give it to green. If there are two extra bits give | |
348 them to red and greed. We can get extra bits when the | |
349 number of bits per pixel is not a multiple of 3. For | |
350 example when we have 16 bits per pixel and need a 5/6/5 | |
351 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
|
352 |
3052 | 353 rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0); |
354 gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0); | |
355 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
|
356 |
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
|
357 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
|
358 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
|
359 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
|
360 |
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
|
361 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
|
362 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
|
363 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
|
364 |
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
|
365 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
|
366 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
|
367 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
|
368 |
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
|
369 /* 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
|
370 /* 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
|
371 /* 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
|
372 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
373 /* build the color table pixel values */ |
3052 | 374 pix = 0; |
375 for (r = 0; r < rmax; r++) { | |
376 for (g = 0; g < gmax; g++) { | |
377 for (b = 0; b < bmax; b++) { | |
378 colorcells[pix].pixel = | |
379 (r << rshift) | (g << gshift) | (b << bshift); | |
380 colorcells[pix].red = (0xffff * r) / rmask; | |
381 colorcells[pix].green = (0xffff * g) / gmask; | |
382 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
|
383 /* 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
|
384 /* 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
|
385 /* 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
|
386 /* 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
|
387 /* 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
|
388 /* colorcells[pix].blue); */ |
3052 | 389 pix++; |
390 } | |
391 } | |
392 } | |
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
393 |
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
|
394 /* status = */ |
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 /* XStoreColors(data->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
|
396 |
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset
|
397 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
|
398 X11_TrackColormap(data->display, displaydata->screen, |
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 colormap, visual, NULL); |
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 |
3009
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
401 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
|
402 } |
2945
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset
|
403 } 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
|
404 Status status; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
405 XColor *colorcells; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
406 Colormap colormap; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
407 int i; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
408 int ncolors; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
409 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
|
410 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
|
411 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
|
412 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
413 /* 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
|
414 if ((colormap = |
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
|
415 X11_LookupColormap(data->display, |
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
|
416 displaydata->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
|
417 xattr.colormap = colormap; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
418 /* 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
|
419 } else { |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
420 /* The colormap is not known to SDL so we will create it */ |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
421 colormap = XCreateColormap(data->display, |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
422 RootWindow(data->display, |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
423 displaydata->screen), |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
424 visual, AllocAll); |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
425 /* 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
|
426 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
427 /* 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
|
428 if (!colormap) { |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
429 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
|
430 ("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
|
431 return -1; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
432 } |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
433 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
434 /* 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
|
435 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
|
436 if (NULL == colorcells) { |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
437 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
|
438 return -1; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
439 } |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
440 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
|
441 rmax = 0xffff; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
442 gmax = 0xffff; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
443 bmax = 0xffff; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
444 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
445 rshift = 0; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
446 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
|
447 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
|
448 rshift++; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
449 rmask >>= 1; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
450 } |
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 /* 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
|
453 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
454 gshift = 0; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
455 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
|
456 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
|
457 gshift++; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
458 gmask >>= 1; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
459 } |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
460 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
461 /* 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
|
462 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
463 bshift = 0; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
464 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
|
465 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
|
466 bshift++; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
467 bmask >>= 1; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
468 } |
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 /* 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
|
471 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
472 /* 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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
478 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
|
479 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
|
480 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
|
481 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
482 Uint32 pix = |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
483 (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
|
484 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
485 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
|
486 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
487 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
|
488 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
|
489 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
|
490 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
491 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
|
492 /* 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
|
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 status = |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
496 XStoreColors(data->display, colormap, colorcells, ncolors); |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
497 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
498 xattr.colormap = colormap; |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
499 X11_TrackColormap(data->display, displaydata->screen, |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
500 colormap, visual, colorcells); |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
501 |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
502 SDL_free(colorcells); |
546c022a9ae5
Changed and hopefully fixed support for DirectColor with support for gammaramps.
Bob Pendleton <bob@pendleton.com>
parents:
2990
diff
changeset
|
503 } |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 xattr.colormap = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 XCreateColormap(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 RootWindow(data->display, displaydata->screen), |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 visual, AllocNone); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 |
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
|
511 if (oldstyle_fullscreen |
2876 | 512 || 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
|
513 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
|
514 x = (x - window->w) / 2; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 x = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 x = window->x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 } |
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
|
520 if (oldstyle_fullscreen |
2876 | 521 || 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
|
522 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
|
523 y = (y - window->h) / 2; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 y = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 y = window->y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 w = XCreateWindow(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 RootWindow(data->display, displaydata->screen), x, y, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 window->w, window->h, 0, depth, InputOutput, visual, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 (CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 CWColormap), &xattr); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
535 if (!w) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
536 SDL_SetError("Couldn't create window"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
537 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
538 } |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
539 #if SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
540 /* Create the GLES window surface */ |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
541 _this->gles_data->egl_surface = |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
542 _this->gles_data->eglCreateWindowSurface(_this->gles_data-> |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
543 egl_display, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
544 _this->gles_data->egl_config, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
545 (NativeWindowType) w, NULL); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
546 |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
547 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
|
548 SDL_SetError("Could not create GLES window surface"); |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
549 return -1; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
550 } |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3078
diff
changeset
|
551 #endif |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 sizehints = XAllocSizeHints(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 if (sizehints) { |
3225
5859d0a0c519
Removed arbitrary window size limitation
Sam Lantinga <slouken@libsdl.org>
parents:
3161
diff
changeset
|
555 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
|
556 || oldstyle_fullscreen) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 sizehints->min_width = sizehints->max_width = window->w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 sizehints->min_height = sizehints->max_height = window->h; |
3225
5859d0a0c519
Removed arbitrary window size limitation
Sam Lantinga <slouken@libsdl.org>
parents:
3161
diff
changeset
|
559 sizehints->flags = PMaxSize | PMinSize; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 } |
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
|
561 if (!oldstyle_fullscreen |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 && window->x != SDL_WINDOWPOS_UNDEFINED |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 && window->y != SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 sizehints->x = x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 sizehints->y = y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
566 sizehints->flags |= USPosition; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
567 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 XSetWMNormalHints(data->display, w, sizehints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 XFree(sizehints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 |
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
|
572 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
|
573 SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 /* 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
|
577 set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 /* First try to set MWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 /* Hints used by Motif compliant window managers */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 struct |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 unsigned long flags; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 unsigned long functions; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 unsigned long decorations; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 long input_mode; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 unsigned long status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 } MWMHints = { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 (1L << 1), 0, 0, 0, 0}; |
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 XChangeProperty(data->display, w, WM_HINTS, WM_HINTS, 32, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 PropModeReplace, (unsigned char *) &MWMHints, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 sizeof(MWMHints) / sizeof(long)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 set = SDL_TRUE; |
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 /* Now try to set KWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 long KWMHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 XChangeProperty(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 WM_HINTS, WM_HINTS, 32, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 (unsigned char *) &KWMHints, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 sizeof(KWMHints) / sizeof(long)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 /* Now try to set GNOME hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 long GNOMEHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 XChangeProperty(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 WM_HINTS, WM_HINTS, 32, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 (unsigned char *) &GNOMEHints, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 sizeof(GNOMEHints) / sizeof(long)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 /* Finally set the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 if (!set) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 XSetTransientForHint(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 RootWindow(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 displaydata->screen)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 /* 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
|
633 set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 /* First try to unset MWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 XDeleteProperty(data->display, w, WM_HINTS); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 /* Now try to unset KWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 XDeleteProperty(data->display, w, WM_HINTS); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 /* Now try to unset GNOME hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 XDeleteProperty(data->display, w, WM_HINTS); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 set = SDL_TRUE; |
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 /* Finally unset the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 if (!set) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 /* NOTE: Does this work? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 XSetTransientForHint(data->display, w, None); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
657 } |
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
660 /* 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
|
661 wmhints = XAllocWMHints(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 if (wmhints) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 wmhints->input = True; |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
664 wmhints->flags = InputHint; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 XSetWMHints(data->display, w, wmhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 XFree(wmhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 /* 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
|
670 classhints = XAllocClassHint(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 if (classhints != NULL) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 classhints->res_name = data->classname; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 classhints->res_class = data->classname; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 XSetClassHint(data->display, w, classhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 XFree(classhints); |
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 |
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
|
678 /* FIXME: Why doesn't this work? */ |
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
|
679 if (window->flags & SDL_WINDOW_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
|
680 Atom _NET_WM_STATE = data->_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
|
681 Atom _NET_WM_STATE_FULLSCREEN = data->_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
|
682 XEvent e; |
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
|
683 |
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
|
684 e.xany.type = ClientMessage; |
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
|
685 e.xclient.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
|
686 e.xclient.window = w; |
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
|
687 e.xclient.message_type = _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
|
688 e.xclient.format = 32; |
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
|
689 e.xclient.data.l[0] = _NET_WM_STATE_ADD; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4510
diff
changeset
|
690 e.xclient.data.l[1] = _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
|
691 e.xclient.data.l[2] = 0l; |
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
|
692 |
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
|
693 XSendEvent(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
|
694 RootWindow(data->display, displaydata->screen), 0, |
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
|
695 SubstructureNotifyMask | SubstructureRedirectMask, &e); |
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
|
696 } |
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
|
697 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 /* Allow the window to be deleted by the window manager */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
699 XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
700 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
702 XDestroyWindow(data->display, w); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 } |
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
|
705 #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
|
706 { |
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
|
707 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
|
708 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
|
709 XNFilterEvents, &fevent, NULL); |
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
|
710 XSelectInput(data->display, w, |
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
|
711 (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
|
712 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
|
713 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
|
714 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
|
715 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
|
716 } |
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
|
717 #else |
2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset
|
718 { |
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset
|
719 XSelectInput(data->display, w, |
2725 | 720 (FocusChangeMask | EnterWindowMask | LeaveWindowMask | |
721 ExposureMask | ButtonPressMask | ButtonReleaseMask | | |
722 PointerMotionMask | KeyPressMask | KeyReleaseMask | | |
723 PropertyChangeMask | StructureNotifyMask | | |
724 KeymapStateMask)); | |
2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset
|
725 } |
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
|
726 #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
|
727 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
729 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
730 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 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
|
732 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
|
733 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 Window w = (Window) data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
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
|
736 window->title = X11_GetWindowTitle(_this, w); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 |
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
|
744 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
|
745 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
|
746 { |
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
|
747 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
|
748 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 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
|
754 |
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
|
755 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
|
756 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
|
757 &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
|
758 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
|
759 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
|
760 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
|
761 } 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
|
762 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
|
763 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
|
764 &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
|
765 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
|
766 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
|
767 } 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
|
768 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
|
769 } |
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 } |
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 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
|
772 } |
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 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
774 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
775 X11_SetWindowTitle(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
776 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
777 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
778 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
779 XTextProperty titleprop, iconprop; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
780 Status status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 const char *title = window->title; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 const char *icon = NULL; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
783 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
784 #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
|
785 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
|
786 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
|
787 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
788 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
789 if (title != NULL) { |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
790 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
|
791 if (!title_locale) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 } |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
795 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
|
796 SDL_free(title_locale); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
797 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
|
798 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
|
799 XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
800 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
801 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
802 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
803 status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
804 Xutf8TextListToTextProperty(display, (char **) &title, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 XUTF8StringStyle, &titleprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
806 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
|
807 XSetTextProperty(display, data->xwindow, &titleprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
808 _NET_WM_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
809 XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
810 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
811 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
812 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
813 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
814 if (icon != NULL) { |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
815 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
|
816 if (!icon_locale) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
817 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
818 return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
819 } |
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
820 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
|
821 SDL_free(icon_locale); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
822 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
|
823 XSetTextProperty(display, data->xwindow, &iconprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 XA_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
827 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
828 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
830 Xutf8TextListToTextProperty(display, (char **) &icon, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 XUTF8StringStyle, &iconprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
832 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
|
833 XSetTextProperty(display, data->xwindow, &iconprop, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
834 _NET_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
836 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
837 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
838 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
839 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
840 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
841 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
842 void |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
843 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
|
844 { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
845 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
|
846 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
|
847 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
|
848 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
849 if (icon) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
850 SDL_PixelFormat format; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
851 SDL_Surface *surface; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
852 int propsize; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
853 Uint32 *propdata; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
854 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
855 /* Convert the icon to ARGB for modern window managers */ |
2990 | 856 SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, |
857 0xFF000000); | |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
858 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
|
859 if (!surface) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
860 return; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
861 } |
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 /* Set the _NET_WM_ICON property */ |
2990 | 864 propsize = 2 + (icon->w * icon->h); |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
865 propdata = SDL_malloc(propsize * sizeof(Uint32)); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
866 if (propdata) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
867 propdata[0] = icon->w; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
868 propdata[1] = icon->h; |
2990 | 869 SDL_memcpy(&propdata[2], surface->pixels, |
870 surface->h * surface->pitch); | |
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
|
871 XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, |
2990 | 872 32, PropModeReplace, (unsigned char *) propdata, |
873 propsize); | |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
874 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
875 SDL_FreeSurface(surface); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
876 } 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
|
877 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
|
878 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
879 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
880 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset
|
881 void |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 X11_SetWindowPosition(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 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
|
886 SDL_bool oldstyle_fullscreen; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
887 int x, y; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 |
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
|
889 /* 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
|
890 oldstyle_fullscreen = X11_WindowIsOldstyleFullscreen(window); |
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
|
891 |
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
|
892 if (oldstyle_fullscreen |
2876 | 893 || 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
|
894 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
|
895 x = (x - window->w) / 2; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
896 } else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
897 x = window->x; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
898 } |
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
|
899 if (oldstyle_fullscreen |
2876 | 900 || 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
|
901 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
|
902 y = (y - window->h) / 2; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
903 } else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
904 y = window->y; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
905 } |
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
|
906 XMoveWindow(display, data->xwindow, x, y); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 X11_SetWindowSize(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 |
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
|
915 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
|
916 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
917 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
919 X11_ShowWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
920 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
922 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
923 |
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
|
924 XMapRaised(display, data->xwindow); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
925 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
926 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
927 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
928 X11_HideWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
929 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
930 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
931 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
932 |
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
|
933 XUnmapWindow(display, data->xwindow); |
1951
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 X11_RaiseWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
941 |
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
|
942 XRaiseWindow(display, data->xwindow); |
1951
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 |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
945 static void |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
946 X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
947 { |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
948 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
949 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
|
950 (SDL_DisplayData *) window->display->driverdata; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
951 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
|
952 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
|
953 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
|
954 Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
955 XEvent e; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
956 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
957 e.xany.type = ClientMessage; |
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
|
958 e.xclient.display = 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
|
959 e.xclient.window = data->xwindow; |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
960 e.xclient.message_type = _NET_WM_STATE; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
961 e.xclient.format = 32; |
3078 | 962 e.xclient.data.l[0] = |
963 maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; | |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
964 e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
965 e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
966 e.xclient.data.l[3] = 0l; |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
967 |
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
968 XSendEvent(display, RootWindow(display, displaydata->screen), 0, |
3078 | 969 SubstructureNotifyMask | SubstructureRedirectMask, &e); |
3077
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 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
972 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
973 X11_MaximizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
974 { |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
975 X11_SetWindowMaximized(_this, window, SDL_TRUE); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
976 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
977 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
978 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
979 X11_MinimizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
980 { |
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
|
981 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
|
982 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
|
983 (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
|
984 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
|
985 |
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
|
986 XIconifyWindow(display, data->xwindow, displaydata->screen); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
987 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
988 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
989 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
990 X11_RestoreWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
991 { |
3077
9b58f26ede81
Implemented X11 maximized state control
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
992 X11_SetWindowMaximized(_this, window, SDL_FALSE); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
993 X11_ShowWindow(_this, window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
994 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
995 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
996 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
997 X11_SetWindowGrab(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
998 { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
999 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1000 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
|
1001 SDL_bool oldstyle_fullscreen; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1002 |
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
|
1003 /* 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
|
1004 oldstyle_fullscreen = X11_WindowIsOldstyleFullscreen(window); |
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
|
1005 |
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
|
1006 if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen) |
2876 | 1007 && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1008 /* Try to grab the mouse */ |
2876 | 1009 for (;;) { |
1010 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
|
1011 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
|
1012 GrabModeAsync, data->xwindow, None, CurrentTime); |
2876 | 1013 if (result == GrabSuccess) { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1014 break; |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1015 } |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1016 SDL_Delay(100); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1017 } |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1018 |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1019 /* 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
|
1020 XRaiseWindow(display, data->xwindow); |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1021 |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1022 /* 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
|
1023 XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, |
2876 | 1024 GrabModeAsync, CurrentTime); |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1025 } else { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1026 XUngrabPointer(display, CurrentTime); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1027 XUngrabKeyboard(display, CurrentTime); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1028 } |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1029 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1030 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1031 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1032 X11_DestroyWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1033 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1034 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
|
1035 window->driverdata = NULL; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1036 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1037 if (data) { |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1038 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
|
1039 Display *display = videodata->display; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1040 int numwindows = videodata->numwindows; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1041 SDL_WindowData **windowlist = videodata->windowlist; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1042 int i; |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1043 |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1044 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
|
1045 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
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 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
|
1051 } |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1052 } |
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
1053 } |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1054 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1055 if (data->ic) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1056 XDestroyIC(data->ic); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1057 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1058 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1059 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
|
1060 XDestroyWindow(display, data->xwindow); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1061 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1062 SDL_free(data); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1063 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1064 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1065 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1066 SDL_bool |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1067 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
|
1068 { |
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
|
1069 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
|
1070 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
|
1071 |
6f8175ad0335
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
Sam Lantinga <slouken@libsdl.org>
parents:
4505
diff
changeset
|
1072 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
|
1073 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
|
1074 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
|
1075 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
|
1076 info->info.x11.window = data->xwindow; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1077 return SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1078 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1079 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
|
1080 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1081 return SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1082 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1083 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1084 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1085 /* vi: set ts=4 sw=4 expandtab: */ |