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