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