Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11wm.c @ 1351:82c38796c7ca
Changed X11 header order so it works on Solaris.
Fixes Bugzilla #138.
--ryan.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 08 Feb 2006 20:29:12 +0000 |
parents | 604d73db6802 |
children | c71e05b4dc2e |
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 */ |
22 | |
23 #include <X11/Xlib.h> | |
24 #include <X11/Xutil.h> | |
25 | |
26 #include "SDL_version.h" | |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
27 #include "SDL_stdlib.h" |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
28 #include "SDL_string.h" |
0 | 29 #include "SDL_error.h" |
30 #include "SDL_timer.h" | |
31 #include "SDL_video.h" | |
32 #include "SDL_syswm.h" | |
33 #include "SDL_events_c.h" | |
34 #include "SDL_pixels_c.h" | |
35 #include "SDL_x11modes_c.h" | |
36 #include "SDL_x11wm_c.h" | |
37 | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
38 static Uint8 reverse_byte(Uint8 x) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
39 { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
40 x = (x & 0xaa) >> 1 | (x & 0x55) << 1; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
41 x = (x & 0xcc) >> 2 | (x & 0x33) << 2; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
42 x = (x & 0xf0) >> 4 | (x & 0x0f) << 4; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
43 return x; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
44 } |
0 | 45 |
46 void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) | |
47 { | |
48 SDL_Surface *sicon; | |
49 XWMHints *wmhints; | |
50 XImage *icon_image; | |
51 Pixmap icon_pixmap; | |
52 Pixmap mask_pixmap; | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
53 Window icon_window = None; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
54 GC gc; |
0 | 55 XGCValues GCvalues; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
56 int i, dbpp; |
0 | 57 SDL_Rect bounds; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
58 Uint8 *LSBmask; |
0 | 59 Visual *dvis; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
60 char *p; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
61 int masksize; |
0 | 62 |
63 SDL_Lock_EventThread(); | |
64 | |
65 /* The icon must use the default visual, depth and colormap of the | |
66 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
|
67 dvis = DefaultVisual(SDL_Display, SDL_Screen); |
0 | 68 dbpp = DefaultDepth(SDL_Display, SDL_Screen); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
69 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
|
70 if(this->hidden->visuals[i].visual == dvis) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
71 dbpp = this->hidden->visuals[i].bpp; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
72 break; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
73 } |
0 | 74 } |
75 | |
76 /* The Visual struct is supposed to be opaque but we cheat a little */ | |
77 sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, | |
78 dbpp, | |
79 dvis->red_mask, dvis->green_mask, | |
80 dvis->blue_mask, 0); | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
81 if ( sicon == NULL ) |
0 | 82 goto done; |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
83 |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
84 if(dbpp == 8) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
85 /* 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
|
86 the default colormap */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
87 SDL_Color want[256], got[256]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
88 int nwant; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
89 Colormap dcmap; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
90 int missing; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
91 dcmap = DefaultColormap(SDL_Display, SDL_Screen); |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
92 if(icon->format->palette) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
93 /* 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
|
94 find those colours */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
95 nwant = icon->format->palette->ncolors; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
96 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
|
97 nwant * sizeof want[0]); |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
98 } else { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
99 /* 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
|
100 ideas */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
101 int r, g, b, i; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
102 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
|
103 for(g = 0; g < 256; g += 0x33) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
104 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
|
105 want[i].r = r; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
106 want[i].g = g; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
107 want[i].b = b; |
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 nwant = 216; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
110 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
111 if(SDL_iconcolors) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
112 /* free already allocated colours first */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
113 unsigned long freelist[512]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
114 int nfree = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
115 for(i = 0; i < 256; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
116 while(SDL_iconcolors[i]) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
117 freelist[nfree++] = i; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
118 SDL_iconcolors[i]--; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
119 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
120 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
121 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
|
122 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
123 if(!SDL_iconcolors) |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
124 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
|
125 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
|
126 |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
127 /* try to allocate the colours */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
128 SDL_memset(got, 0, sizeof got); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
129 missing = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
130 for(i = 0; i < nwant; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
131 XColor c; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
132 c.red = want[i].r << 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
133 c.green = want[i].g << 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
134 c.blue = want[i].b << 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
135 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
|
136 if(pXAllocColor(GFX_Display, dcmap, &c)) { |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
137 /* got the colour */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
138 SDL_iconcolors[c.pixel]++; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
139 got[c.pixel] = want[i]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
140 } else { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
141 missing = 1; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
142 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
143 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
144 if(missing) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
145 /* 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
|
146 allocate all the rest as well */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
147 XColor cols[256]; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
148 for(i = 0; i < 256; i++) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
149 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
|
150 pXQueryColors(GFX_Display, dcmap, cols, 256); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
151 for(i = 0; i < 256; i++) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
152 got[i].r = cols[i].red >> 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
153 got[i].g = cols[i].green >> 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
154 got[i].b = cols[i].blue >> 8; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
155 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
|
156 if(pXAllocColor(GFX_Display, dcmap, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
157 cols + i)) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
158 SDL_iconcolors[i] = 1; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
159 } else { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
160 /* index not available */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
161 got[i].r = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
162 got[i].g = 0; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
163 got[i].b = 0; |
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 } |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
168 |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
169 SDL_SetColors(sicon, got, 0, 256); |
0 | 170 } |
171 | |
172 bounds.x = 0; | |
173 bounds.y = 0; | |
174 bounds.w = icon->w; | |
175 bounds.h = icon->h; | |
176 if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) | |
177 goto done; | |
178 | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
179 /* 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
|
180 MSBfirst. Reverse the bits in each byte. */ |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
181 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
|
182 LSBmask = SDL_malloc(masksize); |
0 | 183 if ( LSBmask == NULL ) { |
184 goto done; | |
185 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
186 SDL_memset(LSBmask, 0, masksize); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
187 for(i = 0; i < masksize; i++) |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
188 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
|
189 mask_pixmap = pXCreatePixmapFromBitmapData(SDL_Display, WMwindow, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
190 (char *)LSBmask, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
191 sicon->w, sicon->h, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
192 1L, 0L, 1); |
0 | 193 |
194 /* 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
|
195 icon_image = pXCreateImage(SDL_Display, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
196 DefaultVisual(SDL_Display, SDL_Screen), |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
197 DefaultDepth(SDL_Display, SDL_Screen), |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
198 ZPixmap, 0, sicon->pixels, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
199 sicon->w, sicon->h, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
200 32, 0); |
246
7c09c9e3b0c7
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
236
diff
changeset
|
201 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
|
202 ? 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 pXDestroyImage(icon_image); |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
210 SDL_free(LSBmask); |
0 | 211 sicon->pixels = NULL; |
212 | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
213 /* 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 0, 0, sicon->w, sicon->h, 0, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
220 CopyFromParent, |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
221 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
|
222 pXSetWindowBackgroundPixmap(SDL_Display, icon_window, |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
223 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
|
224 pXClearWindow(SDL_Display, icon_window); |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
225 } |
0 | 226 |
227 /* 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
|
228 wmhints = pXAllocWMHints(); |
0 | 229 wmhints->flags = (IconPixmapHint | IconMaskHint); |
230 wmhints->icon_pixmap = icon_pixmap; | |
231 wmhints->icon_mask = mask_pixmap; | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
232 if(icon_window != None) { |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
233 wmhints->flags |= IconWindowHint; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
234 wmhints->icon_window = icon_window; |
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
235 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
236 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
|
237 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
|
238 pXSync(SDL_Display, False); |
0 | 239 |
240 done: | |
241 SDL_Unlock_EventThread(); | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
242 SDL_FreeSurface(sicon); |
0 | 243 } |
244 | |
245 void X11_SetCaption(_THIS, const char *title, const char *icon) | |
246 { | |
247 XTextProperty titleprop, iconprop; | |
248 | |
249 /* Lock the event thread, in multi-threading environments */ | |
250 SDL_Lock_EventThread(); | |
251 | |
252 if ( title != NULL ) { | |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
253 int error = XLocaleNotSupported; |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
254 #ifdef X_HAVE_UTF8_STRING |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
255 error = pXutf8TextListToTextProperty(SDL_Display, |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
256 (char **)&title, 1, XUTF8StringStyle, |
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
257 &titleprop); |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
258 #endif |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
259 if ( error != Success ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
260 pXStringListToTextProperty((char **)&title, 1, |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
261 &titleprop); |
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
262 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
263 pXSetWMName(SDL_Display, WMwindow, &titleprop); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
264 pXFree(titleprop.value); |
0 | 265 } |
266 if ( icon != NULL ) { | |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
267 int error = XLocaleNotSupported; |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
268 #ifdef X_HAVE_UTF8_STRING |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
269 error = pXutf8TextListToTextProperty(SDL_Display, |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
270 (char **)&icon, 1, XUTF8StringStyle, &iconprop); |
913
a7a8c282d62e
Date: Mon, 28 Jun 2004 23:15:55 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
271 #endif |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
272 if ( error != Success ) { |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
273 pXStringListToTextProperty((char **)&icon, 1, &iconprop); |
954
3acd16ea0180
Date: Thu, 02 Sep 2004 01:06:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
913
diff
changeset
|
274 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
275 pXSetWMIconName(SDL_Display, WMwindow, &iconprop); |
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
276 pXFree(iconprop.value); |
0 | 277 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
278 pXSync(SDL_Display, False); |
0 | 279 |
280 SDL_Unlock_EventThread(); | |
281 } | |
282 | |
283 /* Iconify the window */ | |
284 int X11_IconifyWindow(_THIS) | |
285 { | |
286 int result; | |
287 | |
288 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
|
289 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
|
290 pXSync(SDL_Display, False); |
0 | 291 SDL_Unlock_EventThread(); |
292 return(result); | |
293 } | |
294 | |
295 SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) | |
296 { | |
236
3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
99
diff
changeset
|
297 int result; |
0 | 298 |
299 if ( this->screen == NULL ) { | |
300 return(SDL_GRAB_OFF); | |
301 } | |
302 if ( ! SDL_Window ) { | |
303 return(mode); /* Will be set later on mode switch */ | |
304 } | |
305 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
|
306 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
|
307 pXUngrabKeyboard(SDL_Display, CurrentTime); |
0 | 308 } else { |
309 if ( this->screen->flags & SDL_FULLSCREEN ) { | |
310 /* 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
|
311 pXUngrabPointer(SDL_Display, CurrentTime); |
0 | 312 } |
313 /* Try to grab the mouse */ | |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
314 #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */ |
0 | 315 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
|
316 #else |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
317 while ( 1 ) { |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
318 #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
|
319 result = pXGrabPointer(SDL_Display, SDL_Window, True, 0, |
0 | 320 GrabModeAsync, GrabModeAsync, |
321 SDL_Window, None, CurrentTime); | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
322 if ( result == GrabSuccess ) { |
0 | 323 break; |
324 } | |
325 SDL_Delay(100); | |
326 } | |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
327 if ( result != GrabSuccess ) { |
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
328 /* 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
|
329 } |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
330 /* 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
|
331 pXGrabKeyboard(SDL_Display, WMwindow, True, |
88
71774090f286
Hopefully fixed the fullscreen mode code for KDE
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
332 GrabModeAsync, GrabModeAsync, CurrentTime); |
0 | 333 |
334 /* Raise the window if we grab the mouse */ | |
335 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
|
336 pXRaiseWindow(SDL_Display, WMwindow); |
98
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
337 |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
338 /* Make sure we register input focus */ |
8a5aff5c1294
Fixed some problems with the fullscreen code. Wooo. :)
Sam Lantinga <slouken@lokigames.com>
parents:
88
diff
changeset
|
339 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
0 | 340 } |
1168
045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
954
diff
changeset
|
341 pXSync(SDL_Display, False); |
0 | 342 |
343 return(mode); | |
344 } | |
345 | |
346 SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode) | |
347 { | |
348 SDL_Lock_EventThread(); | |
349 mode = X11_GrabInputNoLock(this, mode); | |
350 SDL_Unlock_EventThread(); | |
351 | |
352 return(mode); | |
353 } | |
354 | |
355 /* If 'info' is the right version, this function fills it and returns 1. | |
356 Otherwise, in case of a version mismatch, it returns -1. | |
357 */ | |
358 static void lock_display(void) | |
359 { | |
360 SDL_Lock_EventThread(); | |
361 } | |
362 static void unlock_display(void) | |
363 { | |
364 /* Make sure any X11 transactions are completed */ | |
365 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
|
366 pXSync(SDL_Display, False); |
0 | 367 SDL_Unlock_EventThread(); |
368 } | |
369 int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info) | |
370 { | |
371 if ( info->version.major <= SDL_MAJOR_VERSION ) { | |
372 info->subsystem = SDL_SYSWM_X11; | |
373 info->info.x11.display = SDL_Display; | |
374 info->info.x11.window = SDL_Window; | |
375 if ( SDL_VERSIONNUM(info->version.major, | |
376 info->version.minor, | |
377 info->version.patch) >= 1002 ) { | |
378 info->info.x11.fswindow = FSwindow; | |
379 info->info.x11.wmwindow = WMwindow; | |
380 } | |
381 info->info.x11.lock_func = lock_display; | |
382 info->info.x11.unlock_func = unlock_display; | |
383 return(1); | |
384 } else { | |
385 SDL_SetError("Application not compiled with SDL %d.%d\n", | |
386 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
387 return(-1); | |
388 } | |
389 } |