Mercurial > mplayer.hg
annotate gui/wm/ws.c @ 33539:5bdc088113f7
Cosmetic: Format to MPlayer coding style.
author | ib |
---|---|
date | Thu, 16 Jun 2011 12:31:42 +0000 |
parents | 276eef06fb3d |
children | 0dec83e053cc |
rev | line source |
---|---|
26458 | 1 /* |
2 * AutoSpace Window System for Linux/Win32 v0.85 | |
3 * written by pontscho/fresh!mindworkz | |
4 * | |
5 * This file is part of MPlayer. | |
6 * | |
7 * MPlayer is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * MPlayer is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License along | |
18 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 */ | |
23077 | 21 |
22 #include <X11/Xlib.h> | |
23 #include <X11/Xproto.h> | |
24 #include <X11/Xutil.h> | |
25 #include <X11/keysym.h> | |
26 #include <X11/Xatom.h> | |
27 | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 #include <string.h> | |
31 #include <unistd.h> | |
32 #include <errno.h> | |
33 | |
33123
9566100d88a1
Replace inttypes.h by stdint.h and remove inttypes.h where unneeded.
ib
parents:
32833
diff
changeset
|
34 #include <stdint.h> |
23077 | 35 |
33264 | 36 #include "gui/interface.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
37 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
38 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
39 #include "libvo/video_out.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
40 #include "cpudetect.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
41 #include "libswscale/swscale.h" |
32833
c4891d10ddbb
Adjust #include paths after the merge of libavcore into libavutil in FFmpeg.
diego
parents:
32741
diff
changeset
|
42 #include "libavutil/imgutils.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
43 #include "libmpcodecs/vf_scale.h" |
33264 | 44 #include "mp_core.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
45 #include "mp_msg.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
46 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
47 #include "mplayer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
23795
diff
changeset
|
48 #include "mpbswap.h" |
23077 | 49 #include "ws.h" |
50 #include "wsxdnd.h" | |
51 | |
52 #include <X11/extensions/XShm.h> | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
53 #ifdef CONFIG_XSHAPE |
23077 | 54 #include <X11/extensions/shape.h> |
55 #endif | |
56 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
57 #ifdef CONFIG_XINERAMA |
23077 | 58 #include <X11/extensions/Xinerama.h> |
59 #endif | |
60 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
61 #ifdef CONFIG_XF86VM |
23077 | 62 #include <X11/extensions/xf86vmode.h> |
63 #endif | |
64 | |
65 #include <sys/ipc.h> | |
66 #include <sys/shm.h> | |
67 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
68 #undef ENABLE_DPMS |
23077 | 69 |
33539 | 70 typedef struct { |
71 unsigned long flags; | |
72 unsigned long functions; | |
73 unsigned long decorations; | |
74 long input_mode; | |
75 unsigned long status; | |
23077 | 76 } MotifWmHints; |
77 | |
33539 | 78 Atom wsMotifHints; |
23077 | 79 |
33539 | 80 int wsMaxX = 0; // Screen width. |
81 int wsMaxY = 0; // Screen height. | |
82 int wsOrgX = 0; // Screen origin x. | |
83 int wsOrgY = 0; // Screen origin y. | |
23077 | 84 |
33539 | 85 Display *wsDisplay; |
86 int wsScreen; | |
87 Window wsRootWin; | |
88 XEvent wsEvent; | |
89 int wsWindowDepth; | |
90 GC wsHGC; | |
91 MotifWmHints wsMotifWmHints; | |
92 Atom wsTextProperlyAtom = None; | |
93 int wsLayer = 0; | |
23077 | 94 |
33539 | 95 int wsDepthOnScreen = 0; |
96 int wsRedMask = 0; | |
97 int wsGreenMask = 0; | |
98 int wsBlueMask = 0; | |
99 int wsOutMask = 0; | |
100 int wsNonNativeOrder = 0; | |
23077 | 101 |
33539 | 102 int wsTrue = True; |
23077 | 103 |
33539 | 104 #define wsWLCount 5 |
105 wsTWindow *wsWindowList[wsWLCount] = { NULL, NULL, NULL, NULL, NULL }; | |
106 | |
107 unsigned long wsKeyTable[512]; | |
23077 | 108 |
33539 | 109 int wsUseXShm = 1; |
110 int wsUseXShape = 1; | |
23077 | 111 |
33539 | 112 static int wsSearch(Window win) |
113 { | |
114 int i; | |
23077 | 115 |
33539 | 116 for (i = 0; i < wsWLCount; i++) |
117 if (wsWindowList[i] && wsWindowList[i]->WindowID == win) | |
118 return i; | |
119 | |
120 return -1; | |
31325 | 121 } |
122 | |
23077 | 123 // --- |
124 | |
33539 | 125 #define PACK_RGB16(r, g, b, pixel) pixel = (b >> 3); \ |
126 pixel <<= 6; \ | |
127 pixel |= (g >> 2); \ | |
128 pixel <<= 5; \ | |
129 pixel |= (r >> 3) | |
23077 | 130 |
33539 | 131 #define PACK_RGB15(r, g, b, pixel) pixel = (b >> 3); \ |
132 pixel <<= 5; \ | |
133 pixel |= (g >> 3); \ | |
134 pixel <<= 5; \ | |
135 pixel |= (r >> 3) | |
23077 | 136 |
33539 | 137 struct SwsContext *sws_ctx = NULL; |
32028
9e6fdede8ece
gui: remove direct usage of rgb2rgb interface, use swscale instead
ramiro
parents:
31325
diff
changeset
|
138 enum PixelFormat out_pix_fmt = PIX_FMT_NONE; |
23077 | 139 |
140 // --- | |
141 | |
142 #define MWM_HINTS_FUNCTIONS (1L << 0) | |
143 #define MWM_HINTS_DECORATIONS (1L << 1) | |
144 #define MWM_HINTS_INPUT_MODE (1L << 2) | |
145 #define MWM_HINTS_STATUS (1L << 3) | |
146 | |
147 #define MWM_FUNC_ALL (1L << 0) | |
148 #define MWM_FUNC_RESIZE (1L << 1) | |
149 #define MWM_FUNC_MOVE (1L << 2) | |
150 #define MWM_FUNC_MINIMIZE (1L << 3) | |
151 #define MWM_FUNC_MAXIMIZE (1L << 4) | |
152 #define MWM_FUNC_CLOSE (1L << 5) | |
153 | |
154 #define MWM_DECOR_ALL (1L << 0) | |
155 #define MWM_DECOR_BORDER (1L << 1) | |
156 #define MWM_DECOR_RESIZEH (1L << 2) | |
157 #define MWM_DECOR_TITLE (1L << 3) | |
158 #define MWM_DECOR_MENU (1L << 4) | |
159 #define MWM_DECOR_MINIMIZE (1L << 5) | |
160 #define MWM_DECOR_MAXIMIZE (1L << 6) | |
161 | |
162 #define MWM_INPUT_MODELESS 0 | |
163 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 | |
164 #define MWM_INPUT_SYSTEM_MODAL 2 | |
165 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 | |
166 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL | |
167 | |
33539 | 168 #define MWM_TEAROFF_WINDOW (1L << 0) |
23077 | 169 |
33539 | 170 void wsWindowDecoration(wsTWindow *win, long d) |
23077 | 171 { |
33539 | 172 wsMotifHints = XInternAtom(wsDisplay, "_MOTIF_WM_HINTS", 0); |
173 | |
174 if (wsMotifHints == None) | |
175 return; | |
23077 | 176 |
33539 | 177 memset(&wsMotifWmHints, 0, sizeof(MotifWmHints)); |
178 wsMotifWmHints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; | |
179 | |
180 if (d) { | |
181 wsMotifWmHints.functions = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; | |
182 wsMotifWmHints.decorations = MWM_DECOR_ALL; | |
183 } | |
184 | |
185 XChangeProperty(wsDisplay, win->WindowID, wsMotifHints, wsMotifHints, 32, | |
186 PropModeReplace, (unsigned char *)&wsMotifWmHints, 5); | |
23077 | 187 } |
188 | |
189 // ---------------------------------------------------------------------------------------------- | |
190 // Init X Window System. | |
191 // ---------------------------------------------------------------------------------------------- | |
192 | |
33539 | 193 static int wsErrorHandler(Display *dpy, XErrorEvent *Event) |
23077 | 194 { |
33539 | 195 char type[128]; |
196 | |
197 XGetErrorText(wsDisplay, Event->error_code, type, 128); | |
198 fprintf(stderr, "[ws] Error in display.\n"); | |
199 fprintf(stderr, "[ws] Error code: %d ( %s )\n", Event->error_code, type); | |
200 fprintf(stderr, "[ws] Request code: %d\n", Event->request_code); | |
201 fprintf(stderr, "[ws] Minor code: %d\n", Event->minor_code); | |
202 fprintf(stderr, "[ws] Modules: %s\n", current_module ? current_module : "(NULL)"); | |
203 return 0; | |
23077 | 204 } |
205 | |
33539 | 206 void wsXInit(Display *mDisplay) |
23077 | 207 { |
33539 | 208 int eventbase; |
209 int errorbase; | |
23077 | 210 |
33539 | 211 // NOTE TO MYSELF: Use global mDisplay, get rid of wsDisplay. |
212 wsDisplay = mDisplay; | |
23077 | 213 |
33539 | 214 XSetErrorHandler(wsErrorHandler); |
31323
c674bb16fa6d
Install error handler as early as possible to avoid crashing.
reimar
parents:
31314
diff
changeset
|
215 |
23077 | 216 /* enable DND atoms */ |
33539 | 217 wsXDNDInitialize(); |
218 | |
219 { /* on remote display XShm will be disabled - LGB */ | |
220 char *dispname = DisplayString(wsDisplay); | |
221 int localdisp = 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
222 |
33539 | 223 if (dispname && *dispname != ':') { |
224 localdisp = 0; | |
225 wsUseXShm = 0; | |
226 } | |
227 | |
228 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[ws] display name: %s => %s display.\n", dispname, localdisp ? "local" : "REMOTE"); | |
23077 | 229 |
33539 | 230 if (!localdisp) |
231 mp_msg(MSGT_GPLAYER, MSGL_V, MSGTR_WS_RemoteDisplay); | |
232 } | |
233 | |
234 if (!XShmQueryExtension(wsDisplay)) { | |
235 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_WS_NoXshm); | |
236 wsUseXShm = 0; | |
237 } | |
238 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
239 #ifdef CONFIG_XSHAPE |
33539 | 240 |
241 if (!XShapeQueryExtension(wsDisplay, &eventbase, &errorbase)) { | |
242 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_WS_NoXshape); | |
243 wsUseXShape = 0; | |
244 } | |
245 | |
23077 | 246 #else |
33539 | 247 wsUseXShape = 0; |
23077 | 248 #endif |
249 | |
33539 | 250 XSynchronize(wsDisplay, True); |
23077 | 251 |
33539 | 252 wsScreen = DefaultScreen(wsDisplay); |
253 wsRootWin = RootWindow(wsDisplay, wsScreen); | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
254 #ifdef CONFIG_XF86VM |
23077 | 255 { |
33539 | 256 int clock; |
257 XF86VidModeModeLine modeline; | |
23077 | 258 |
33539 | 259 XF86VidModeGetModeLine(wsDisplay, wsScreen, &clock, &modeline); |
260 wsMaxX = modeline.hdisplay; | |
261 wsMaxY = modeline.vdisplay; | |
23077 | 262 } |
263 #endif | |
33539 | 264 { |
265 wsOrgX = wsOrgY = 0; | |
23077 | 266 |
33539 | 267 if (!wsMaxX) |
268 wsMaxX = DisplayWidth(wsDisplay, wsScreen); | |
269 | |
270 if (!wsMaxY) | |
271 wsMaxY = DisplayHeight(wsDisplay, wsScreen); | |
23077 | 272 } |
33539 | 273 vo_screenwidth = wsMaxX; |
274 vo_screenheight = wsMaxY; | |
275 xinerama_x = wsOrgX; | |
276 xinerama_y = wsOrgY; | |
277 update_xinerama_info(); | |
278 wsMaxX = vo_screenwidth; | |
279 wsMaxY = vo_screenheight; | |
280 wsOrgX = xinerama_x; | |
281 wsOrgY = xinerama_y; | |
282 | |
283 wsGetDepthOnScreen(); | |
284 #ifdef DEBUG | |
285 { | |
286 int minor, major, shp; | |
287 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] Screen depth: %d\n", wsDepthOnScreen); | |
288 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] size: %dx%d\n", wsMaxX, wsMaxY); | |
289 #ifdef CONFIG_XINERAMA | |
290 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] origin: +%d+%d\n", wsOrgX, wsOrgY); | |
291 #endif | |
292 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] red mask: 0x%x\n", wsRedMask); | |
293 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] green mask: 0x%x\n", wsGreenMask); | |
294 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] blue mask: 0x%x\n", wsBlueMask); | |
295 | |
296 if (wsUseXShm) { | |
297 XShmQueryVersion(wsDisplay, &major, &minor, &shp); | |
298 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] XShm version is %d.%d\n", major, minor); | |
299 } | |
300 | |
301 #ifdef CONFIG_XSHAPE | |
302 | |
303 if (wsUseXShape) { | |
304 XShapeQueryVersion(wsDisplay, &major, &minor); | |
305 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] XShape version is %d.%d\n", major, minor); | |
306 } | |
307 | |
23077 | 308 #endif |
33539 | 309 } |
310 #endif | |
311 wsOutMask = wsGetOutMask(); | |
312 | |
313 switch (wsOutMask) { | |
314 case wsRGB32: | |
315 out_pix_fmt = PIX_FMT_RGB32; | |
316 break; | |
317 | |
318 case wsBGR32: | |
319 out_pix_fmt = PIX_FMT_BGR32; | |
320 break; | |
321 | |
322 case wsRGB24: | |
323 out_pix_fmt = PIX_FMT_RGB24; | |
324 break; | |
325 | |
326 case wsBGR24: | |
327 out_pix_fmt = PIX_FMT_BGR24; | |
328 break; | |
329 | |
330 case wsRGB16: | |
331 out_pix_fmt = PIX_FMT_RGB565; | |
332 break; | |
333 | |
334 case wsBGR16: | |
335 out_pix_fmt = PIX_FMT_BGR565; | |
336 break; | |
337 | |
338 case wsRGB15: | |
339 out_pix_fmt = PIX_FMT_RGB555; | |
340 break; | |
341 | |
342 case wsBGR15: | |
343 out_pix_fmt = PIX_FMT_BGR555; | |
344 break; | |
345 } | |
23077 | 346 } |
347 | |
348 // ---------------------------------------------------------------------------------------------- | |
349 // Create window. | |
350 // X,Y : window position | |
351 // wX,wY : size of window | |
352 // bW : border width | |
353 // cV : visible mouse cursor on window | |
354 // D : visible frame, title, etc. | |
355 // sR : screen ratio | |
356 // ---------------------------------------------------------------------------------------------- | |
357 | |
33539 | 358 XClassHint wsClassHint; |
359 XTextProperty wsTextProperty; | |
360 Window LeaderWindow; | |
23077 | 361 |
33539 | 362 void wsCreateWindow(wsTWindow *win, int X, int Y, int wX, int hY, int bW, int cV, unsigned char D, char *label) |
23077 | 363 { |
33539 | 364 int depth; |
365 | |
366 win->Property = D; | |
23077 | 367 |
33539 | 368 if (D & wsShowFrame) |
369 win->Decorations = 1; | |
370 | |
371 wsHGC = DefaultGC(wsDisplay, wsScreen); | |
372 | |
23077 | 373 // The window position and size. |
33539 | 374 switch (X) { |
375 case -1: | |
376 win->X = (wsMaxX / 2) - (wX / 2) + wsOrgX; | |
377 break; | |
378 | |
379 case -2: | |
380 win->X = wsMaxX - wX - 1 + wsOrgX; | |
381 break; | |
382 | |
383 default: | |
384 win->X = X; | |
385 break; | |
386 } | |
387 | |
388 switch (Y) { | |
389 case -1: | |
390 win->Y = (wsMaxY / 2) - (hY / 2) + wsOrgY; | |
391 break; | |
392 | |
393 case -2: | |
394 win->Y = wsMaxY - hY - 1 + wsOrgY; | |
395 break; | |
396 | |
397 default: | |
398 win->Y = Y; | |
399 break; | |
400 } | |
401 | |
402 win->Width = wX; | |
403 win->Height = hY; | |
404 win->OldX = win->X; | |
405 win->OldY = win->Y; | |
406 win->OldWidth = win->Width; | |
407 win->OldHeight = win->Height; | |
23077 | 408 |
409 // Border size for window. | |
33539 | 410 win->BorderWidth = bW; |
23077 | 411 // Hide Mouse Cursor |
33539 | 412 win->wsCursor = None; |
413 win->wsMouseEventType = cV; | |
414 win->wsCursorData[0] = 0; | |
415 win->wsCursorPixmap = XCreateBitmapFromData(wsDisplay, wsRootWin, win->wsCursorData, 1, 1); | |
23077 | 416 |
33539 | 417 if (!(cV & wsShowMouseCursor)) |
418 win->wsCursor = XCreatePixmapCursor(wsDisplay, win->wsCursorPixmap, win->wsCursorPixmap, &win->wsColor, &win->wsColor, 0, 0); | |
419 | |
420 depth = vo_find_depth_from_visuals(wsDisplay, wsScreen, NULL); | |
421 | |
422 if (depth < 15) { | |
423 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ColorDepthTooLow); | |
424 guiExit(EXIT_ERROR); | |
425 } | |
426 | |
427 XMatchVisualInfo(wsDisplay, wsScreen, depth, TrueColor, &win->VisualInfo); | |
23077 | 428 |
429 // --- | |
33539 | 430 win->AtomLeaderClient = XInternAtom(wsDisplay, "WM_CLIENT_LEADER", False); |
431 win->AtomDeleteWindow = XInternAtom(wsDisplay, "WM_DELETE_WINDOW", False); | |
432 win->AtomTakeFocus = XInternAtom(wsDisplay, "WM_TAKE_FOCUS", False); | |
433 win->AtomRolle = XInternAtom(wsDisplay, "WM_WINDOW_ROLE", False); | |
434 win->AtomWMSizeHint = XInternAtom(wsDisplay, "WM_SIZE_HINT", False); | |
435 win->AtomWMNormalHint = XInternAtom(wsDisplay, "WM_NORMAL_HINT", False); | |
436 win->AtomProtocols = XInternAtom(wsDisplay, "WM_PROTOCOLS", False); | |
437 win->AtomsProtocols[0] = win->AtomDeleteWindow; | |
438 win->AtomsProtocols[1] = win->AtomTakeFocus; | |
439 win->AtomsProtocols[2] = win->AtomRolle; | |
23077 | 440 // --- |
441 | |
33539 | 442 win->WindowAttrib.background_pixel = BlackPixel(wsDisplay, wsScreen); |
443 win->WindowAttrib.border_pixel = WhitePixel(wsDisplay, wsScreen); | |
444 win->WindowAttrib.colormap = XCreateColormap(wsDisplay, wsRootWin, win->VisualInfo.visual, AllocNone); | |
445 win->WindowAttrib.event_mask = StructureNotifyMask | FocusChangeMask | | |
446 ExposureMask | PropertyChangeMask | | |
447 EnterWindowMask | LeaveWindowMask | | |
448 VisibilityChangeMask | | |
449 KeyPressMask | KeyReleaseMask; | |
23077 | 450 |
33539 | 451 if ((cV & wsHandleMouseButton)) |
452 win->WindowAttrib.event_mask |= ButtonPressMask | ButtonReleaseMask; | |
453 | |
454 if ((cV & wsHandleMouseMove)) | |
455 win->WindowAttrib.event_mask |= PointerMotionMask; | |
456 | |
457 win->WindowAttrib.cursor = win->wsCursor; | |
458 win->WindowAttrib.override_redirect = False; | |
459 | |
460 if (D & wsOverredirect) | |
461 win->WindowAttrib.override_redirect = True; | |
23077 | 462 |
33539 | 463 win->WindowMask = CWBackPixel | CWBorderPixel | |
464 CWColormap | CWEventMask | CWCursor | | |
465 CWOverrideRedirect; | |
23077 | 466 |
33539 | 467 win->WindowID = XCreateWindow(wsDisplay, |
468 (win->Parent != 0 ? win->Parent : wsRootWin), | |
469 win->X, win->Y, win->Width, win->Height, win->BorderWidth, | |
470 win->VisualInfo.depth, | |
471 InputOutput, | |
472 win->VisualInfo.visual, | |
473 win->WindowMask, &win->WindowAttrib); | |
23077 | 474 |
33539 | 475 wsClassHint.res_name = "MPlayer"; |
476 | |
477 wsClassHint.res_class = "MPlayer"; | |
478 XSetClassHint(wsDisplay, win->WindowID, &wsClassHint); | |
479 | |
480 win->SizeHint.flags = PPosition | PSize | PResizeInc | PWinGravity; // | PBaseSize; | |
481 win->SizeHint.x = win->X; | |
482 win->SizeHint.y = win->Y; | |
483 win->SizeHint.width = win->Width; | |
484 win->SizeHint.height = win->Height; | |
23077 | 485 |
33539 | 486 if (D & wsMinSize) { |
487 win->SizeHint.flags |= PMinSize; | |
488 win->SizeHint.min_width = win->Width; | |
489 win->SizeHint.min_height = win->Height; | |
490 } | |
491 | |
492 if (D & wsMaxSize) { | |
493 win->SizeHint.flags |= PMaxSize; | |
494 win->SizeHint.max_width = win->Width; | |
495 win->SizeHint.max_height = win->Height; | |
496 } | |
23077 | 497 |
33539 | 498 win->SizeHint.height_inc = 1; |
499 win->SizeHint.width_inc = 1; | |
500 win->SizeHint.base_width = win->Width; | |
501 win->SizeHint.base_height = win->Height; | |
502 win->SizeHint.win_gravity = StaticGravity; | |
503 XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint); | |
23077 | 504 |
33539 | 505 win->WMHints.flags = InputHint | StateHint; |
506 win->WMHints.input = True; | |
507 win->WMHints.initial_state = NormalState; | |
508 XSetWMHints(wsDisplay, win->WindowID, &win->WMHints); | |
23077 | 509 |
33539 | 510 wsWindowDecoration(win, win->Decorations); |
511 XStoreName(wsDisplay, win->WindowID, label); | |
512 XmbSetWMProperties(wsDisplay, win->WindowID, label, label, NULL, 0, NULL, NULL, NULL); | |
23077 | 513 |
33539 | 514 XSetWMProtocols(wsDisplay, win->WindowID, win->AtomsProtocols, 3); |
515 XChangeProperty(wsDisplay, win->WindowID, | |
516 win->AtomLeaderClient, | |
517 XA_WINDOW, 32, PropModeReplace, | |
518 (unsigned char *)&LeaderWindow, 1); | |
23077 | 519 |
33539 | 520 wsTextProperty.value = label; |
521 wsTextProperty.encoding = XA_STRING; | |
522 wsTextProperty.format = 8; | |
523 wsTextProperty.nitems = strlen(label); | |
524 XSetWMIconName(wsDisplay, win->WindowID, &wsTextProperty); | |
525 | |
526 win->wGC = XCreateGC(wsDisplay, win->WindowID, | |
527 GCForeground | GCBackground, | |
528 &win->wGCV); | |
23077 | 529 |
33539 | 530 win->Visible = 0; |
531 win->Focused = 0; | |
532 win->Mapped = 0; | |
533 win->Rolled = 0; | |
23077 | 534 |
33539 | 535 if (D & wsShowWindow) |
536 XMapWindow(wsDisplay, win->WindowID); | |
23077 | 537 |
33539 | 538 wsCreateImage(win, win->Width, win->Height); |
23077 | 539 // --- End of creating -------------------------------------------------------------------------- |
540 | |
33539 | 541 { |
542 int i; | |
543 | |
544 for (i = 0; i < wsWLCount; i++) | |
545 if (wsWindowList[i] == NULL) | |
546 break; | |
547 | |
548 if (i == wsWLCount) { | |
549 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_TooManyOpenWindows); | |
550 guiExit(EXIT_ERROR); | |
551 } | |
23077 | 552 |
33539 | 553 wsWindowList[i] = win; |
554 } | |
555 | |
556 XFlush(wsDisplay); | |
557 XSync(wsDisplay, False); | |
23077 | 558 |
33539 | 559 win->ReDraw = NULL; |
560 win->ReSize = NULL; | |
561 win->Idle = NULL; | |
562 win->MouseHandler = NULL; | |
563 win->KeyHandler = NULL; | |
564 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[ws] window is created. ( %s ).\n", label); | |
23077 | 565 } |
566 | |
33539 | 567 void wsDestroyWindow(wsTWindow *win) |
23077 | 568 { |
33539 | 569 int l; |
570 | |
571 l = wsSearch(win->WindowID); | |
572 wsWindowList[l] = NULL; | |
573 | |
574 if (win->wsCursor != None) { | |
575 XFreeCursor(wsDisplay, win->wsCursor); | |
576 win->wsCursor = None; | |
577 } | |
578 | |
579 XFreeGC(wsDisplay, win->wGC); | |
580 XUnmapWindow(wsDisplay, win->WindowID); | |
581 wsDestroyImage(win); | |
582 XDestroyWindow(wsDisplay, win->WindowID); | |
23077 | 583 #if 0 |
33539 | 584 win->ReDraw = NULL; |
585 win->ReSize = NULL; | |
586 win->Idle = NULL; | |
587 win->MouseHandler = NULL; | |
588 win->KeyHandler = NULL; | |
589 win->Visible = 0; | |
590 win->Focused = 0; | |
591 win->Mapped = 0; | |
592 win->Rolled = 0; | |
23077 | 593 #endif |
594 } | |
595 | |
596 // ---------------------------------------------------------------------------------------------- | |
597 // Handle events. | |
598 // ---------------------------------------------------------------------------------------------- | |
599 | |
33539 | 600 Bool wsEvents(Display *display, XEvent *Event, XPointer arg) |
23077 | 601 { |
33539 | 602 unsigned long i = 0; |
603 int l; | |
604 int x, y; | |
605 Window child_window = 0; | |
606 | |
607 l = wsSearch(Event->xany.window); | |
608 | |
609 if (l == -1) | |
610 return !wsTrue; | |
611 | |
612 wsWindowList[l]->State = 0; | |
613 | |
614 switch (Event->type) { | |
615 case ClientMessage: | |
23077 | 616 |
33539 | 617 if (Event->xclient.message_type == wsWindowList[l]->AtomProtocols) { |
618 if ((Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow) { | |
619 i = wsWindowClosed; | |
620 goto expose; | |
621 } | |
622 | |
623 if ((Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus) { | |
624 i = wsWindowFocusIn; | |
625 wsWindowList[l]->Focused = wsFocused; | |
626 goto expose; | |
627 } | |
628 | |
629 if ((Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomRolle) { | |
630 mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] role set.\n"); | |
631 } | |
632 } else { | |
633 /* try to process DND events */ | |
634 wsXDNDProcessClientMessage(wsWindowList[l], &Event->xclient); | |
635 } | |
636 | |
23077 | 637 break; |
638 | |
33539 | 639 case MapNotify: |
640 i = wsWindowMapped; | |
641 wsWindowList[l]->Mapped = wsMapped; | |
642 goto expose; | |
643 | |
644 case UnmapNotify: | |
645 i = wsWindowUnmapped; | |
646 wsWindowList[l]->Mapped = wsNone; | |
647 goto expose; | |
648 | |
649 case FocusIn: | |
650 | |
651 if (wsWindowList[l]->Focused == wsFocused) | |
652 break; | |
653 | |
654 i = wsWindowFocusIn; | |
655 wsWindowList[l]->Focused = wsFocused; | |
656 goto expose; | |
657 | |
658 case FocusOut: | |
659 | |
660 if (wsWindowList[l]->Focused == wsNone) | |
661 break; | |
662 | |
663 i = wsWindowFocusOut; | |
664 wsWindowList[l]->Focused = wsNone; | |
23077 | 665 goto expose; |
33539 | 666 |
667 case VisibilityNotify: | |
668 | |
669 switch (Event->xvisibility.state) { | |
670 case VisibilityUnobscured: | |
671 i = wsWindowVisible; | |
672 wsWindowList[l]->Visible = wsVisible; | |
673 goto expose; | |
674 | |
675 case VisibilityFullyObscured: | |
676 i = wsWindowNotVisible; | |
677 wsWindowList[l]->Visible = wsNotVisible; | |
678 goto expose; | |
679 | |
680 case VisibilityPartiallyObscured: | |
681 i = wsWindowPartialVisible; | |
682 wsWindowList[l]->Visible = wsPVisible; | |
683 goto expose; | |
684 } | |
685 | |
23077 | 686 expose: |
33539 | 687 wsWindowList[l]->State = i; |
688 | |
689 if (wsWindowList[l]->ReDraw) | |
690 wsWindowList[l]->ReDraw(); | |
691 | |
23077 | 692 break; |
693 | |
33539 | 694 case Expose: |
695 wsWindowList[l]->State = wsWindowExpose; | |
696 | |
697 if ((wsWindowList[l]->ReDraw) && (!Event->xexpose.count)) | |
698 wsWindowList[l]->ReDraw(); | |
699 | |
23077 | 700 break; |
701 | |
33539 | 702 case ConfigureNotify: |
703 XTranslateCoordinates(wsDisplay, wsWindowList[l]->WindowID, wsRootWin, 0, 0, &x, &y, &child_window); | |
704 | |
705 if ((wsWindowList[l]->X != x) || (wsWindowList[l]->Y != y) || (wsWindowList[l]->Width != Event->xconfigure.width) || (wsWindowList[l]->Height != Event->xconfigure.height)) { | |
706 wsWindowList[l]->X = x; | |
707 wsWindowList[l]->Y = y; | |
708 wsWindowList[l]->Width = Event->xconfigure.width; | |
709 wsWindowList[l]->Height = Event->xconfigure.height; | |
23077 | 710 |
33539 | 711 if (wsWindowList[l]->ReSize) |
712 wsWindowList[l]->ReSize(wsWindowList[l]->X, wsWindowList[l]->Y, wsWindowList[l]->Width, wsWindowList[l]->Height); | |
713 } | |
714 | |
715 wsWindowList[l]->Rolled = wsNone; | |
716 | |
717 if (Event->xconfigure.y < 0) { | |
718 i = wsWindowRolled; | |
719 wsWindowList[l]->Rolled = wsRolled; | |
720 goto expose; | |
721 } | |
23077 | 722 |
723 break; | |
724 | |
33539 | 725 case KeyPress: |
726 i = wsKeyPressed; | |
727 goto keypressed; | |
728 | |
729 case KeyRelease: | |
730 i = wsKeyReleased; | |
23077 | 731 keypressed: |
33539 | 732 wsWindowList[l]->Alt = 0; |
733 wsWindowList[l]->Shift = 0; | |
734 wsWindowList[l]->NumLock = 0; | |
735 wsWindowList[l]->Control = 0; | |
736 wsWindowList[l]->CapsLock = 0; | |
737 | |
738 if (Event->xkey.state & Mod1Mask) | |
739 wsWindowList[l]->Alt = 1; | |
740 | |
741 if (Event->xkey.state & Mod2Mask) | |
742 wsWindowList[l]->NumLock = 1; | |
743 | |
744 if (Event->xkey.state & ControlMask) | |
745 wsWindowList[l]->Control = 1; | |
746 | |
747 if (Event->xkey.state & ShiftMask) | |
748 wsWindowList[l]->Shift = 1; | |
749 | |
750 if (Event->xkey.state & LockMask) | |
751 wsWindowList[l]->CapsLock = 1; | |
752 | |
23077 | 753 #if 0 |
754 { | |
33539 | 755 KeySym keySym; |
756 keySym = XKeycodeToKeysym(wsDisplay, Event->xkey.keycode, 0); | |
757 | |
758 if (keySym != NoSymbol) { | |
759 keySym = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym)); | |
760 wsKeyTable[keySym] = i; | |
761 | |
762 if (wsWindowList[l]->KeyHandler) | |
763 wsWindowList[l]->KeyHandler(Event->xkey.state, i, keySym); | |
764 } | |
765 } | |
23077 | 766 #else |
33539 | 767 { |
768 int key; | |
769 char buf[100]; | |
770 KeySym keySym; | |
771 static XComposeStatus stat; | |
23077 | 772 |
33539 | 773 XLookupString(&Event->xkey, buf, sizeof(buf), &keySym, &stat); |
774 key = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym)); | |
775 wsKeyTable[key] = i; | |
776 | |
777 if (wsWindowList[l]->KeyHandler) | |
778 wsWindowList[l]->KeyHandler(Event->xkey.keycode, i, key); | |
779 } | |
23077 | 780 #endif |
781 break; | |
782 | |
33539 | 783 case MotionNotify: |
784 i = wsMoveMouse; | |
785 { | |
786 /* pump all motion events from the display queue: | |
787 * this way it works faster when moving the window */ | |
788 static XEvent e; | |
789 | |
790 if (Event->xmotion.state) { | |
791 while (XCheckTypedWindowEvent(display, Event->xany.window, MotionNotify, &e)) { | |
792 /* FIXME: need to make sure we didn't release/press the button in between...*/ | |
793 /* FIXME: do we need some timeout here to make sure we don't spend too much time | |
794 * removing events from the queue? */ | |
795 Event = &e; | |
796 } | |
797 } | |
23077 | 798 } |
33539 | 799 goto buttonreleased; |
800 | |
801 case ButtonRelease: | |
802 i = Event->xbutton.button + 128; | |
803 goto buttonreleased; | |
804 | |
805 case ButtonPress: | |
806 i = Event->xbutton.button; | |
807 goto buttonreleased; | |
808 | |
809 case EnterNotify: | |
810 i = wsEnterWindow; | |
811 goto buttonreleased; | |
812 | |
813 case LeaveNotify: | |
814 i = wsLeaveWindow; | |
23077 | 815 buttonreleased: |
33539 | 816 |
817 if (wsWindowList[l]->MouseHandler) | |
818 wsWindowList[l]->MouseHandler(i, Event->xbutton.x, Event->xbutton.y, Event->xmotion.x_root, Event->xmotion.y_root); | |
819 | |
23077 | 820 break; |
821 | |
33539 | 822 case SelectionNotify: |
823 /* Handle DandD */ | |
824 wsXDNDProcessSelection(wsWindowList[l], Event); | |
825 break; | |
826 } | |
827 | |
828 XFlush(wsDisplay); | |
829 XSync(wsDisplay, False); | |
830 return !wsTrue; | |
23077 | 831 } |
832 | |
33539 | 833 void wsHandleEvents(void) |
834 { | |
835 // handle pending events | |
836 while (XPending(wsDisplay)) { | |
837 XNextEvent(wsDisplay, &wsEvent); | |
23077 | 838 // printf("### X event: %d [%d]\n",wsEvent.type,delay); |
33539 | 839 wsEvents(wsDisplay, &wsEvent, NULL); |
840 } | |
23077 | 841 } |
842 | |
33539 | 843 void wsMainLoop(void) |
23077 | 844 { |
33539 | 845 int delay = 20; |
846 | |
847 mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] init threads: %d\n", XInitThreads()); | |
848 XSynchronize(wsDisplay, False); | |
849 XLockDisplay(wsDisplay); | |
23077 | 850 // XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL ); |
851 | |
33539 | 852 while (wsTrue) { |
853 // handle pending events | |
854 while (XPending(wsDisplay)) { | |
855 XNextEvent(wsDisplay, &wsEvent); | |
856 wsEvents(wsDisplay, &wsEvent, NULL); | |
857 delay = 0; | |
858 } | |
23077 | 859 |
33539 | 860 usleep(delay * 1000); // FIXME! |
861 | |
862 if (delay < 10 * 20) | |
863 delay += 20; // pump up delay up to 0.2 sec (low activity) | |
864 } | |
865 | |
866 XUnlockDisplay(wsDisplay); | |
23077 | 867 } |
868 | |
869 // ---------------------------------------------------------------------------------------------- | |
870 // Move window to selected layer | |
871 // ---------------------------------------------------------------------------------------------- | |
872 | |
873 #define WIN_LAYER_ONBOTTOM 2 | |
874 #define WIN_LAYER_NORMAL 4 | |
875 #define WIN_LAYER_ONTOP 10 | |
876 | |
33539 | 877 void wsSetLayer(Display *wsDisplay, Window win, int layer) |
878 { | |
879 vo_x11_setlayer(wsDisplay, win, layer); | |
880 } | |
23077 | 881 |
882 // ---------------------------------------------------------------------------------------------- | |
883 // Switch to fullscreen. | |
884 // ---------------------------------------------------------------------------------------------- | |
33539 | 885 void wsFullScreen(wsTWindow *win) |
23077 | 886 { |
33539 | 887 int decoration = 0; |
888 | |
889 if (win->isFullScreen) { | |
890 vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH | |
23077 | 891 |
33539 | 892 if (!(vo_fs_type & vo_wm_FULLSCREEN)) { // shouldn't be needed with EWMH fs |
893 win->X = win->OldX; | |
894 win->Y = win->OldY; | |
895 win->Width = win->OldWidth; | |
896 win->Height = win->OldHeight; | |
897 decoration = win->Decorations; | |
898 } | |
23077 | 899 |
900 #ifdef ENABLE_DPMS | |
33539 | 901 wsScreenSaverOn(wsDisplay); |
23077 | 902 #endif |
903 | |
33539 | 904 win->isFullScreen = False; |
905 } else { | |
906 if (!(vo_fs_type & vo_wm_FULLSCREEN)) { // shouldn't be needed with EWMH fs | |
907 win->OldX = win->X; | |
908 win->OldY = win->Y; | |
909 win->OldWidth = win->Width; | |
910 win->OldHeight = win->Height; | |
911 vo_dx = win->X; | |
912 vo_dy = win->Y; | |
913 vo_dwidth = win->Width; | |
914 vo_dheight = win->Height; | |
915 vo_screenwidth = wsMaxX; | |
916 vo_screenheight = wsMaxY; | |
917 xinerama_x = wsOrgX; | |
918 xinerama_y = wsOrgY; | |
919 update_xinerama_info(); | |
920 wsMaxX = vo_screenwidth; | |
921 wsMaxY = vo_screenheight; | |
922 wsOrgX = xinerama_x; | |
923 wsOrgY = xinerama_y; | |
924 win->X = wsOrgX; | |
925 win->Y = wsOrgY; | |
926 win->Width = wsMaxX; | |
927 win->Height = wsMaxY; | |
928 } | |
23077 | 929 |
33539 | 930 win->isFullScreen = True; |
23077 | 931 #ifdef ENABLE_DPMS |
33539 | 932 wsScreenSaverOff(wsDisplay); |
23077 | 933 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
934 |
33539 | 935 vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // adds fullscreen state if wm supports EWMH |
936 } | |
23077 | 937 |
33539 | 938 if (!(vo_fs_type & vo_wm_FULLSCREEN)) { // shouldn't be needed with EWMH fs |
939 vo_x11_decoration(wsDisplay, win->WindowID, decoration); | |
940 vo_x11_sizehint(win->X, win->Y, win->Width, win->Height, 0); | |
941 vo_x11_setlayer(wsDisplay, win->WindowID, win->isFullScreen); | |
23077 | 942 |
33539 | 943 if ((!(win->isFullScreen)) & vo_ontop) |
944 vo_x11_setlayer(wsDisplay, win->WindowID, 1); | |
23077 | 945 |
33539 | 946 XMoveResizeWindow(wsDisplay, win->WindowID, win->X, win->Y, win->Width, win->Height); |
947 } | |
23077 | 948 |
33539 | 949 if (vo_wm_type == 0 && !(vo_fsmode & 16)) { |
950 XWithdrawWindow(wsDisplay, win->WindowID, wsScreen); | |
951 } | |
23077 | 952 |
33539 | 953 XMapRaised(wsDisplay, win->WindowID); |
954 XRaiseWindow(wsDisplay, win->WindowID); | |
955 XFlush(wsDisplay); | |
23077 | 956 } |
957 | |
958 // ---------------------------------------------------------------------------------------------- | |
959 // Redraw screen. | |
960 // ---------------------------------------------------------------------------------------------- | |
33539 | 961 void wsPostRedisplay(wsTWindow *win) |
23077 | 962 { |
33539 | 963 if (win->ReDraw) { |
964 win->State = wsWindowExpose; | |
965 win->ReDraw(); | |
966 XFlush(wsDisplay); | |
967 } | |
23077 | 968 } |
969 | |
970 // ---------------------------------------------------------------------------------------------- | |
971 // Do Exit. | |
972 // ---------------------------------------------------------------------------------------------- | |
33539 | 973 void wsDoExit(void) |
974 { | |
975 wsTrue = False; | |
976 wsResizeWindow(wsWindowList[0], 32, 32); | |
977 } | |
23077 | 978 |
979 // ---------------------------------------------------------------------------------------------- | |
980 // Put 'Image' to window. | |
981 // ---------------------------------------------------------------------------------------------- | |
33539 | 982 void wsConvert(wsTWindow *win, unsigned char *Image, unsigned int Size) |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
983 { |
33539 | 984 const uint8_t *src[4] = { Image, NULL, NULL, NULL }; |
985 int src_stride[4] = { 4 * win->xImage->width, 0, 0, 0 }; | |
986 uint8_t *dst[4] = { win->ImageData, NULL, NULL, NULL }; | |
987 int dst_stride[4]; | |
988 int i; | |
989 | |
990 sws_ctx = sws_getCachedContext(sws_ctx, win->xImage->width, win->xImage->height, PIX_FMT_RGB32, | |
991 win->xImage->width, win->xImage->height, out_pix_fmt, | |
992 SWS_POINT, NULL, NULL, NULL); | |
993 av_image_fill_linesizes(dst_stride, out_pix_fmt, win->xImage->width); | |
994 sws_scale(sws_ctx, src, src_stride, 0, win->xImage->height, dst, dst_stride); | |
995 | |
996 if (!wsNonNativeOrder) | |
997 return; | |
998 | |
999 switch (win->xImage->bits_per_pixel) { | |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1000 case 32: |
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1001 { |
33539 | 1002 uint32_t *d = (uint32_t *)win->ImageData; |
1003 | |
1004 for (i = 0; i < win->xImage->width * win->xImage->height; i++) | |
1005 d[i] = bswap_32(d[i]); | |
1006 | |
1007 break; | |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1008 } |
33539 | 1009 |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1010 case 16: |
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1011 case 15: |
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1012 { |
33539 | 1013 uint16_t *d = (uint16_t *)win->ImageData; |
1014 | |
1015 for (i = 0; i < win->xImage->width * win->xImage->height; i++) | |
1016 d[i] = bswap_16(d[i]); | |
1017 | |
1018 break; | |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1019 } |
33539 | 1020 } |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1021 } |
23077 | 1022 |
33539 | 1023 void wsPutImage(wsTWindow *win) |
23077 | 1024 { |
33539 | 1025 if (wsUseXShm) { |
1026 XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage, | |
1027 0, 0, | |
1028 (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2, | |
1029 win->xImage->width, win->xImage->height, 0); | |
1030 } else { | |
1031 XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage, | |
1032 0, 0, | |
1033 (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2, | |
1034 win->xImage->width, win->xImage->height); | |
1035 } | |
23077 | 1036 } |
1037 | |
1038 // ---------------------------------------------------------------------------------------------- | |
1039 // Move window to x, y. | |
1040 // ---------------------------------------------------------------------------------------------- | |
33539 | 1041 void wsMoveWindow(wsTWindow *win, int b, int x, int y) |
23077 | 1042 { |
33539 | 1043 if (b) { |
1044 switch (x) { | |
1045 case -1: | |
1046 win->X = (wsMaxX / 2) - (win->Width / 2) + wsOrgX; | |
1047 break; | |
1048 | |
1049 case -2: | |
1050 win->X = wsMaxX - win->Width + wsOrgX; | |
1051 break; | |
1052 | |
1053 default: | |
1054 win->X = x; | |
1055 break; | |
1056 } | |
1057 | |
1058 switch (y) { | |
1059 case -1: | |
1060 win->Y = (wsMaxY / 2) - (win->Height / 2) + wsOrgY; | |
1061 break; | |
1062 | |
1063 case -2: | |
1064 win->Y = wsMaxY - win->Height + wsOrgY; | |
1065 break; | |
1066 | |
1067 default: | |
1068 win->Y = y; | |
1069 break; | |
1070 } | |
1071 } else { | |
1072 win->X = x; | |
1073 win->Y = y; | |
23077 | 1074 } |
1075 | |
33539 | 1076 win->SizeHint.flags = PPosition | PWinGravity; |
1077 win->SizeHint.x = win->X; | |
1078 win->SizeHint.y = win->Y; | |
1079 win->SizeHint.win_gravity = StaticGravity; | |
1080 XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint); | |
23077 | 1081 |
33539 | 1082 XMoveWindow(wsDisplay, win->WindowID, win->X, win->Y); |
1083 | |
1084 if (win->ReSize) | |
1085 win->ReSize(win->X, win->Y, win->Width, win->Height); | |
23077 | 1086 } |
1087 | |
1088 // ---------------------------------------------------------------------------------------------- | |
1089 // Resize window to sx, sy. | |
1090 // ---------------------------------------------------------------------------------------------- | |
33539 | 1091 void wsResizeWindow(wsTWindow *win, int sx, int sy) |
23077 | 1092 { |
33539 | 1093 win->Width = sx; |
1094 win->Height = sy; | |
23077 | 1095 |
33539 | 1096 win->SizeHint.flags = PPosition | PSize | PWinGravity; // | PBaseSize; |
1097 win->SizeHint.x = win->X; | |
1098 win->SizeHint.y = win->Y; | |
1099 win->SizeHint.width = win->Width; | |
1100 win->SizeHint.height = win->Height; | |
1101 | |
1102 if (win->Property & wsMinSize) { | |
1103 win->SizeHint.flags |= PMinSize; | |
1104 win->SizeHint.min_width = win->Width; | |
1105 win->SizeHint.min_height = win->Height; | |
1106 } | |
23077 | 1107 |
33539 | 1108 if (win->Property & wsMaxSize) { |
1109 win->SizeHint.flags |= PMaxSize; | |
1110 win->SizeHint.max_width = win->Width; | |
1111 win->SizeHint.max_height = win->Height; | |
1112 } | |
1113 | |
1114 win->SizeHint.win_gravity = StaticGravity; | |
1115 win->SizeHint.base_width = sx; | |
1116 win->SizeHint.base_height = sy; | |
23077 | 1117 |
33539 | 1118 if (vo_wm_type == 0) |
1119 XUnmapWindow(wsDisplay, win->WindowID); | |
23077 | 1120 |
33539 | 1121 XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint); |
1122 XResizeWindow(wsDisplay, win->WindowID, sx, sy); | |
1123 XMapRaised(wsDisplay, win->WindowID); | |
1124 | |
1125 if (win->ReSize) | |
1126 win->ReSize(win->X, win->Y, win->Width, win->Height); | |
23077 | 1127 } |
1128 | |
1129 // ---------------------------------------------------------------------------------------------- | |
1130 // Iconify window. | |
1131 // ---------------------------------------------------------------------------------------------- | |
33539 | 1132 void wsIconify(wsTWindow win) |
1133 { | |
1134 XIconifyWindow(wsDisplay, win.WindowID, 0); | |
1135 } | |
23077 | 1136 |
1137 // ---------------------------------------------------------------------------------------------- | |
1138 // Move top the window. | |
1139 // ---------------------------------------------------------------------------------------------- | |
33539 | 1140 void wsMoveTopWindow(Display *wsDisplay, Window win) |
23077 | 1141 { |
1142 // XUnmapWindow( wsDisplay,win ); | |
1143 // XMapWindow( wsDisplay,win ); | |
33539 | 1144 XMapRaised(wsDisplay, win); |
1145 XRaiseWindow(wsDisplay, win); | |
23077 | 1146 } |
1147 | |
1148 // ---------------------------------------------------------------------------------------------- | |
1149 // Set window background to 'color'. | |
1150 // ---------------------------------------------------------------------------------------------- | |
33539 | 1151 void wsSetBackground(wsTWindow *win, int color) |
23077 | 1152 { |
33539 | 1153 XSetWindowBackground(wsDisplay, win->WindowID, color); |
23077 | 1154 } |
1155 | |
33539 | 1156 void wsSetBackgroundRGB(wsTWindow *win, int r, int g, int b) |
23077 | 1157 { |
33539 | 1158 int color = 0; |
1159 | |
1160 switch (wsOutMask) { | |
1161 case wsRGB32: | |
1162 case wsRGB24: | |
1163 color = (r << 16) + (g << 8) + b; | |
1164 break; | |
1165 | |
1166 case wsBGR32: | |
1167 case wsBGR24: | |
1168 color = (b << 16) + (g << 8) + r; | |
1169 break; | |
1170 | |
1171 case wsRGB16: | |
1172 PACK_RGB16(b, g, r, color); | |
1173 break; | |
1174 | |
1175 case wsBGR16: | |
1176 PACK_RGB16(r, g, b, color); | |
1177 break; | |
1178 | |
1179 case wsRGB15: | |
1180 PACK_RGB15(b, g, r, color); | |
1181 break; | |
1182 | |
1183 case wsBGR15: | |
1184 PACK_RGB15(r, g, b, color); | |
1185 break; | |
1186 } | |
1187 | |
1188 XSetWindowBackground(wsDisplay, win->WindowID, color); | |
1189 } | |
1190 | |
1191 void wsSetForegroundRGB(wsTWindow *win, int r, int g, int b) | |
1192 { | |
1193 int color = 0; | |
1194 | |
1195 switch (wsOutMask) { | |
1196 case wsRGB32: | |
1197 case wsRGB24: | |
1198 color = (r << 16) + (g << 8) + b; | |
1199 break; | |
1200 | |
1201 case wsBGR32: | |
1202 case wsBGR24: | |
1203 color = (b << 16) + (g << 8) + r; | |
1204 break; | |
1205 | |
1206 case wsRGB16: | |
1207 PACK_RGB16(b, g, r, color); | |
1208 break; | |
1209 | |
1210 case wsBGR16: | |
1211 PACK_RGB16(r, g, b, color); | |
1212 break; | |
1213 | |
1214 case wsRGB15: | |
1215 PACK_RGB15(b, g, r, color); | |
1216 break; | |
1217 | |
1218 case wsBGR15: | |
1219 PACK_RGB15(r, g, b, color); | |
1220 break; | |
1221 } | |
1222 | |
1223 XSetForeground(wsDisplay, win->wGC, color); | |
23077 | 1224 } |
1225 | |
1226 // ---------------------------------------------------------------------------------------------- | |
1227 // Draw string at x,y with fc ( foreground color ) and bc ( background color ). | |
1228 // ---------------------------------------------------------------------------------------------- | |
33539 | 1229 void wsDrawString(wsTWindow win, int x, int y, char *str, int fc, int bc) |
23077 | 1230 { |
33539 | 1231 XSetForeground(wsDisplay, win.wGC, bc); |
1232 XFillRectangle(wsDisplay, win.WindowID, win.wGC, x, y, | |
1233 XTextWidth(win.Font, str, strlen(str)) + 20, | |
1234 win.FontHeight + 2); | |
1235 XSetForeground(wsDisplay, win.wGC, fc); | |
1236 XDrawString(wsDisplay, win.WindowID, win.wGC, x + 10, y + 13, str, strlen(str)); | |
23077 | 1237 } |
1238 | |
1239 // ---------------------------------------------------------------------------------------------- | |
1240 // Calculation string width. | |
1241 // ---------------------------------------------------------------------------------------------- | |
33539 | 1242 int wsTextWidth(wsTWindow win, char *str) |
1243 { | |
1244 return XTextWidth(win.Font, str, strlen(str)) + 20; | |
1245 } | |
23077 | 1246 |
1247 // ---------------------------------------------------------------------------------------------- | |
1248 // Show / hide mouse cursor. | |
1249 // ---------------------------------------------------------------------------------------------- | |
33539 | 1250 void wsVisibleMouse(wsTWindow *win, int m) |
23077 | 1251 { |
33539 | 1252 switch (m) { |
1253 case wsShowMouseCursor: | |
1254 | |
1255 if (win->wsCursor != None) { | |
1256 XFreeCursor(wsDisplay, win->wsCursor); | |
1257 win->wsCursor = None; | |
1258 } | |
1259 | |
1260 XDefineCursor(wsDisplay, win->WindowID, 0); | |
1261 break; | |
1262 | |
1263 case wsHideMouseCursor: | |
1264 win->wsCursor = XCreatePixmapCursor(wsDisplay, win->wsCursorPixmap, win->wsCursorPixmap, &win->wsColor, &win->wsColor, 0, 0); | |
1265 XDefineCursor(wsDisplay, win->WindowID, win->wsCursor); | |
1266 break; | |
1267 } | |
1268 | |
1269 XFlush(wsDisplay); | |
23077 | 1270 } |
1271 | |
33539 | 1272 int wsGetDepthOnScreen(void) |
23077 | 1273 { |
33539 | 1274 int depth; |
1275 XImage *mXImage; | |
1276 Visual *visual; | |
23077 | 1277 |
33539 | 1278 if ((depth = vo_find_depth_from_visuals(wsDisplay, wsScreen, &visual)) > 0) { |
1279 mXImage = XCreateImage(wsDisplay, visual, depth, ZPixmap, 0, NULL, | |
1280 1, 1, 32, 0); | |
1281 wsDepthOnScreen = mXImage->bits_per_pixel; | |
1282 wsRedMask = mXImage->red_mask; | |
1283 wsGreenMask = mXImage->green_mask; | |
1284 wsBlueMask = mXImage->blue_mask; | |
29401
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29263
diff
changeset
|
1285 #if HAVE_BIGENDIAN |
33539 | 1286 wsNonNativeOrder = mXImage->byte_order == LSBFirst; |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1287 #else |
33539 | 1288 wsNonNativeOrder = mXImage->byte_order == MSBFirst; |
23453
3e18bed9618a
Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents:
23077
diff
changeset
|
1289 #endif |
33539 | 1290 XDestroyImage(mXImage); |
1291 } else { | |
1292 int bpp, ibpp; | |
1293 XWindowAttributes attribs; | |
23077 | 1294 |
33539 | 1295 mXImage = XGetImage(wsDisplay, wsRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap); |
1296 bpp = mXImage->bits_per_pixel; | |
23077 | 1297 |
33539 | 1298 XGetWindowAttributes(wsDisplay, wsRootWin, &attribs); |
1299 ibpp = attribs.depth; | |
1300 mXImage = XGetImage(wsDisplay, wsRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap); | |
1301 bpp = mXImage->bits_per_pixel; | |
1302 | |
1303 if ((ibpp + 7) / 8 != (bpp + 7) / 8) | |
1304 ibpp = bpp; | |
1305 | |
1306 wsDepthOnScreen = ibpp; | |
1307 wsRedMask = mXImage->red_mask; | |
1308 wsGreenMask = mXImage->green_mask; | |
1309 wsBlueMask = mXImage->blue_mask; | |
1310 XDestroyImage(mXImage); | |
1311 } | |
1312 | |
1313 return wsDepthOnScreen; | |
23077 | 1314 } |
1315 | |
33539 | 1316 void wsXDone(void) |
23077 | 1317 { |
33539 | 1318 XCloseDisplay(wsDisplay); |
23077 | 1319 } |
1320 | |
33539 | 1321 void wsVisibleWindow(wsTWindow *win, int show) |
23077 | 1322 { |
33539 | 1323 switch (show) { |
1324 case wsShowWindow: | |
1325 XMapRaised(wsDisplay, win->WindowID); | |
1326 break; | |
1327 | |
1328 case wsHideWindow: | |
1329 XUnmapWindow(wsDisplay, win->WindowID); | |
1330 break; | |
1331 } | |
1332 | |
1333 XFlush(wsDisplay); | |
23077 | 1334 } |
1335 | |
33539 | 1336 void wsDestroyImage(wsTWindow *win) |
23077 | 1337 { |
33539 | 1338 if (win->xImage) { |
1339 XDestroyImage(win->xImage); | |
1340 | |
1341 if (wsUseXShm) { | |
1342 XShmDetach(wsDisplay, &win->Shminfo); | |
1343 shmdt(win->Shminfo.shmaddr); | |
1344 } | |
23077 | 1345 } |
33539 | 1346 |
1347 win->xImage = NULL; | |
23077 | 1348 } |
1349 | |
33539 | 1350 void wsCreateImage(wsTWindow *win, int Width, int Height) |
23077 | 1351 { |
33539 | 1352 if (wsUseXShm) { |
1353 win->xImage = XShmCreateImage(wsDisplay, win->VisualInfo.visual, | |
1354 win->VisualInfo.depth, ZPixmap, NULL, &win->Shminfo, Width, Height); | |
1355 | |
1356 if (win->xImage == NULL) { | |
1357 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError); | |
1358 guiExit(EXIT_ERROR); | |
1359 } | |
1360 | |
1361 win->Shminfo.shmid = shmget(IPC_PRIVATE, win->xImage->bytes_per_line * win->xImage->height, IPC_CREAT | 0777); | |
1362 | |
1363 if (win->Shminfo.shmid < 0) { | |
1364 XDestroyImage(win->xImage); | |
1365 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError); | |
1366 guiExit(EXIT_ERROR); | |
1367 } | |
1368 | |
1369 win->Shminfo.shmaddr = (char *)shmat(win->Shminfo.shmid, 0, 0); | |
1370 | |
1371 if (win->Shminfo.shmaddr == ((char *)-1)) { | |
1372 XDestroyImage(win->xImage); | |
23077 | 1373 |
33539 | 1374 if (win->Shminfo.shmaddr != ((char *)-1)) |
1375 shmdt(win->Shminfo.shmaddr); | |
1376 | |
1377 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError); | |
1378 guiExit(EXIT_ERROR); | |
1379 } | |
1380 | |
1381 win->xImage->data = win->Shminfo.shmaddr; | |
1382 win->Shminfo.readOnly = 0; | |
1383 XShmAttach(wsDisplay, &win->Shminfo); | |
1384 XSync(wsDisplay, False); | |
1385 shmctl(win->Shminfo.shmid, IPC_RMID, 0); | |
1386 } else { | |
1387 win->xImage = XCreateImage(wsDisplay, win->VisualInfo.visual, win->VisualInfo.depth, | |
1388 ZPixmap, 0, 0, Width, Height, | |
1389 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen, | |
1390 0); | |
1391 | |
1392 if ((win->xImage->data = malloc(win->xImage->bytes_per_line * win->xImage->height)) == NULL) { | |
1393 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_NotEnoughMemoryDrawBuffer); | |
1394 guiExit(EXIT_ERROR); | |
1395 } | |
23077 | 1396 } |
33539 | 1397 |
1398 win->ImageData = (unsigned char *)win->xImage->data; | |
1399 win->ImageDataw = (unsigned short int *)win->xImage->data; | |
1400 win->ImageDatadw = (unsigned int *)win->xImage->data; | |
23077 | 1401 } |
1402 | |
33539 | 1403 void wsResizeImage(wsTWindow *win, int Width, int Height) |
1404 { | |
1405 wsDestroyImage(win); | |
1406 wsCreateImage(win, Width, Height); | |
1407 } | |
23077 | 1408 |
33539 | 1409 int wsGetOutMask(void) |
23077 | 1410 { |
33539 | 1411 if ((wsDepthOnScreen == 32) && (wsRedMask == 0xff0000) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0x0000ff)) |
1412 return wsRGB32; | |
1413 | |
1414 if ((wsDepthOnScreen == 32) && (wsRedMask == 0x0000ff) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0xff0000)) | |
1415 return wsBGR32; | |
1416 | |
1417 if ((wsDepthOnScreen == 24) && (wsRedMask == 0xff0000) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0x0000ff)) | |
1418 return wsRGB24; | |
1419 | |
1420 if ((wsDepthOnScreen == 24) && (wsRedMask == 0x0000ff) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0xff0000)) | |
1421 return wsBGR24; | |
1422 | |
1423 if ((wsDepthOnScreen == 16) && (wsRedMask == 0xf800) && (wsGreenMask == 0x7e0) && (wsBlueMask == 0x1f)) | |
1424 return wsRGB16; | |
1425 | |
1426 if ((wsDepthOnScreen == 16) && (wsRedMask == 0x1f) && (wsGreenMask == 0x7e0) && (wsBlueMask == 0xf800)) | |
1427 return wsBGR16; | |
1428 | |
1429 if ((wsDepthOnScreen == 15) && (wsRedMask == 0x7c00) && (wsGreenMask == 0x3e0) && (wsBlueMask == 0x1f)) | |
1430 return wsRGB15; | |
1431 | |
1432 if ((wsDepthOnScreen == 15) && (wsRedMask == 0x1f) && (wsGreenMask == 0x3e0) && (wsBlueMask == 0x7c00)) | |
1433 return wsBGR15; | |
1434 | |
1435 return 0; | |
23077 | 1436 } |
1437 | |
33539 | 1438 void wsSetTitle(wsTWindow *win, char *name) |
1439 { | |
1440 XStoreName(wsDisplay, win->WindowID, name); | |
1441 } | |
23077 | 1442 |
33539 | 1443 void wsSetMousePosition(wsTWindow *win, int x, int y) |
1444 { | |
1445 XWarpPointer(wsDisplay, wsRootWin, win->WindowID, 0, 0, 0, 0, x, y); | |
1446 } | |
23077 | 1447 |
1448 #ifdef ENABLE_DPMS | |
33539 | 1449 static int dpms_disabled = 0; |
1450 static int timeout_save = 0; | |
23077 | 1451 |
33539 | 1452 void wsScreenSaverOn(Display *mDisplay) |
23077 | 1453 { |
33539 | 1454 int nothing; |
1455 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
1456 #ifdef CONFIG_XDPMS |
33539 | 1457 |
1458 if (dpms_disabled) { | |
1459 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) { | |
1460 if (!DPMSEnable(mDisplay)) | |
1461 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_WS_DpmsUnavailable); // restoring power saving settings | |
1462 else { | |
1463 // DPMS does not seem to be enabled unless we call DPMSInfo | |
1464 BOOL onoff; | |
1465 CARD16 state; | |
1466 DPMSInfo(mDisplay, &state, &onoff); | |
1467 | |
1468 if (onoff) | |
1469 mp_msg(MSGT_GPLAYER, MSGL_V, "Successfully enabled DPMS.\n"); | |
1470 else | |
1471 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_WS_DpmsNotEnabled); | |
1472 } | |
1473 } | |
1474 } | |
1475 | |
1476 #endif | |
1477 | |
1478 if (timeout_save) { | |
1479 int dummy, interval, prefer_blank, allow_exp; | |
1480 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp); | |
1481 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp); | |
1482 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); | |
1483 } | |
1484 } | |
1485 | |
1486 void wsScreenSaverOff(Display *mDisplay) | |
1487 { | |
1488 int interval, prefer_blank, allow_exp, nothing; | |
1489 | |
1490 #ifdef CONFIG_XDPMS | |
1491 | |
1492 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) { | |
23077 | 1493 BOOL onoff; |
1494 CARD16 state; | |
33539 | 1495 DPMSInfo(mDisplay, &state, &onoff); |
1496 | |
1497 if (onoff) { | |
1498 Status stat; | |
1499 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "Disabling DPMS.\n"); | |
1500 dpms_disabled = 1; | |
1501 stat = DPMSDisable(mDisplay); // monitor powersave off | |
1502 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "stat: %d.\n", stat); | |
1503 } | |
23077 | 1504 } |
33539 | 1505 |
23077 | 1506 #endif |
33539 | 1507 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp); |
1508 | |
1509 if (timeout_save) | |
1510 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp); // turning off screensaver | |
23077 | 1511 } |
1512 | |
1513 #endif | |
1514 | |
33539 | 1515 void wsSetShape(wsTWindow *win, char *data) |
23077 | 1516 { |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26458
diff
changeset
|
1517 #ifdef CONFIG_XSHAPE |
33539 | 1518 |
1519 if (!wsUseXShape) | |
1520 return; | |
1521 | |
1522 if (data) { | |
1523 win->Mask = XCreateBitmapFromData(wsDisplay, win->WindowID, data, win->Width, win->Height); | |
1524 XShapeCombineMask(wsDisplay, win->WindowID, ShapeBounding, 0, 0, win->Mask, ShapeSet); | |
1525 XFreePixmap(wsDisplay, win->Mask); | |
1526 } else | |
1527 XShapeCombineMask(wsDisplay, win->WindowID, ShapeBounding, 0, 0, None, ShapeSet); | |
1528 | |
23077 | 1529 #endif |
1530 } | |
1531 | |
33539 | 1532 void wsSetIcon(Display *dsp, Window win, guiIcon_t *icon) |
23077 | 1533 { |
33539 | 1534 XWMHints *wm; |
1535 CARD32 data[2]; | |
1536 Atom iconatom; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
1537 |
33539 | 1538 wm = XGetWMHints(dsp, win); |
1539 | |
1540 if (!wm) | |
1541 wm = XAllocWMHints(); | |
23077 | 1542 |
33539 | 1543 wm->icon_pixmap = icon->normal; |
1544 wm->icon_mask = icon->normal_mask; | |
1545 wm->flags |= IconPixmapHint | IconMaskHint; | |
23077 | 1546 |
33539 | 1547 XSetWMHints(dsp, win, wm); |
23077 | 1548 |
33539 | 1549 data[0] = icon->normal; |
1550 data[1] = icon->normal_mask; | |
1551 iconatom = XInternAtom(dsp, "KWM_WIN_ICON", 0); | |
1552 XChangeProperty(dsp, win, iconatom, iconatom, 32, PropModeReplace, (unsigned char *)data, 2); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
1553 |
33539 | 1554 XFree(wm); |
23077 | 1555 } |