Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11wm.c @ 1558:b46bb79cc197
Fixed bug #113:
Date: Sat, 16 Apr 2005 08:39:22 +1000
From: "Eric Mangold"
Subject: [SDL] Window manager does not show SDL window titles
Hello,
I have an issue with SDL-using applications and the sawfish window manager.
The problem is that SDL windows do not show the window caption. My gnome
panel *does* show the window name, but the actual sawfish window frame
shows no caption at all. All other non-SDL applications that I use work
fine.
I tried a couple other window managers, and they *were* able to show the
SDL window captions correctly. Though there many be other WMs that can't.
I believe the problem is that SDL is using the UTF8_STRING type for the
window's WM_NAME and WM_ICON properties. In fact, WM_NAME and WM_ICON are
supposed to set to a TEXT type, usually STRING (ISO 8859-1).
The property names _NET_WM_NAME and _NET_WM_ICON_NAME should be used to
store the UTF8_STRING versions of the window title and icon name.
You can see the properties I refer to with a command like this:
xprop|grep -e "WM.*NAME"
Please note the freedesktop.org standard:
http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#id2506954
This page talks a little bit about the history of these properties. Just
search down the page for "WM_NAME".
http://www.cl.cam.ac.uk/~mgk25/unicode.html
Please let me know if I can be of any assistance in resolving this issue.
Thanks,
Eric Mangold
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 20 Mar 2006 07:31:36 +0000 |
parents | 4d005dfbb7f5 |
children | 3ba88cb7eb1b |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
246
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 #include <X11/Xlib.h> | |
25 #include <X11/Xutil.h> | |
26 | |
27 #include "SDL_version.h" | |
28 #include "SDL_timer.h" | |
29 #include "SDL_video.h" | |
30 #include "SDL_syswm.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
31 #include "../SDL_pixels_c.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
32 #include "../../events/SDL_events_c.h" |
0 | 33 #include "SDL_x11modes_c.h" |
34 #include "SDL_x11wm_c.h" | |
35 | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
36 static Uint8 reverse_byte(Uint8 x) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
37 { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
38 x = (x & 0xaa) >> 1 | (x & 0x55) << 1; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
39 x = (x & 0xcc) >> 2 | (x & 0x33) << 2; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
40 x = (x & 0xf0) >> 4 | (x & 0x0f) << 4; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
41 return x; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
42 } |
0 | 43 |
44 void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) | |
45 { | |
46 SDL_Surface *sicon; | |
47 XWMHints *wmhints; | |
48 XImage *icon_image; | |
49 Pixmap icon_pixmap; | |
50 Pixmap mask_pixmap; | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
51 Window icon_window = None; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
52 GC gc; |
0 | 53 XGCValues GCvalues; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
54 int i, dbpp; |
0 | 55 SDL_Rect bounds; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
56 Uint8 *LSBmask; |
0 | 57 Visual *dvis; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
58 char *p; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
59 int masksize; |
0 | 60 |
61 SDL_Lock_EventThread(); | |
62 | |
63 /* The icon must use the default visual, depth and colormap of the | |
64 screen, so it might need a conversion */ | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
65 dvis = DefaultVisual(SDL_Display, SDL_Screen); |
0 | 66 dbpp = DefaultDepth(SDL_Display, SDL_Screen); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
67 for(i = 0; i < this->hidden->nvisuals; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
68 if(this->hidden->visuals[i].visual == dvis) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
69 dbpp = this->hidden->visuals[i].bpp; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
70 break; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
71 } |
0 | 72 } |
73 | |
74 /* The Visual struct is supposed to be opaque but we cheat a little */ | |
75 sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, | |
76 dbpp, | |
77 dvis->red_mask, dvis->green_mask, | |
78 dvis->blue_mask, 0); | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
79 if ( sicon == NULL ) |
0 | 80 goto done; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
81 |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
82 if(dbpp == 8) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
83 /* Default visual is 8bit; we need to allocate colours from |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
84 the default colormap */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
85 SDL_Color want[256], got[256]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
86 int nwant; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
87 Colormap dcmap; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
88 int missing; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
89 dcmap = DefaultColormap(SDL_Display, SDL_Screen); |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
90 if(icon->format->palette) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
91 /* The icon has a palette as well - we just have to |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
92 find those colours */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
93 nwant = icon->format->palette->ncolors; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
94 SDL_memcpy(want, icon->format->palette->colors, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
95 nwant * sizeof want[0]); |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
96 } else { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
97 /* try the standard 6x6x6 cube for lack of better |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
98 ideas */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
99 int r, g, b, i; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
100 for(r = i = 0; r < 256; r += 0x33) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
101 for(g = 0; g < 256; g += 0x33) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
102 for(b = 0; b < 256; b += 0x33, i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
103 want[i].r = r; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
104 want[i].g = g; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
105 want[i].b = b; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
106 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
107 nwant = 216; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
108 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
109 if(SDL_iconcolors) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
110 /* free already allocated colours first */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
111 unsigned long freelist[512]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
112 int nfree = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
113 for(i = 0; i < 256; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
114 while(SDL_iconcolors[i]) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
115 freelist[nfree++] = i; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
116 SDL_iconcolors[i]--; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
117 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
118 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
119 pXFreeColors(GFX_Display, dcmap, freelist, nfree, 0); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
120 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
121 if(!SDL_iconcolors) |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
122 SDL_iconcolors = SDL_malloc(256 * sizeof *SDL_iconcolors); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
123 SDL_memset(SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
124 |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
125 /* try to allocate the colours */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
126 SDL_memset(got, 0, sizeof got); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
127 missing = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
128 for(i = 0; i < nwant; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
129 XColor c; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
130 c.red = want[i].r << 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
131 c.green = want[i].g << 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
132 c.blue = want[i].b << 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
133 c.flags = DoRed | DoGreen | DoBlue; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
134 if(pXAllocColor(GFX_Display, dcmap, &c)) { |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
135 /* got the colour */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
136 SDL_iconcolors[c.pixel]++; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
137 got[c.pixel] = want[i]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
138 } else { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
139 missing = 1; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
140 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
141 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
142 if(missing) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
143 /* Some colours were apparently missing, so we just |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
144 allocate all the rest as well */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
145 XColor cols[256]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
146 for(i = 0; i < 256; i++) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
147 cols[i].pixel = i; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
148 pXQueryColors(GFX_Display, dcmap, cols, 256); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
149 for(i = 0; i < 256; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
150 got[i].r = cols[i].red >> 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
151 got[i].g = cols[i].green >> 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
152 got[i].b = cols[i].blue >> 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
153 if(!SDL_iconcolors[i]) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
154 if(pXAllocColor(GFX_Display, dcmap, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
155 cols + i)) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
156 SDL_iconcolors[i] = 1; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
157 } else { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
158 /* index not available */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
159 got[i].r = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
160 got[i].g = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
161 got[i].b = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
162 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
163 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
164 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
165 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
166 |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
167 SDL_SetColors(sicon, got, 0, 256); |
0 | 168 } |
169 | |
170 bounds.x = 0; | |
171 bounds.y = 0; | |
172 bounds.w = icon->w; | |
173 bounds.h = icon->h; | |
174 if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) | |
175 goto done; | |
176 | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
177 /* We need the mask as given, except in LSBfirst format instead of |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
178 MSBfirst. Reverse the bits in each byte. */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
179 masksize = ((sicon->w + 7) >> 3) * sicon->h; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
180 LSBmask = SDL_malloc(masksize); |
0 | 181 if ( LSBmask == NULL ) { |
182 goto done; | |
183 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
184 SDL_memset(LSBmask, 0, masksize); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
185 for(i = 0; i < masksize; i++) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
186 LSBmask[i] = reverse_byte(mask[i]); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
187 mask_pixmap = pXCreatePixmapFromBitmapData(SDL_Display, WMwindow, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
188 (char *)LSBmask, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
189 sicon->w, sicon->h, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
190 1L, 0L, 1); |
0 | 191 |
192 /* Transfer the image to an X11 pixmap */ | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
193 icon_image = pXCreateImage(SDL_Display, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
194 DefaultVisual(SDL_Display, SDL_Screen), |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
195 DefaultDepth(SDL_Display, SDL_Screen), |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
196 ZPixmap, 0, sicon->pixels, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
197 sicon->w, sicon->h, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
198 32, 0); |
246
7c09c9e3b0c7
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
236
diff
changeset
|
199 icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) |
7c09c9e3b0c7
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
236
diff
changeset
|
200 ? MSBFirst : LSBFirst; |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
201 icon_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
202 DefaultDepth(SDL_Display, SDL_Screen)); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
203 gc = pXCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
204 pXPutImage(SDL_Display, icon_pixmap, gc, icon_image, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
205 0, 0, 0, 0, sicon->w, sicon->h); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
206 pXFreeGC(SDL_Display, gc); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
207 pXDestroyImage(icon_image); |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
208 SDL_free(LSBmask); |
0 | 209 sicon->pixels = NULL; |
210 | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
211 /* Some buggy window managers (some versions of Enlightenment, it |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
212 seems) need an icon window *and* icon pixmap to work properly, while |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
213 it screws up others. The default is only to use a pixmap. */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
214 p = SDL_getenv("SDL_VIDEO_X11_ICONWIN"); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
215 if(p && *p) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
216 icon_window = pXCreateSimpleWindow(SDL_Display, SDL_Root, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
217 0, 0, sicon->w, sicon->h, 0, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
218 CopyFromParent, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
219 CopyFromParent); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
220 pXSetWindowBackgroundPixmap(SDL_Display, icon_window, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
221 icon_pixmap); |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
222 pXClearWindow(SDL_Display, icon_window); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
223 } |
0 | 224 |
225 /* Set the window icon to the icon pixmap (and icon window) */ | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
226 wmhints = pXAllocWMHints(); |
0 | 227 wmhints->flags = (IconPixmapHint | IconMaskHint); |
228 wmhints->icon_pixmap = icon_pixmap; | |
229 wmhints->icon_mask = mask_pixmap; | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
230 if(icon_window != None) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
231 wmhints->flags |= IconWindowHint; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
232 wmhints->icon_window = icon_window; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
233 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
234 pXSetWMHints(SDL_Display, WMwindow, wmhints); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
235 pXFree(wmhints); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
236 pXSync(SDL_Display, False); |
0 | 237 |
238 done: | |
239 SDL_Unlock_EventThread(); | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
240 SDL_FreeSurface(sicon); |
0 | 241 } |
242 | |
243 void X11_SetCaption(_THIS, const char *title, const char *icon) | |
244 { | |
245 XTextProperty titleprop, iconprop; | |
1558 | 246 Status status; |
247 | |
248 #ifdef X_HAVE_UTF8_STRING | |
249 Atom _NET_WM_NAME; | |
250 Atom _NET_WM_ICON_NAME; | |
251 | |
252 /* Look up some useful Atoms */ | |
253 _NET_WM_NAME = pXInternAtom(SDL_Display, "_NET_WM_NAME", False); | |
254 _NET_WM_ICON_NAME = pXInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False); | |
255 #endif | |
0 | 256 |
257 /* Lock the event thread, in multi-threading environments */ | |
258 SDL_Lock_EventThread(); | |
259 | |
260 if ( title != NULL ) { | |
1558 | 261 char *title_latin1 = SDL_iconv_utf8_latin1((char *)title); |
262 if ( !title_latin1 ) { | |
263 SDL_OutOfMemory(); | |
264 return; | |
265 } | |
266 status = pXStringListToTextProperty(&title_latin1, 1, &titleprop); | |
267 SDL_free(title_latin1); | |
268 if ( status ) { | |
269 pXSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME); | |
270 pXFree(titleprop.value); | |
271 } | |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
272 #ifdef X_HAVE_UTF8_STRING |
1558 | 273 status = pXutf8TextListToTextProperty(SDL_Display, |
274 (char **)&title, 1, XUTF8StringStyle, &titleprop); | |
275 if ( status == Success ) { | |
276 pXSetTextProperty(SDL_Display, WMwindow, &titleprop, _NET_WM_NAME); | |
277 pXFree(titleprop.value); | |
278 } | |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
279 #endif |
0 | 280 } |
281 if ( icon != NULL ) { | |
1558 | 282 char *icon_latin1 = SDL_iconv_utf8_latin1((char *)icon); |
283 if ( !icon_latin1 ) { | |
284 SDL_OutOfMemory(); | |
285 return; | |
286 } | |
287 status = pXStringListToTextProperty(&icon_latin1, 1, &iconprop); | |
288 SDL_free(icon_latin1); | |
289 if ( status ) { | |
290 pXSetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME); | |
291 pXFree(iconprop.value); | |
292 } | |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
293 #ifdef X_HAVE_UTF8_STRING |
1558 | 294 status = pXutf8TextListToTextProperty(SDL_Display, |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
295 (char **)&icon, 1, XUTF8StringStyle, &iconprop); |
1558 | 296 if ( status == Success ) { |
297 pXSetTextProperty(SDL_Display, WMwindow, &iconprop, _NET_WM_ICON_NAME); | |
298 pXFree(iconprop.value); | |
299 } | |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
300 #endif |
0 | 301 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
302 pXSync(SDL_Display, False); |
0 | 303 |
304 SDL_Unlock_EventThread(); | |
305 } | |
306 | |
307 /* Iconify the window */ | |
308 int X11_IconifyWindow(_THIS) | |
309 { | |
310 int result; | |
311 | |
312 SDL_Lock_EventThread(); | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
313 result = pXIconifyWindow(SDL_Display, WMwindow, SDL_Screen); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
314 pXSync(SDL_Display, False); |
0 | 315 SDL_Unlock_EventThread(); |
316 return(result); | |
317 } | |
318 | |
319 SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) | |
320 { | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
321 int result; |
0 | 322 |
323 if ( this->screen == NULL ) { | |
324 return(SDL_GRAB_OFF); | |
325 } | |
326 if ( ! SDL_Window ) { | |
327 return(mode); /* Will be set later on mode switch */ | |
328 } | |
329 if ( mode == SDL_GRAB_OFF ) { | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
330 pXUngrabPointer(SDL_Display, CurrentTime); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
331 pXUngrabKeyboard(SDL_Display, CurrentTime); |
0 | 332 } else { |
333 if ( this->screen->flags & SDL_FULLSCREEN ) { | |
334 /* Unbind the mouse from the fullscreen window */ | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
335 pXUngrabPointer(SDL_Display, CurrentTime); |
0 | 336 } |
337 /* Try to grab the mouse */ | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
338 #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */ |
0 | 339 for ( numtries = 0; numtries < 10; ++numtries ) { |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
340 #else |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
341 while ( 1 ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
342 #endif |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
343 result = pXGrabPointer(SDL_Display, SDL_Window, True, 0, |
0 | 344 GrabModeAsync, GrabModeAsync, |
345 SDL_Window, None, CurrentTime); | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
346 if ( result == GrabSuccess ) { |
0 | 347 break; |
348 } | |
349 SDL_Delay(100); | |
350 } | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
351 if ( result != GrabSuccess ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
352 /* Uh, oh, what do we do here? */ ; |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
353 } |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
354 /* Now grab the keyboard */ |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
355 pXGrabKeyboard(SDL_Display, WMwindow, True, |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
356 GrabModeAsync, GrabModeAsync, CurrentTime); |
0 | 357 |
358 /* Raise the window if we grab the mouse */ | |
359 if ( !(this->screen->flags & SDL_FULLSCREEN) ) | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
360 pXRaiseWindow(SDL_Display, WMwindow); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
361 |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
362 /* Make sure we register input focus */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
363 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
0 | 364 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
365 pXSync(SDL_Display, False); |
0 | 366 |
367 return(mode); | |
368 } | |
369 | |
370 SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode) | |
371 { | |
372 SDL_Lock_EventThread(); | |
373 mode = X11_GrabInputNoLock(this, mode); | |
374 SDL_Unlock_EventThread(); | |
375 | |
376 return(mode); | |
377 } | |
378 | |
379 /* If 'info' is the right version, this function fills it and returns 1. | |
380 Otherwise, in case of a version mismatch, it returns -1. | |
381 */ | |
382 static void lock_display(void) | |
383 { | |
384 SDL_Lock_EventThread(); | |
385 } | |
386 static void unlock_display(void) | |
387 { | |
388 /* Make sure any X11 transactions are completed */ | |
389 SDL_VideoDevice *this = current_video; | |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
390 pXSync(SDL_Display, False); |
0 | 391 SDL_Unlock_EventThread(); |
392 } | |
393 int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info) | |
394 { | |
395 if ( info->version.major <= SDL_MAJOR_VERSION ) { | |
396 info->subsystem = SDL_SYSWM_X11; | |
397 info->info.x11.display = SDL_Display; | |
398 info->info.x11.window = SDL_Window; | |
399 if ( SDL_VERSIONNUM(info->version.major, | |
400 info->version.minor, | |
401 info->version.patch) >= 1002 ) { | |
402 info->info.x11.fswindow = FSwindow; | |
403 info->info.x11.wmwindow = WMwindow; | |
404 } | |
405 info->info.x11.lock_func = lock_display; | |
406 info->info.x11.unlock_func = unlock_display; | |
407 return(1); | |
408 } else { | |
409 SDL_SetError("Application not compiled with SDL %d.%d\n", | |
410 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
411 return(-1); | |
412 } | |
413 } |