Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11window.c @ 1952:420716272158
Implemented X11 OpenGL support.
Added support for the SDL_VIDEO_OPENGL environment variable.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 28 Jul 2006 08:43:17 +0000 |
parents | 7177581dc9fa |
children | ba0d62354872 |
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
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_syswm.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "../SDL_sysvideo.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "../../events/SDL_keyboard_c.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_x11video.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 static int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 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
|
33 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 SDL_WindowData *data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 int numwindows = videodata->numwindows; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 SDL_WindowData **windowlist = videodata->windowlist; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 /* Allocate the window data */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 if (!data) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 data->windowID = window->id; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 data->window = w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 data->ic = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 XNInputStyle, XIMPreeditNothing | XIMStatusNothing, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 XNResourceName, videodata->classname, XNResourceClass, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 videodata->classname, NULL); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 data->created = created; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 data->videodata = videodata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 /* Associate the data with the window */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 windowlist = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 (SDL_WindowData **) SDL_realloc(windowlist, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 (numwindows + |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 1) * sizeof(*windowlist)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 if (!windowlist) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 SDL_free(data); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 windowlist[numwindows++] = data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 videodata->numwindows = numwindows; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 videodata->windowlist = windowlist; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 /* 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
|
74 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 XWindowAttributes attrib; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 XGetWindowAttributes(data->videodata->display, w, &attrib); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 window->x = attrib.x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 window->y = attrib.y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 window->w = attrib.width; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 window->h = attrib.height; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 if (attrib.map_state != IsUnmapped) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 window->flags |= SDL_WINDOW_SHOWN; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 window->flags &= ~SDL_WINDOW_SHOWN; |
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 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 /* FIXME: How can I tell? |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 DWORD style = GetWindowLong(hwnd, GWL_STYLE); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 if (style & WS_VISIBLE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 if (style & (WS_BORDER | WS_THICKFRAME)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 window->flags &= ~SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 window->flags |= SDL_WINDOW_BORDERLESS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 if (style & WS_THICKFRAME) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 window->flags |= SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 window->flags &= ~SDL_WINDOW_RESIZABLE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 if (style & WS_MAXIMIZE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 window->flags |= SDL_WINDOW_MAXIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 window->flags &= ~SDL_WINDOW_MAXIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 if (style & WS_MINIMIZE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 window->flags |= SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 window->flags &= ~SDL_WINDOW_MINIMIZED; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 if (GetFocus() == hwnd) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 int index = data->videodata->keyboard; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 window->flags |= SDL_WINDOW_INPUT_FOCUS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 SDL_SetKeyboardFocus(index, data->windowID); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 if (window->flags & SDL_WINDOW_INPUT_GRABBED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 RECT rect; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 GetClientRect(hwnd, &rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 ClientToScreen(hwnd, (LPPOINT) & rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 ClientToScreen(hwnd, (LPPOINT) & rect + 1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 ClipCursor(&rect); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 /* All done! */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 window->driverdata = data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 return 0; |
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 X11_CreateWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 SDL_DisplayData *displaydata = |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
138 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 Visual *visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 int depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 XSetWindowAttributes xattr; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 int x, y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 Window w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 XSizeHints *sizehints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 XWMHints *wmhints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 XClassHint *classhints; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 /* FIXME |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 if ( use_xinerama ) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 x = xinerama_info.x_org; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 y = xinerama_info.y_org; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 #endif |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
156 #ifdef SDL_VIDEO_OPENGL_GLX |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 if (window->flags & SDL_WINDOW_OPENGL) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
158 XVisualInfo *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
159 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
160 if (X11_GL_Initialize(_this) < 0) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
161 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
162 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
163 vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
164 if (!vinfo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
165 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
166 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
167 visual = vinfo->visual; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
168 depth = vinfo->depth; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
169 XFree(vinfo); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
170 } else |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
171 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
172 { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 visual = displaydata->visual; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 depth = displaydata->depth; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 xattr.override_redirect = True; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 xattr.override_redirect = False; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 xattr.background_pixel = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 xattr.border_pixel = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 if (visual->class == PseudoColor || visual->class == DirectColor) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 xattr.colormap = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 XCreateColormap(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 RootWindow(data->display, displaydata->screen), |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 visual, AllocAll); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 xattr.colormap = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 XCreateColormap(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 RootWindow(data->display, displaydata->screen), |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 visual, AllocNone); |
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 if ((window->flags & SDL_WINDOW_FULLSCREEN) || |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 window->x == SDL_WINDOWPOS_CENTERED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 x = (DisplayWidth(data->display, displaydata->screen) - |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 window->w) / 2; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 x = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 x = window->x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 if ((window->flags & SDL_WINDOW_FULLSCREEN) || |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 window->y == SDL_WINDOWPOS_CENTERED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 y = (DisplayHeight(data->display, displaydata->screen) - |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 window->h) / 2; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 y = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 y = window->y; |
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 w = XCreateWindow(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 RootWindow(data->display, displaydata->screen), x, y, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 window->w, window->h, 0, depth, InputOutput, visual, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 (CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 CWColormap), &xattr); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
220 if (!w) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
221 #ifdef SDL_VIDEO_OPENGL_GLX |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
222 if (window->flags & SDL_WINDOW_OPENGL) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
223 X11_GL_Shutdown(_this); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
224 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
225 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
226 SDL_SetError("Couldn't create window"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
227 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
228 } |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 sizehints = XAllocSizeHints(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if (sizehints) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 if (window->flags & SDL_WINDOW_RESIZABLE) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 sizehints->min_width = 32; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 sizehints->min_height = 32; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 sizehints->max_height = 4096; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 sizehints->max_width = 4096; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 sizehints->min_width = sizehints->max_width = window->w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 sizehints->min_height = sizehints->max_height = window->h; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 sizehints->flags = PMaxSize | PMinSize; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 if (!(window->flags & SDL_WINDOW_FULLSCREEN) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 && window->x != SDL_WINDOWPOS_UNDEFINED |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 && window->y != SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 sizehints->x = x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 sizehints->y = y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 sizehints->flags |= USPosition; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 XSetWMNormalHints(data->display, w, sizehints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 XFree(sizehints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 if (window->flags & SDL_WINDOW_BORDERLESS) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 /* 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
|
258 set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 /* First try to set MWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 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
|
262 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 /* Hints used by Motif compliant window managers */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 struct |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 unsigned long flags; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 unsigned long functions; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 unsigned long decorations; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 long input_mode; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 unsigned long status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 } MWMHints = { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 (1L << 1), 0, 0, 0, 0}; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 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
|
275 PropModeReplace, (unsigned char *) &MWMHints, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 sizeof(MWMHints) / sizeof(long)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 /* Now try to set KWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 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
|
281 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 long KWMHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 XChangeProperty(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 WM_HINTS, WM_HINTS, 32, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 (unsigned char *) &KWMHints, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 sizeof(KWMHints) / sizeof(long)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 /* Now try to set GNOME hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 long GNOMEHints = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 XChangeProperty(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 WM_HINTS, WM_HINTS, 32, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 PropModeReplace, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 (unsigned char *) &GNOMEHints, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 sizeof(GNOMEHints) / sizeof(long)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 /* Finally set the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 if (!set) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 XSetTransientForHint(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 RootWindow(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 displaydata->screen)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 SDL_bool set; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 Atom WM_HINTS; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 /* 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
|
314 set = SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 /* First try to unset MWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 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
|
318 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 XDeleteProperty(data->display, w, WM_HINTS); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 /* Now try to unset KWM hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 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
|
324 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 XDeleteProperty(data->display, w, WM_HINTS); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 /* Now try to unset GNOME hints */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 if (WM_HINTS != None) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 XDeleteProperty(data->display, w, WM_HINTS); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 set = SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 /* Finally unset the transient hints if necessary */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 if (!set) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 /* NOTE: Does this work? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 XSetTransientForHint(data->display, w, None); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 /* Tell KDE to keep fullscreen windows on top */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 XEvent ev; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 long mask; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 SDL_zero(ev); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 ev.xclient.type = ClientMessage; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 ev.xclient.window = RootWindow(data->display, displaydata->screen); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 ev.xclient.message_type = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 XInternAtom(data->display, "KWM_KEEP_ON_TOP", False); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 ev.xclient.format = 32; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 ev.xclient.data.l[0] = w; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 ev.xclient.data.l[1] = CurrentTime; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 XSendEvent(data->display, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 RootWindow(data->display, displaydata->screen), False, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 SubstructureRedirectMask, &ev); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 /* 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
|
360 wmhints = XAllocWMHints(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 if (wmhints) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 wmhints->input = True; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 if (window->flags & SDL_WINDOW_MINIMIZED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 wmhints->initial_state = IconicState; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 } else if (window->flags & SDL_WINDOW_SHOWN) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 wmhints->initial_state = NormalState; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 wmhints->initial_state = WithdrawnState; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 wmhints->flags = InputHint | StateHint; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 XSetWMHints(data->display, w, wmhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 XFree(wmhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 XSelectInput(data->display, w, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 (FocusChangeMask | EnterWindowMask | LeaveWindowMask | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 ExposureMask | ButtonPressMask | ButtonReleaseMask | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 PointerMotionMask | KeyPressMask | KeyReleaseMask | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 PropertyChangeMask | StructureNotifyMask | |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 KeymapStateMask)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 /* 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
|
383 classhints = XAllocClassHint(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 if (classhints != NULL) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 classhints->res_name = data->classname; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 classhints->res_class = data->classname; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 XSetClassHint(data->display, w, classhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 XFree(classhints); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 /* 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
|
392 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
|
393 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 /* Finally, show the window */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 if (window->flags & SDL_WINDOW_SHOWN) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
396 XEvent event; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
397 |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 XMapRaised(data->display, w); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
399 do { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
400 XCheckWindowEvent(data->display, w, StructureNotifyMask, &event); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
401 } while (event.type != MapNotify); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
405 #ifdef SDL_VIDEO_OPENGL_GLX |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
406 if (window->flags & SDL_WINDOW_OPENGL) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
407 X11_GL_Shutdown(_this); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
408 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
409 #endif |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 XDestroyWindow(data->display, w); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 X11_SetWindowTitle(_this, window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 int |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 Window w = (Window) data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 /* FIXME: Query the title from the existing window */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 return -1; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 return 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 X11_SetWindowTitle(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 XTextProperty titleprop, iconprop; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 Status status; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 const char *title = window->title; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 const char *icon = NULL; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 Atom _NET_WM_NAME = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 Atom _NET_WM_ICON_NAME = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 /* Look up some useful Atoms */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 _NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", False); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 _NET_WM_ICON_NAME = XInternAtom(display, "_NET_WM_ICON_NAME", False); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 if (title != NULL) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 char *title_latin1 = SDL_iconv_utf8_latin1((char *) title); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 if (!title_latin1) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 status = XStringListToTextProperty(&title_latin1, 1, &titleprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 SDL_free(title_latin1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 if (status) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 XSetTextProperty(display, data->window, &titleprop, XA_WM_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 Xutf8TextListToTextProperty(display, (char **) &title, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 XUTF8StringStyle, &titleprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 if (status == Success) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 XSetTextProperty(display, data->window, &titleprop, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 _NET_WM_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 XFree(titleprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 if (icon != NULL) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 char *icon_latin1 = SDL_iconv_utf8_latin1((char *) icon); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 if (!icon_latin1) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 SDL_OutOfMemory(); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 status = XStringListToTextProperty(&icon_latin1, 1, &iconprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 SDL_free(icon_latin1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 if (status) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 XSetTextProperty(display, data->window, &iconprop, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 XA_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 if (SDL_X11_HAVE_UTF8) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 status = |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 Xutf8TextListToTextProperty(display, (char **) &icon, 1, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 XUTF8StringStyle, &iconprop); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 if (status == Success) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 XSetTextProperty(display, data->window, &iconprop, |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 _NET_WM_ICON_NAME); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 XFree(iconprop.value); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 X11_SetWindowPosition(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 SDL_DisplayData *displaydata = |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
511 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 int x, y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 if ((window->flags & SDL_WINDOW_FULLSCREEN) || |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 window->x == SDL_WINDOWPOS_CENTERED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 x = (DisplayWidth(display, displaydata->screen) - window->w) / 2; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 x = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 x = window->x; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 if ((window->flags & SDL_WINDOW_FULLSCREEN) || |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 window->y == SDL_WINDOWPOS_CENTERED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 y = (DisplayHeight(display, displaydata->screen) - window->h) / 2; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 y = 0; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 y = window->y; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 XMoveWindow(display, data->window, x, y); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 X11_SetWindowSize(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 XMoveWindow(display, data->window, window->w, window->h); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 X11_ShowWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 XMapRaised(display, data->window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 X11_HideWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 XUnmapWindow(display, data->window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 X11_RaiseWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 Display *display = data->videodata->display; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
566 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
567 XRaiseWindow(display, data->window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 X11_MaximizeWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 /* FIXME: is this even possible? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 X11_MinimizeWindow(_THIS, SDL_Window * window) |
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 X11_HideWindow(_this, window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 X11_RestoreWindow(_THIS, SDL_Window * window) |
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 X11_ShowWindow(_this, window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 X11_SetWindowGrab(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 /* FIXME */ |
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 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 X11_DestroyWindow(_THIS, SDL_Window * window) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 if (data) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 Display *display = data->videodata->display; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
601 #ifdef SDL_VIDEO_OPENGL_GLX |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
602 if (window->flags & SDL_WINDOW_OPENGL) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
603 X11_GL_Shutdown(_this); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
604 } |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 #ifdef X_HAVE_UTF8_STRING |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 if (data->ic) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 XDestroyIC(data->ic); |
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 #endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 if (data->created) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 XDestroyWindow(display, data->window); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 SDL_free(data); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 SDL_bool |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 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
|
620 { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 if (info->version.major <= SDL_MAJOR_VERSION) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 /* FIXME! */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 return SDL_TRUE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 } else { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 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
|
626 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 return SDL_FALSE; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 } |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 /* vi: set ts=4 sw=4 expandtab: */ |