Mercurial > mplayer.hg
annotate Gui/wm/ws.c @ 7801:48b7d7fd7075
- wsErrorHandler was crashing on solaris with a null pointer access in printf;
don't crash when current_module is not set.
- CWX, CWY, CWWidth, CWHeight are invalid attributes for CreateWindow, they
should be used with ConfigureWindow only. (Note: their definition is
equivalent to CWBackPixmap, CWBackPixel, CWBorderPixmap, CWBorderPixel)
author | jkeil |
---|---|
date | Sat, 19 Oct 2002 19:47:16 +0000 |
parents | 27c9c440536f |
children | 037982e833a7 |
rev | line source |
---|---|
1693 | 1 |
2 // -------------------------------------------------------------------------- | |
3 // AutoSpace Window System for Linux/Win32 v0.85 | |
4 // Writed by pontscho/fresh!mindworkz | |
5 // -------------------------------------------------------------------------- | |
6 | |
7 #include <X11/Xlib.h> | |
8 #include <X11/Xproto.h> | |
9 #include <X11/Xutil.h> | |
10 #include <X11/keysym.h> | |
11 #include <X11/Xatom.h> | |
2081 | 12 |
13 #include <stdio.h> | |
1693 | 14 #include <stdlib.h> |
2081 | 15 #include <string.h> |
16 #include <unistd.h> | |
17 #include <errno.h> | |
1693 | 18 |
2733 | 19 #include <inttypes.h> |
20 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4566
diff
changeset
|
21 #include "../../config.h" |
1693 | 22 #include "ws.h" |
6967
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
23 #include "wsxdnd.h" |
2733 | 24 #include "../../postproc/rgb2rgb.h" |
5919 | 25 #include "../../mp_msg.h" |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
26 #include "../../mplayer.h" |
1693 | 27 |
28 #include <X11/extensions/XShm.h> | |
2476 | 29 #ifdef HAVE_XSHAPE |
1693 | 30 #include <X11/extensions/shape.h> |
2476 | 31 #endif |
32 | |
1693 | 33 #include <sys/ipc.h> |
34 #include <sys/shm.h> | |
35 | |
36 typedef struct | |
37 { | |
3054 | 38 unsigned long flags; |
39 unsigned long functions; | |
40 unsigned long decorations; | |
1693 | 41 long input_mode; |
3054 | 42 unsigned long status; |
1693 | 43 } MotifWmHints; |
44 | |
45 Atom wsMotifHints; | |
46 | |
4465 | 47 int wsMaxX = 0; // Screen width. |
48 int wsMaxY = 0; // Screen height. | |
1693 | 49 |
50 Display * wsDisplay; | |
51 int wsScreen; | |
52 Window wsRootWin; | |
53 XEvent wsEvent; | |
54 int wsWindowDepth; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
55 int wsWMType = wsWMUnknown; |
1693 | 56 GC wsHGC; |
57 MotifWmHints wsMotifWmHints; | |
58 Atom wsTextProperlyAtom = None; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
59 int wsLayer = 0; |
1693 | 60 |
61 int wsDepthOnScreen = 0; | |
62 int wsRedMask = 0; | |
63 int wsGreenMask = 0; | |
64 int wsBlueMask = 0; | |
65 int wsOutMask = 0; | |
66 | |
67 int wsTrue = True; | |
68 | |
69 wsTWindow * wsWindowList[5] = { NULL,NULL,NULL,NULL,NULL }; | |
70 int wsWLCount = 0; | |
71 | |
72 unsigned long wsKeyTable[512]; | |
73 | |
74 int wsUseXShm = 1; | |
75 int wsUseXShape = 1; | |
76 | |
77 int XShmGetEventBase( Display* ); | |
78 inline int wsSearch( Window win ); | |
79 | |
7206 | 80 // --- |
81 | |
82 #define PACK_RGB16(r,g,b,pixel) pixel=(b>>3);\ | |
83 pixel<<=6;\ | |
84 pixel|=(g>>2);\ | |
85 pixel<<=5;\ | |
86 pixel|=(r>>3) | |
87 | |
88 #define PACK_RGB15(r,g,b,pixel) pixel=(b>>3);\ | |
89 pixel<<=5;\ | |
90 pixel|=(g>>3);\ | |
91 pixel<<=5;\ | |
92 pixel|=(r>>3) | |
93 | |
94 typedef void(*wsTConvFunc)( const unsigned char * in_pixels, unsigned char * out_pixels, unsigned num_pixels ); | |
95 wsTConvFunc wsConvFunc = NULL; | |
7706 | 96 |
97 void rgb32torgb32( const unsigned char * src, unsigned char * dst,unsigned int src_size ) | |
7206 | 98 { memcpy( dst,src,src_size ); } |
99 | |
100 // --- | |
101 | |
1693 | 102 #define MWM_HINTS_FUNCTIONS (1L << 0) |
103 #define MWM_HINTS_DECORATIONS (1L << 1) | |
104 #define MWM_HINTS_INPUT_MODE (1L << 2) | |
105 #define MWM_HINTS_STATUS (1L << 3) | |
106 | |
107 #define MWM_FUNC_ALL (1L << 0) | |
108 #define MWM_FUNC_RESIZE (1L << 1) | |
109 #define MWM_FUNC_MOVE (1L << 2) | |
110 #define MWM_FUNC_MINIMIZE (1L << 3) | |
111 #define MWM_FUNC_MAXIMIZE (1L << 4) | |
112 #define MWM_FUNC_CLOSE (1L << 5) | |
113 | |
114 #define MWM_DECOR_ALL (1L << 0) | |
115 #define MWM_DECOR_BORDER (1L << 1) | |
116 #define MWM_DECOR_RESIZEH (1L << 2) | |
117 #define MWM_DECOR_TITLE (1L << 3) | |
118 #define MWM_DECOR_MENU (1L << 4) | |
119 #define MWM_DECOR_MINIMIZE (1L << 5) | |
120 #define MWM_DECOR_MAXIMIZE (1L << 6) | |
121 | |
122 #define MWM_INPUT_MODELESS 0 | |
123 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 | |
124 #define MWM_INPUT_SYSTEM_MODAL 2 | |
125 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 | |
126 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL | |
127 | |
128 #define MWM_TEAROFF_WINDOW (1L<<0) | |
129 | |
130 void wsWindowDecoration( wsTWindow * win,long d ) | |
131 { | |
132 wsMotifHints=XInternAtom( wsDisplay,"_MOTIF_WM_HINTS",0 ); | |
3054 | 133 if ( wsMotifHints == None ) return; |
134 | |
135 memset( &wsMotifWmHints,0,sizeof( MotifWmHints ) ); | |
5031 | 136 wsMotifWmHints.flags=MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; |
137 if ( d ) | |
138 { | |
139 wsMotifWmHints.functions=MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; | |
140 wsMotifWmHints.decorations=MWM_DECOR_ALL; | |
141 } | |
3054 | 142 XChangeProperty( wsDisplay,win->WindowID,wsMotifHints,wsMotifHints,32, |
143 PropModeReplace,(unsigned char *)&wsMotifWmHints,5 ); | |
1693 | 144 } |
145 | |
146 // ---------------------------------------------------------------------------------------------- | |
147 // Init X Window System. | |
148 // ---------------------------------------------------------------------------------------------- | |
149 | |
150 int wsIOErrorHandler( Display * dpy ) | |
151 { | |
152 fprintf( stderr,"[ws] io error in display.\n" ); | |
153 exit( 0 ); | |
154 } | |
155 | |
156 int wsErrorHandler( Display * dpy,XErrorEvent * Event ) | |
157 { | |
158 char type[128]; | |
159 XGetErrorText( wsDisplay,Event->error_code,type,128 ); | |
160 fprintf(stderr,"[ws] Error in display.\n"); | |
161 fprintf(stderr,"[ws] Error code: %d ( %s )\n",Event->error_code,type ); | |
162 fprintf(stderr,"[ws] Request code: %d\n",Event->request_code ); | |
163 fprintf(stderr,"[ws] Minor code: %d\n",Event->minor_code ); | |
7801
48b7d7fd7075
- wsErrorHandler was crashing on solaris with a null pointer access in printf;
jkeil
parents:
7751
diff
changeset
|
164 fprintf(stderr,"[ws] Modules: %s\n",current_module?current_module:"(NULL)" ); |
1693 | 165 exit( 0 ); |
166 } | |
167 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
168 int wsWindowManagerType( void ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
169 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
170 Atom type; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
171 int format; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
172 unsigned long nitems, bytesafter; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
173 unsigned char * args = NULL; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
174 |
6009 | 175 Window win; |
176 XEvent xev; | |
177 int c = 0; | |
178 int wm = wsWMUnknown; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
179 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
180 // --- gnome |
6089 | 181 /* |
6009 | 182 type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False ); |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
183 if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( int32_t ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 ) |
6009 | 184 { |
185 mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is Gnome\n" ); | |
186 XFree( args ); | |
187 return wsWMGnome; | |
188 } | |
6089 | 189 */ |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
190 // --- net wm |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
191 type=XInternAtom( wsDisplay,"_NET_SUPPORTED",False ); |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
192 if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( int32_t ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
193 { |
6009 | 194 mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is NetWM\n" ); |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
195 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
196 return wsWMNetWM; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
197 } |
6009 | 198 |
199 // --- other wm | |
200 mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Create window for WM detect ...\n" ); | |
201 win=XCreateSimpleWindow( wsDisplay,wsRootWin,wsMaxX,wsMaxY,1,1,0,0,0 ); | |
202 XSelectInput( wsDisplay,win,PropertyChangeMask | StructureNotifyMask ); | |
203 XMapWindow( wsDisplay,win ); | |
204 XMoveWindow( wsDisplay,win,wsMaxX,wsMaxY ); | |
205 do | |
206 { | |
207 XCheckWindowEvent( wsDisplay,win,PropertyChangeMask | StructureNotifyMask,&xev ); | |
208 | |
209 if ( xev.type == PropertyNotify ) | |
210 { | |
211 char * name = XGetAtomName( wsDisplay,xev.xproperty.atom ); | |
212 if ( !name ) break; | |
213 | |
214 if ( !strncmp( name,"_ICEWM_TRAY",11 ) ) | |
215 { mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is IceWM.\n" ); wm=wsWMIceWM; break; } | |
216 if ( !strncmp( name,"_KDE_",5 ) ) | |
217 { mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is KDE.\n" ); wm=wsWMKDE; break; } | |
218 if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) ) | |
219 { mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is WindowMaker style.\n" ); wm=wsWMWMaker; break; } | |
220 // fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",win,name,xev.xproperty.atom ); | |
221 XFree( name ); | |
222 } | |
223 } while( c++ < 25 ); | |
6089 | 224 XUnmapWindow( wsDisplay,win ); |
6009 | 225 XDestroyWindow( wsDisplay,win ); |
226 #ifdef MP_DEBUG | |
227 if ( wm == wsWMUnknown ) mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Unknown wm type...\n" ); | |
228 #endif | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
229 return wsWMUnknown; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
230 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
231 |
6089 | 232 extern int vo_wm_type; |
233 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1709
diff
changeset
|
234 void wsXInit( void* mDisplay ) |
1693 | 235 { |
236 int eventbase; | |
237 int errorbase; | |
238 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1709
diff
changeset
|
239 if(mDisplay){ |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1709
diff
changeset
|
240 wsDisplay=mDisplay; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1709
diff
changeset
|
241 } else { |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1709
diff
changeset
|
242 char * DisplayName = ":0.0"; |
1693 | 243 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" ); |
244 wsDisplay=XOpenDisplay( DisplayName ); | |
245 if ( !wsDisplay ) | |
246 { | |
5919 | 247 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] couldn't open the display !\n" ); |
1693 | 248 exit( 0 ); |
249 } | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1709
diff
changeset
|
250 } |
1693 | 251 |
6967
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
252 /* enable DND atoms */ |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
253 wsXDNDInitialize(); |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
254 |
1838 | 255 { /* on remote display XShm will be disabled - LGB */ |
256 char *dispname=DisplayString(wsDisplay); | |
257 int localdisp=1; | |
258 if (dispname&&*dispname!=':') { | |
259 localdisp=0; | |
260 wsUseXShm=0; | |
261 } | |
5919 | 262 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Display name: %s => %s display.\n",dispname,localdisp?"local":"REMOTE"); |
263 if (!localdisp) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Remote display, disabling XMITSHM\n"); | |
1838 | 264 } |
265 | |
1693 | 266 if ( !XShmQueryExtension( wsDisplay ) ) |
267 { | |
5919 | 268 mp_msg( MSGT_GPLAYER,MSGL_ERR,"[ws] sorry, your system is not supported X shared memory extension.\n" ); |
1693 | 269 wsUseXShm=0; |
270 } | |
1699 | 271 #ifdef HAVE_XSHAPE |
1693 | 272 if ( !XShapeQueryExtension( wsDisplay,&eventbase,&errorbase ) ) |
273 { | |
5919 | 274 mp_msg( MSGT_GPLAYER,MSGL_ERR,"[ws] sorry, your system is not supported XShape extension.\n" ); |
1693 | 275 wsUseXShape=0; |
276 } | |
1699 | 277 #else |
1693 | 278 wsUseXShape=0; |
1699 | 279 #endif |
1693 | 280 |
281 XSynchronize( wsDisplay,True ); | |
282 | |
283 wsScreen=DefaultScreen( wsDisplay ); | |
284 wsRootWin=RootWindow( wsDisplay,wsScreen ); | |
285 wsMaxX=DisplayWidth( wsDisplay,wsScreen ); | |
286 wsMaxY=DisplayHeight( wsDisplay,wsScreen ); | |
287 | |
6089 | 288 if ( vo_wm_type != -1 ) wsWMType=vo_wm_type; |
289 else wsWMType=wsWindowManagerType(); | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
290 |
1693 | 291 wsGetDepthOnScreen(); |
1699 | 292 #ifdef DEBUG |
1693 | 293 { |
294 int minor,major,shp; | |
5919 | 295 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Screen depth: %d\n",wsDepthOnScreen ); |
296 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] size: %dx%d\n",wsMaxX,wsMaxY ); | |
297 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] red mask: 0x%x\n",wsRedMask ); | |
298 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] green mask: 0x%x\n",wsGreenMask ); | |
299 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] blue mask: 0x%x\n",wsBlueMask ); | |
1693 | 300 if ( wsUseXShm ) |
301 { | |
302 XShmQueryVersion( wsDisplay,&major,&minor,&shp ); | |
5919 | 303 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] XShm version is %d.%d\n",major,minor ); |
1693 | 304 } |
305 #ifdef HAVE_XSHAPE | |
306 if ( wsUseXShape ) | |
307 { | |
308 XShapeQueryVersion( wsDisplay,&major,&minor ); | |
5919 | 309 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[ws] XShape version is %d.%d\n",major,minor ); |
1693 | 310 } |
311 #endif | |
312 } | |
1699 | 313 #endif |
1693 | 314 wsOutMask=wsGetOutMask(); |
5919 | 315 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] Initialized converter: " ); |
1693 | 316 switch ( wsOutMask ) |
317 { | |
318 case wsRGB32: | |
5919 | 319 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb32\n" ); |
7206 | 320 wsConvFunc=rgb32torgb32; |
1693 | 321 break; |
322 case wsBGR32: | |
5919 | 323 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr32\n" ); |
2782 | 324 wsConvFunc=rgb32tobgr32; |
1693 | 325 break; |
326 case wsRGB24: | |
5919 | 327 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb24\n" ); |
2733 | 328 wsConvFunc=rgb32to24; |
1693 | 329 break; |
330 case wsBGR24: | |
5919 | 331 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr24\n" ); |
7206 | 332 wsConvFunc=rgb32tobgr24; |
1693 | 333 break; |
334 case wsRGB16: | |
5919 | 335 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb16\n" ); |
2733 | 336 wsConvFunc=rgb32to16; |
1693 | 337 break; |
338 case wsBGR16: | |
5919 | 339 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr16\n" ); |
7206 | 340 wsConvFunc=rgb32tobgr16; |
1693 | 341 break; |
342 case wsRGB15: | |
5919 | 343 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to rgb15\n" ); |
2733 | 344 wsConvFunc=rgb32to15; |
1693 | 345 break; |
346 case wsBGR15: | |
5919 | 347 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"rgb32 to bgr15\n" ); |
7206 | 348 wsConvFunc=rgb32tobgr15; |
1693 | 349 break; |
350 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
351 XSetErrorHandler( wsErrorHandler ); |
1693 | 352 } |
353 | |
354 // ---------------------------------------------------------------------------------------------- | |
355 // Create window. | |
356 // X,Y : window position | |
357 // wX,wY : size of window | |
358 // bW : border width | |
359 // cV : visible mouse cursor on window | |
360 // D : visible frame, title, etc. | |
361 // sR : screen ratio | |
362 // ---------------------------------------------------------------------------------------------- | |
363 | |
364 XClassHint wsClassHint; | |
365 XTextProperty wsTextProperty; | |
366 Window LeaderWindow; | |
367 | |
368 void wsCreateWindow( wsTWindow * win,int X,int Y,int wX,int hY,int bW,int cV,unsigned char D,char * label ) | |
369 { | |
370 win->Property=D; | |
371 if ( D & wsShowFrame ) win->Decorations=1; | |
372 wsHGC=DefaultGC( wsDisplay,wsScreen ); | |
373 // The window position and size. | |
374 switch ( X ) | |
375 { | |
376 case -1: win->X=( wsMaxX / 2 ) - ( wX / 2 ); break; | |
377 case -2: win->X=wsMaxX - wX - 1; break; | |
378 default: win->X=X; break; | |
379 } | |
380 switch ( Y ) | |
381 { | |
382 case -1: win->Y=( wsMaxY / 2 ) - ( hY / 2 ); break; | |
383 case -2: win->Y=wsMaxY - hY - 1; break; | |
384 default: win->Y=Y; break; | |
385 } | |
386 win->Width=wX; | |
387 win->Height=hY; | |
388 win->OldX=win->X; | |
389 win->OldY=win->Y; | |
390 win->OldWidth=win->Width; | |
391 win->OldHeight=win->Height; | |
392 | |
393 // Border size for window. | |
394 win->BorderWidth=bW; | |
395 // Hide Mouse Cursor | |
396 win->wsCursor=None; | |
397 win->wsMouseEventType=cV; | |
398 win->wsCursorData[0]=0; | |
399 win->wsCursorPixmap=XCreateBitmapFromData( wsDisplay,wsRootWin,win->wsCursorData,1,1 ); | |
400 if ( !(cV & wsShowMouseCursor) ) win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 ); | |
401 | |
402 XGetWindowAttributes( wsDisplay,wsRootWin,&win->Attribs ); | |
403 if ( win->Attribs.depth < 15 ) | |
404 { | |
5919 | 405 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, this color depth is not enough.\n" ); |
1693 | 406 exit( 0 ); |
407 } | |
408 XMatchVisualInfo( wsDisplay,wsScreen,win->Attribs.depth,TrueColor,&win->VisualInfo ); | |
409 | |
410 // --- | |
411 win->AtomLeaderClient=XInternAtom( wsDisplay,"WM_CLIENT_LEADER",False ); | |
412 win->AtomDeleteWindow=XInternAtom( wsDisplay,"WM_DELETE_WINDOW",False ); | |
413 win->AtomTakeFocus=XInternAtom( wsDisplay,"WM_TAKE_FOCUS",False ); | |
414 win->AtomRolle=XInternAtom( wsDisplay,"WM_WINDOW_ROLE",False ); | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
415 win->AtomWMSizeHint=XInternAtom( wsDisplay,"WM_SIZE_HINT",False ); |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
416 win->AtomWMNormalHint=XInternAtom( wsDisplay,"WM_NORMAL_HINT",False ); |
1693 | 417 win->AtomProtocols=XInternAtom( wsDisplay,"WM_PROTOCOLS",False ); |
418 win->AtomsProtocols[0]=win->AtomDeleteWindow; | |
419 win->AtomsProtocols[1]=win->AtomTakeFocus; | |
420 win->AtomsProtocols[2]=win->AtomRolle; | |
421 // --- | |
422 | |
423 win->WindowAttrib.background_pixel=BlackPixel( wsDisplay,wsScreen ); | |
424 win->WindowAttrib.border_pixel=WhitePixel( wsDisplay,wsScreen ); | |
425 win->WindowAttrib.colormap=XCreateColormap( wsDisplay,wsRootWin,win->VisualInfo.visual,AllocNone ); | |
426 win->WindowAttrib.event_mask=StructureNotifyMask | FocusChangeMask | | |
427 ExposureMask | PropertyChangeMask | | |
428 EnterWindowMask | LeaveWindowMask | | |
429 VisibilityChangeMask | | |
430 KeyPressMask | KeyReleaseMask; | |
431 if ( ( cV & wsHandleMouseButton ) ) win->WindowAttrib.event_mask|=ButtonPressMask | ButtonReleaseMask; | |
432 if ( ( cV & wsHandleMouseMove ) ) win->WindowAttrib.event_mask|=PointerMotionMask; | |
433 win->WindowAttrib.cursor=win->wsCursor; | |
434 win->WindowAttrib.override_redirect=False; | |
435 if ( D & wsOverredirect ) win->WindowAttrib.override_redirect=True; | |
436 | |
437 win->WindowMask=CWBackPixel | CWBorderPixel | | |
438 CWColormap | CWEventMask | CWCursor | | |
439 CWOverrideRedirect; | |
440 | |
441 win->WindowID=XCreateWindow( wsDisplay, | |
442 (win->Parent != 0?win->Parent:wsRootWin), | |
443 win->X,win->Y,win->Width,win->Height,win->BorderWidth, | |
444 win->VisualInfo.depth, | |
445 InputOutput, | |
446 win->VisualInfo.visual, | |
447 win->WindowMask,&win->WindowAttrib ); | |
448 | |
4411 | 449 wsClassHint.res_name="MPlayer"; |
450 | |
2029 | 451 wsClassHint.res_class="MPlayer"; |
1693 | 452 XSetClassHint( wsDisplay,win->WindowID,&wsClassHint ); |
453 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
454 win->SizeHint.flags=PPosition | PSize | PResizeInc | PWinGravity;// | PBaseSize; |
1693 | 455 win->SizeHint.x=win->X; |
456 win->SizeHint.y=win->Y; | |
457 win->SizeHint.width=win->Width; | |
458 win->SizeHint.height=win->Height; | |
5986 | 459 |
1860 | 460 if ( D & wsMinSize ) |
461 { | |
462 win->SizeHint.flags|=PMinSize; | |
463 win->SizeHint.min_width=win->Width; | |
464 win->SizeHint.min_height=win->Height; | |
465 } | |
1693 | 466 if ( D & wsMaxSize ) |
467 { | |
468 win->SizeHint.flags|=PMaxSize; | |
469 win->SizeHint.max_width=win->Width; | |
470 win->SizeHint.max_height=win->Height; | |
471 } | |
5986 | 472 |
1693 | 473 win->SizeHint.height_inc=1; |
474 win->SizeHint.width_inc=1; | |
5919 | 475 win->SizeHint.base_width=win->Width; |
476 win->SizeHint.base_height=win->Height; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
477 win->SizeHint.win_gravity=StaticGravity; |
1693 | 478 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
479 | |
480 win->WMHints.flags=InputHint | StateHint; | |
481 win->WMHints.input=True; | |
482 win->WMHints.initial_state=NormalState; | |
483 XSetWMHints( wsDisplay,win->WindowID,&win->WMHints ); | |
484 | |
485 wsWindowDecoration( win,win->Decorations ); | |
486 XStoreName( wsDisplay,win->WindowID,label ); | |
487 XmbSetWMProperties( wsDisplay,win->WindowID,label,label,NULL,0,NULL,NULL,NULL ); | |
488 | |
489 XSetWMProtocols( wsDisplay,win->WindowID,win->AtomsProtocols,3 ); | |
490 XChangeProperty( wsDisplay,win->WindowID, | |
491 win->AtomLeaderClient, | |
492 XA_WINDOW,32,PropModeReplace, | |
493 (unsigned char *)&LeaderWindow,1 ); | |
494 | |
495 wsTextProperty.value=label; | |
496 wsTextProperty.encoding=XA_STRING; | |
497 wsTextProperty.format=8; | |
498 wsTextProperty.nitems=strlen( label ); | |
499 XSetWMIconName( wsDisplay,win->WindowID,&wsTextProperty ); | |
500 | |
501 win->wGC=XCreateGC( wsDisplay,win->WindowID, | |
1814 | 502 GCForeground | GCBackground, |
1693 | 503 &win->wGCV ); |
504 | |
505 win->Visible=0; | |
506 win->Focused=0; | |
507 win->Mapped=0; | |
508 win->Rolled=0; | |
509 if ( D & wsShowWindow ) XMapWindow( wsDisplay,win->WindowID ); | |
510 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
511 wsCreateImage( win,win->Width,win->Height ); |
1693 | 512 // --- End of creating -------------------------------------------------------------------------- |
513 | |
514 wsWindowList[wsWLCount++]=win; | |
515 | |
516 XFlush( wsDisplay ); | |
517 XSync( wsDisplay,False ); | |
518 | |
519 win->ReDraw=NULL; | |
520 win->ReSize=NULL; | |
521 win->Idle=NULL; | |
522 win->MouseHandler=NULL; | |
523 win->KeyHandler=NULL; | |
5919 | 524 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] window is created. ( %s ).\n",label ); |
1693 | 525 } |
526 | |
527 void wsDestroyWindow( wsTWindow * win ) | |
528 { | |
529 int l; | |
530 l=wsSearch( win->WindowID ); | |
531 wsWindowList[l]=NULL; | |
532 if ( win->wsCursor != None ) | |
533 { | |
534 XFreeCursor( wsDisplay,win->wsCursor ); | |
535 win->wsCursor=None; | |
536 } | |
537 XUnmapWindow( wsDisplay,win->WindowID ); | |
538 wsDestroyImage( win ); | |
539 XDestroyWindow( wsDisplay,win->WindowID ); | |
540 win->ReDraw=NULL; | |
541 win->ReSize=NULL; | |
542 win->Idle=NULL; | |
543 win->MouseHandler=NULL; | |
544 win->KeyHandler=NULL; | |
545 win->Visible=0; | |
546 win->Focused=0; | |
547 win->Mapped=0; | |
548 win->Rolled=0; | |
549 } | |
550 | |
551 // ---------------------------------------------------------------------------------------------- | |
552 // Handle events. | |
553 // ---------------------------------------------------------------------------------------------- | |
554 | |
555 inline int wsSearch( Window win ) | |
556 { | |
557 int i; | |
558 for ( i=0;i<wsWLCount;i++ ) if ( wsWindowList[i]->WindowID == win ) return i; | |
559 return -1; | |
560 } | |
561 | |
562 Bool wsEvents( Display * display,XEvent * Event,XPointer arg ) | |
563 { | |
564 unsigned long i = 0; | |
565 int l; | |
566 int x,y; | |
567 Window child_window = 0; | |
568 | |
569 l=wsSearch( Event->xany.window ); | |
570 if ( l == -1 ) return !wsTrue; | |
1782 | 571 wsWindowList[l]->State=0; |
1693 | 572 switch( Event->type ) |
573 { | |
574 case ClientMessage: | |
575 if ( Event->xclient.message_type == wsWindowList[l]->AtomProtocols ) | |
576 { | |
7751 | 577 if ( (Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow ) |
5919 | 578 { i=wsWindowClosed; goto expose; } |
7751 | 579 if ( (Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus ) |
1693 | 580 { i=wsWindowFocusIn; wsWindowList[l]->Focused=wsFocused; goto expose; } |
7751 | 581 if ( (Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomRolle ) |
5919 | 582 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] rolled.\n" ); } |
6967
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
583 } else { |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
584 /* try to process DND events */ |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
585 wsXDNDProcessClientMessage(wsWindowList[l],&Event->xclient); |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
586 } |
1693 | 587 break; |
588 | |
589 case MapNotify: i=wsWindowMapped; wsWindowList[l]->Mapped=wsMapped; goto expose; | |
590 case UnmapNotify: i=wsWindowUnmapped; wsWindowList[l]->Mapped=wsNone; goto expose; | |
591 case FocusIn: | |
592 if ( wsWindowList[l]->Focused == wsFocused ) break; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
593 i=wsWindowFocusIn; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
594 wsWindowList[l]->Focused=wsFocused; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
595 goto expose; |
1693 | 596 case FocusOut: |
597 if ( wsWindowList[l]->Focused == wsNone ) break; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
598 i=wsWindowFocusOut; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
599 wsWindowList[l]->Focused=wsNone; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
600 goto expose; |
1693 | 601 case VisibilityNotify: |
602 switch( Event->xvisibility.state ) | |
603 { | |
604 case VisibilityUnobscured: i=wsWindowVisible; wsWindowList[l]->Visible=wsVisible; goto expose; | |
605 case VisibilityFullyObscured: i=wsWindowNotVisible; wsWindowList[l]->Visible=wsNotVisible; goto expose; | |
606 case VisibilityPartiallyObscured: i=wsWindowPartialVisible; wsWindowList[l]->Visible=wsPVisible; goto expose; | |
607 } | |
608 expose: | |
609 wsWindowList[l]->State=i; | |
610 if ( wsWindowList[l]->ReDraw ) wsWindowList[l]->ReDraw( wsDisplay,Event->xany.window ); | |
611 break; | |
612 | |
613 case Expose: | |
614 wsWindowList[l]->State=wsWindowExpose; | |
615 if ( ( wsWindowList[l]->ReDraw )&&( !Event->xexpose.count ) ) wsWindowList[l]->ReDraw( wsDisplay,Event->xany.window ); | |
616 break; | |
617 | |
618 case ConfigureNotify: | |
619 XTranslateCoordinates( wsDisplay,wsWindowList[l]->WindowID,wsRootWin,0,0,&x,&y,&child_window ); | |
620 if ( ( wsWindowList[l]->X != x )||( wsWindowList[l]->Y != y )||( wsWindowList[l]->Width != Event->xconfigure.width )||( wsWindowList[l]->Height != Event->xconfigure.height ) ) | |
621 { | |
622 wsWindowList[l]->X=x; wsWindowList[l]->Y=y; | |
623 wsWindowList[l]->Width=Event->xconfigure.width; wsWindowList[l]->Height=Event->xconfigure.height; | |
624 if ( wsWindowList[l]->ReSize ) wsWindowList[l]->ReSize( wsWindowList[l]->X,wsWindowList[l]->Y,wsWindowList[l]->Width,wsWindowList[l]->Height ); | |
625 } | |
626 | |
627 wsWindowList[l]->Rolled=wsNone; | |
628 if ( Event->xconfigure.y < 0 ) | |
629 { i=wsWindowRolled; wsWindowList[l]->Rolled=wsRolled; goto expose; } | |
630 | |
631 break; | |
632 | |
633 case KeyPress: i=wsKeyPressed; goto keypressed; | |
634 case KeyRelease: i=wsKeyReleased; | |
635 keypressed: | |
636 wsWindowList[l]->Alt=0; | |
637 wsWindowList[l]->Shift=0; | |
638 wsWindowList[l]->NumLock=0; | |
639 wsWindowList[l]->Control=0; | |
640 wsWindowList[l]->CapsLock=0; | |
641 if ( Event->xkey.state & Mod1Mask ) wsWindowList[l]->Alt=1; | |
642 if ( Event->xkey.state & Mod2Mask ) wsWindowList[l]->NumLock=1; | |
643 if ( Event->xkey.state & ControlMask ) wsWindowList[l]->Control=1; | |
644 if ( Event->xkey.state & ShiftMask ) wsWindowList[l]->Shift=1; | |
645 if ( Event->xkey.state & LockMask ) wsWindowList[l]->CapsLock=1; | |
6089 | 646 #if 0 |
6183
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
647 { |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
648 KeySym keySym; |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
649 keySym=XKeycodeToKeysym( wsDisplay,Event->xkey.keycode,0 ); |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
650 if ( keySym != NoSymbol ) |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
651 { |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
652 keySym=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ); |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
653 wsKeyTable[ keySym ]=i; |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
654 if ( wsWindowList[l]->KeyHandler ) |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
655 wsWindowList[l]->KeyHandler( Event->xkey.state,i,keySym ); |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
656 } |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
657 } |
6089 | 658 #else |
659 { | |
660 int key; | |
661 char buf[100]; | |
662 KeySym keySym; | |
663 static XComposeStatus stat; | |
664 | |
665 XLookupString( &Event->xkey,buf,sizeof(buf),&keySym,&stat ); | |
666 key=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ); | |
667 wsKeyTable[ key ]=i; | |
6183
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
668 if ( wsWindowList[l]->KeyHandler ) wsWindowList[l]->KeyHandler( Event->xkey.keycode,i,key ); |
6089 | 669 } |
670 #endif | |
1693 | 671 break; |
672 | |
673 case MotionNotify: i=wsMoveMouse; goto buttonreleased; | |
674 case ButtonRelease: i=Event->xbutton.button + 128; goto buttonreleased; | |
675 case ButtonPress: i=Event->xbutton.button; goto buttonreleased; | |
676 case EnterNotify: i=wsEnterWindow; goto buttonreleased; | |
677 case LeaveNotify: i=wsLeaveWindow; | |
678 buttonreleased: | |
679 if ( wsWindowList[l]->MouseHandler ) | |
680 wsWindowList[l]->MouseHandler( i,Event->xbutton.x,Event->xbutton.y,Event->xmotion.x_root,Event->xmotion.y_root ); | |
681 break; | |
682 | |
683 case PropertyNotify: | |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
684 { |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
685 char * name = XGetAtomName( wsDisplay,Event->xproperty.atom ); |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
686 |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
687 if ( !name ) break; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
688 if ( !strncmp( name,"_ICEWM_TRAY",11 ) ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
689 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
690 wsWMType=wsWMIceWM; |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
691 // mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is IceWM.\n" ); |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
692 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
693 if ( !strncmp( name,"_KDE_",5 ) ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
694 { |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
695 // mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is KDE.\n" ); |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
696 wsWMType=wsWMKDE; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
697 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
698 if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
699 { |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
700 // mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is WindowMaker style.\n" ); |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
701 wsWMType=wsWMWMaker; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
702 } |
5919 | 703 |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
704 // fprintf(stderr,"[ws] PropertyNotify %s ( 0x%x )\n",name,Event->xproperty.atom ); |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
705 |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
706 XFree( name ); |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
707 } |
1693 | 708 break; |
709 | |
6967
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
710 case SelectionNotify: |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
711 /* Handle DandD */ |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
712 wsXDNDProcessSelection(wsWindowList[l],Event); |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
713 break; |
1693 | 714 } |
715 XFlush( wsDisplay ); | |
716 XSync( wsDisplay,False ); | |
717 return !wsTrue; | |
718 } | |
719 | |
720 Bool wsDummyEvents( Display * display,XEvent * Event,XPointer arg ) | |
721 { return True; } | |
722 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4566
diff
changeset
|
723 void wsHandleEvents( void ){ |
1709 | 724 // handle pending events |
725 while ( XPending(wsDisplay) ){ | |
726 XNextEvent( wsDisplay,&wsEvent ); | |
727 // printf("### X event: %d [%d]\n",wsEvent.type,delay); | |
728 wsEvents( wsDisplay,&wsEvent,NULL ); | |
729 } | |
730 } | |
731 | |
1693 | 732 void wsMainLoop( void ) |
733 { | |
1699 | 734 int delay=20; |
5919 | 735 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] init threads: %d\n",XInitThreads() ); |
1693 | 736 XSynchronize( wsDisplay,False ); |
737 XLockDisplay( wsDisplay ); | |
738 // XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL ); | |
1699 | 739 |
740 #if 1 | |
741 | |
742 while(wsTrue){ | |
743 // handle pending events | |
744 while ( XPending(wsDisplay) ){ | |
745 XNextEvent( wsDisplay,&wsEvent ); | |
746 wsEvents( wsDisplay,&wsEvent,NULL ); | |
1701 | 747 delay=0; |
1699 | 748 } |
749 usleep(delay*1000); // FIXME! | |
1701 | 750 if(delay<10*20) delay+=20; // pump up delay up to 0.2 sec (low activity) |
1699 | 751 } |
752 | |
753 #else | |
754 | |
1693 | 755 while( wsTrue ) |
756 { | |
757 XIfEvent( wsDisplay,&wsEvent,wsDummyEvents,NULL ); | |
758 wsEvents( wsDisplay,&wsEvent,NULL ); | |
759 } | |
1699 | 760 #endif |
761 | |
1693 | 762 XUnlockDisplay( wsDisplay ); |
763 } | |
764 | |
765 // ---------------------------------------------------------------------------------------------- | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
766 // Move window to selected layer |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
767 // ---------------------------------------------------------------------------------------------- |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
768 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
769 #define WIN_LAYER_ONBOTTOM 2 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
770 #define WIN_LAYER_NORMAL 4 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
771 #define WIN_LAYER_ONTOP 6 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
772 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
773 void wsSetLayer( Display * wsDisplay, Window win, int layer ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
774 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
775 Atom type; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
776 int format; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
777 unsigned long nitems, bytesafter; |
7751 | 778 Atom * args = NULL; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
779 |
6034
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
780 if ( wsWMType == wsWMIceWM ) |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
781 { |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
782 switch ( layer ) |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
783 { |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
784 case -1: layer=2; break; // WinLayerBelow |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
785 case 0: layer=4; break; // WinLayerNormal |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
786 case 1: layer=8; break; // WinLayerOnTop |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
787 } |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
788 XChangeProperty( wsDisplay,win, |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
789 XInternAtom( wsDisplay,"_WIN_LAYER",False ),XA_CARDINAL,32,PropModeReplace,(unsigned char *)&layer,1 ); |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
790 return; |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
791 } |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
792 |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
793 type=XInternAtom( wsDisplay,"_NET_SUPPORTED",False ); |
7751 | 794 if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( int32_t ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char **)&args ) && nitems > 0 ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
795 { |
7572 | 796 int i; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
797 XEvent e; |
7572 | 798 |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
799 e.xclient.type=ClientMessage; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
800 e.xclient.message_type=XInternAtom( wsDisplay,"_NET_WM_STATE",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
801 e.xclient.display=wsDisplay; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
802 e.xclient.window=win; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
803 e.xclient.format=32; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
804 e.xclient.data.l[0]=layer; |
7572 | 805 |
7545 | 806 e.xclient.data.l[1]=XInternAtom( wsDisplay,"_NET_WM_STATE_STAYS_ON_TOP",False ); |
7572 | 807 type=XInternAtom( wsDisplay,"_NET_WM_STATE_FULLSCREEN",False ); |
7751 | 808 for ( i=0;(unsigned long)i < nitems;i++ ) |
7572 | 809 if ( args[i] == type ) { e.xclient.data.l[1]=XInternAtom( wsDisplay,"_NET_WM_STATE_FULLSCREEN",False ); break; } |
810 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
811 e.xclient.data.l[2]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
812 e.xclient.data.l[3]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
813 e.xclient.data.l[4]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
814 XSendEvent( wsDisplay,wsRootWin,False,SubstructureRedirectMask,&e ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
815 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
816 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
817 return; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
818 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
819 type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False ); |
7751 | 820 if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( int32_t ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char **)&args ) && nitems > 0 ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
821 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
822 XClientMessageEvent xev; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
823 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
824 memset( &xev,0,sizeof( xev ) ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
825 xev.type=ClientMessage; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
826 xev.window=win; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
827 xev.message_type=XInternAtom( wsDisplay,"_WIN_LAYER",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
828 xev.format=32; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
829 switch ( layer ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
830 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
831 case -1: xev.data.l[0] = WIN_LAYER_ONBOTTOM; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
832 case 0: xev.data.l[0] = WIN_LAYER_NORMAL; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
833 case 1: xev.data.l[0] = WIN_LAYER_ONTOP; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
834 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
835 XSendEvent( wsDisplay,wsRootWin,False,SubstructureNotifyMask,(XEvent*)&xev ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
836 if ( layer ) XRaiseWindow( wsDisplay,win ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
837 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
838 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
839 return; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
840 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
841 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
842 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
843 // ---------------------------------------------------------------------------------------------- |
1693 | 844 // Switch to fullscreen. |
845 // ---------------------------------------------------------------------------------------------- | |
846 void wsFullScreen( wsTWindow * win ) | |
847 { | |
848 int decoration = 0; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
849 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
850 switch ( wsWMType ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
851 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
852 case wsWMUnknown: |
7543 | 853 // XUnmapWindow( wsDisplay,win->WindowID ); |
854 XWithdrawWindow( wsDisplay,win->WindowID,wsScreen ); | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
855 break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
856 case wsWMIceWM: |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
857 if ( !win->isFullScreen ) XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
858 break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
859 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
860 |
1693 | 861 if ( win->isFullScreen ) |
862 { | |
863 win->X=win->OldX; | |
864 win->Y=win->OldY; | |
865 win->Width=win->OldWidth; | |
866 win->Height=win->OldHeight; | |
867 win->isFullScreen=False; | |
868 decoration=win->Decorations; | |
869 wsScreenSaverOn( wsDisplay ); | |
870 } | |
871 else | |
872 { | |
873 win->OldX=win->X; win->OldY=win->Y; | |
874 win->OldWidth=win->Width; win->OldHeight=win->Height; | |
875 win->X=0; win->Y=0; | |
876 win->Width=wsMaxX; win->Height=wsMaxY; | |
877 win->isFullScreen=True; | |
878 wsScreenSaverOff( wsDisplay ); | |
879 } | |
880 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
881 win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize; |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
882 win->SizeHint.x=win->X; win->SizeHint.y=win->Y; |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
883 win->SizeHint.width=win->Width; win->SizeHint.height=win->Height; |
6034
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
884 // win->SizeHint.base_width=win->Width; win->SizeHint.base_height=win->Height; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
885 |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
886 win->SizeHint.win_gravity=StaticGravity; |
1860 | 887 if ( win->Property & wsMaxSize ) |
888 { | |
889 win->SizeHint.flags|=PMaxSize; | |
890 win->SizeHint.max_width=win->Width; | |
891 win->SizeHint.max_height=win->Height; | |
892 } | |
893 if ( win->Property & wsMinSize ) | |
894 { | |
895 win->SizeHint.flags|=PMinSize; | |
896 win->SizeHint.min_width=win->Width; | |
897 win->SizeHint.min_height=win->Height; | |
898 } | |
1693 | 899 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
900 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
901 wsSetLayer( wsDisplay,win->WindowID,win->isFullScreen ); |
1693 | 902 XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height ); |
903 wsWindowDecoration( win,decoration ); | |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
904 XMapRaised( wsDisplay,win->WindowID ); |
1693 | 905 XRaiseWindow( wsDisplay,win->WindowID ); |
906 } | |
907 | |
908 // ---------------------------------------------------------------------------------------------- | |
909 // Redraw screen. | |
910 // ---------------------------------------------------------------------------------------------- | |
911 void wsPostRedisplay( wsTWindow * win ) | |
912 { | |
913 if ( win->ReDraw ) | |
914 { | |
6794 | 915 win->State=wsWindowExpose; |
1693 | 916 win->ReDraw( wsDisplay,win->WindowID ); |
917 XFlush( wsDisplay ); | |
918 } | |
919 } | |
920 | |
921 // ---------------------------------------------------------------------------------------------- | |
922 // Do Exit. | |
923 // ---------------------------------------------------------------------------------------------- | |
924 void wsDoExit( void ) | |
925 { wsTrue=False; wsResizeWindow( wsWindowList[0],32,32 ); } | |
926 | |
927 // ---------------------------------------------------------------------------------------------- | |
928 // Put 'Image' to window. | |
929 // ---------------------------------------------------------------------------------------------- | |
930 void wsConvert( wsTWindow * win,unsigned char * Image,unsigned int Size ) | |
2733 | 931 { if ( wsConvFunc ) wsConvFunc( Image,win->ImageData,win->xImage->width * win->xImage->height * 4 ); } |
1693 | 932 |
933 void wsPutImage( wsTWindow * win ) | |
934 { | |
935 if ( wsUseXShm ) | |
936 { | |
937 XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
938 0,0, | |
939 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
940 win->xImage->width,win->xImage->height,0 ); | |
941 } | |
942 else | |
943 { | |
944 XPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
945 0,0, | |
946 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
947 win->xImage->width,win->xImage->height ); | |
948 } | |
949 } | |
950 | |
951 // ---------------------------------------------------------------------------------------------- | |
952 // Move window to x, y. | |
953 // ---------------------------------------------------------------------------------------------- | |
2854 | 954 void wsMoveWindow( wsTWindow * win,int b,int x, int y ) |
1693 | 955 { |
2854 | 956 if ( b ) |
1693 | 957 { |
2854 | 958 switch ( x ) |
959 { | |
960 case -1: win->X=( wsMaxX / 2 ) - ( win->Width / 2 ); break; | |
961 case -2: win->X=wsMaxX - win->Width; break; | |
962 default: win->X=x; break; | |
963 } | |
964 switch ( y ) | |
965 { | |
966 case -1: win->Y=( wsMaxY / 2 ) - ( win->Height / 2 ); break; | |
967 case -2: win->Y=wsMaxY - win->Height; break; | |
968 default: win->Y=y; break; | |
969 } | |
1693 | 970 } |
2854 | 971 else { win->X=x; win->Y=y; } |
1693 | 972 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
973 win->SizeHint.flags=PPosition | PWinGravity; |
1693 | 974 win->SizeHint.x=win->X; |
975 win->SizeHint.y=win->Y; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
976 win->SizeHint.win_gravity=StaticGravity; |
1693 | 977 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
978 | |
979 XMoveWindow( wsDisplay,win->WindowID,win->X,win->Y ); | |
1810 | 980 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 981 } |
982 | |
983 // ---------------------------------------------------------------------------------------------- | |
984 // Resize window to sx, sy. | |
985 // ---------------------------------------------------------------------------------------------- | |
986 void wsResizeWindow( wsTWindow * win,int sx, int sy ) | |
987 { | |
988 win->Width=sx; | |
989 win->Height=sy; | |
990 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
991 win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize; |
5986 | 992 win->SizeHint.x=win->X; |
993 win->SizeHint.y=win->Y; | |
1693 | 994 win->SizeHint.width=win->Width; |
995 win->SizeHint.height=win->Height; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
996 |
1693 | 997 if ( win->Property & wsMinSize ) |
998 { | |
999 win->SizeHint.flags|=PMinSize; | |
1000 win->SizeHint.min_width=win->Width; | |
1001 win->SizeHint.min_height=win->Height; | |
1002 } | |
1003 if ( win->Property & wsMaxSize ) | |
1004 { | |
1005 win->SizeHint.flags|=PMaxSize; | |
1006 win->SizeHint.max_width=win->Width; | |
1007 win->SizeHint.max_height=win->Height; | |
1008 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1009 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
1010 win->SizeHint.win_gravity=StaticGravity; |
5986 | 1011 win->SizeHint.base_width=sx; win->SizeHint.base_height=sy; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1012 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1013 if ( wsWMType == wsWMUnknown ) XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1014 |
1693 | 1015 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
1016 XResizeWindow( wsDisplay,win->WindowID,sx,sy ); | |
5986 | 1017 XMapRaised( wsDisplay,win->WindowID ); |
1810 | 1018 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 1019 } |
1020 | |
1021 // ---------------------------------------------------------------------------------------------- | |
1022 // Iconify window. | |
1023 // ---------------------------------------------------------------------------------------------- | |
1024 void wsIconify( wsTWindow win ) | |
1025 { XIconifyWindow( wsDisplay,win.WindowID,0 ); } | |
1026 | |
1027 // ---------------------------------------------------------------------------------------------- | |
1028 // Move top the window. | |
1029 // ---------------------------------------------------------------------------------------------- | |
6146 | 1030 void wsMoveTopWindow( Display * wsDisplay,Window win ) |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
1031 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1032 switch ( wsWMType ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1033 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1034 case wsWMIceWM: |
6146 | 1035 XUnmapWindow( wsDisplay,win ); |
1036 XMapWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1037 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1038 case wsWMNetWM: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1039 case wsWMKDE: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1040 { |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1041 XEvent e; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1042 e.xclient.type=ClientMessage; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1043 e.xclient.message_type=XInternAtom( wsDisplay,"_NET_ACTIVE_WINDOW",False ); |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1044 e.xclient.display=wsDisplay; |
6146 | 1045 e.xclient.window=win; |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1046 e.xclient.format=32; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1047 e.xclient.data.l[0]=0; |
6146 | 1048 XSendEvent( wsDisplay,RootWindow( wsDisplay,DefaultScreen( wsDisplay ) ),False,SubstructureRedirectMask,&e ); |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1049 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1050 } |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1051 default: |
6146 | 1052 XMapRaised( wsDisplay,win ); |
1053 XRaiseWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1054 break; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1055 } |
2045 | 1056 } |
1693 | 1057 |
1058 // ---------------------------------------------------------------------------------------------- | |
1059 // Set window background to 'color'. | |
1060 // ---------------------------------------------------------------------------------------------- | |
1061 void wsSetBackground( wsTWindow * win,int color ) | |
1062 { XSetWindowBackground( wsDisplay,win->WindowID,color ); } | |
1063 | |
1064 void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b ) | |
1065 { | |
1066 int color = 0; | |
1067 switch ( wsOutMask ) | |
1068 { | |
1069 case wsRGB32: | |
1070 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1071 case wsBGR32: | |
1072 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1073 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1074 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1075 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1076 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1693 | 1077 } |
1078 XSetWindowBackground( wsDisplay,win->WindowID,color ); | |
1079 } | |
1080 | |
1814 | 1081 void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b ) |
1082 { | |
1083 int color = 0; | |
1084 switch ( wsOutMask ) | |
1085 { | |
1086 case wsRGB32: | |
1087 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1088 case wsBGR32: | |
1089 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1090 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1091 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1092 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1093 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1814 | 1094 } |
1095 XSetForeground( wsDisplay,win->wGC,color ); | |
1096 } | |
1693 | 1097 |
1098 // ---------------------------------------------------------------------------------------------- | |
1099 // Draw string at x,y with fc ( foreground color ) and bc ( background color ). | |
1100 // ---------------------------------------------------------------------------------------------- | |
1101 void wsDrawString( wsTWindow win,int x,int y,char * str,int fc,int bc ) | |
1102 { | |
1103 XSetForeground( wsDisplay,win.wGC,bc ); | |
1104 XFillRectangle( wsDisplay,win.WindowID,win.wGC,x,y, | |
1105 XTextWidth( win.Font,str,strlen( str ) ) + 20, | |
1106 win.FontHeight + 2 ); | |
1107 XSetForeground( wsDisplay,win.wGC,fc ); | |
1108 XDrawString( wsDisplay,win.WindowID,win.wGC,x + 10,y + 13,str,strlen( str ) ); | |
1109 } | |
1110 | |
1111 // ---------------------------------------------------------------------------------------------- | |
1112 // Calculation string width. | |
1113 // ---------------------------------------------------------------------------------------------- | |
1114 int wsTextWidth( wsTWindow win,char * str ) | |
1115 { return XTextWidth( win.Font,str,strlen( str ) ) + 20; } | |
1116 | |
1117 // ---------------------------------------------------------------------------------------------- | |
1118 // Show / hide mouse cursor. | |
1119 // ---------------------------------------------------------------------------------------------- | |
1120 void wsVisibleMouse( wsTWindow * win,int m ) | |
1121 { | |
1122 switch ( m ) | |
1123 { | |
1124 case wsShowMouseCursor: | |
1125 if ( win->wsCursor != None ) | |
1126 { | |
1127 XFreeCursor( wsDisplay,win->wsCursor ); | |
1128 win->wsCursor=None; | |
1129 } | |
1130 XDefineCursor( wsDisplay,win->WindowID,0 ); | |
1131 break; | |
1132 case wsHideMouseCursor: | |
1133 win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 ); | |
1134 XDefineCursor( wsDisplay,win->WindowID,win->wsCursor ); | |
1135 break; | |
1136 } | |
1137 XFlush( wsDisplay ); | |
1138 } | |
1139 | |
1140 int wsGetDepthOnScreen( void ) | |
1141 { | |
1142 int bpp,ibpp; | |
1143 XImage * mXImage; | |
1144 XWindowAttributes attribs; | |
1145 | |
1146 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1147 bpp=mXImage->bits_per_pixel; | |
1148 | |
1149 XGetWindowAttributes( wsDisplay,wsRootWin,&attribs ); | |
1150 ibpp=attribs.depth; | |
1151 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1152 bpp=mXImage->bits_per_pixel; | |
1153 if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp; | |
1154 wsDepthOnScreen=ibpp; | |
1155 wsRedMask=mXImage->red_mask; | |
1156 wsGreenMask=mXImage->green_mask; | |
1157 wsBlueMask=mXImage->blue_mask; | |
1158 XDestroyImage( mXImage ); | |
1159 return ibpp; | |
1160 } | |
1161 | |
1162 void wsXDone( void ) | |
1163 { | |
1164 XCloseDisplay( wsDisplay ); | |
1165 } | |
1166 | |
1167 void wsVisibleWindow( wsTWindow * win,int show ) | |
1168 { | |
1169 switch( show ) | |
1170 { | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1171 case wsShowWindow: XMapRaised( wsDisplay,win->WindowID ); break; |
1693 | 1172 case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break; |
1173 } | |
1174 XFlush( wsDisplay ); | |
1175 } | |
1176 | |
1177 void wsDestroyImage( wsTWindow * win ) | |
1178 { | |
1179 if ( win->xImage ) | |
1180 { | |
1181 XDestroyImage( win->xImage ); | |
1182 if ( wsUseXShm ) | |
1183 { | |
1184 XShmDetach( wsDisplay,&win->Shminfo ); | |
1185 shmdt( win->Shminfo.shmaddr ); | |
1186 } | |
1187 } | |
1188 win->xImage=NULL; | |
1189 } | |
1190 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1191 void wsCreateImage( wsTWindow * win,int Width,int Height ) |
1693 | 1192 { |
1193 int CompletionType = -1; | |
1194 if ( wsUseXShm ) | |
1195 { | |
1196 CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion; | |
1197 win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual, | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1198 win->Attribs.depth,ZPixmap,NULL,&win->Shminfo,Width,Height ); |
1693 | 1199 if ( win->xImage == NULL ) |
1200 { | |
5919 | 1201 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1202 exit( 0 ); |
1203 } | |
1204 win->Shminfo.shmid=shmget( IPC_PRIVATE,win->xImage->bytes_per_line * win->xImage->height,IPC_CREAT|0777 ); | |
1205 if ( win->Shminfo.shmid < 0 ) | |
1206 { | |
1207 XDestroyImage( win->xImage ); | |
5919 | 1208 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1209 exit( 0 ); |
1210 } | |
1211 win->Shminfo.shmaddr=(char *)shmat( win->Shminfo.shmid,0,0 ); | |
1212 | |
1213 if ( win->Shminfo.shmaddr == ((char *) -1) ) | |
1214 { | |
1215 XDestroyImage( win->xImage ); | |
1216 if ( win->Shminfo.shmaddr != ((char *) -1) ) shmdt( win->Shminfo.shmaddr ); | |
5919 | 1217 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1218 exit( 0 ); |
1219 } | |
1220 win->xImage->data=win->Shminfo.shmaddr; | |
1221 win->Shminfo.readOnly=0; | |
1222 XShmAttach( wsDisplay,&win->Shminfo ); | |
1223 shmctl( win->Shminfo.shmid,IPC_RMID,0 ); | |
1224 } | |
1225 else | |
1226 { | |
1227 win->xImage=XCreateImage( wsDisplay,win->VisualInfo.visual,win->Attribs.depth, | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1228 ZPixmap,0,0,Width,Height, |
1693 | 1229 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen, |
1230 0 ); | |
1231 if ( ( win->xImage->data=malloc( win->xImage->bytes_per_line * win->xImage->height ) ) == NULL ) | |
1232 { | |
5919 | 1233 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, not enough memory for draw buffer.\n" ); |
1693 | 1234 exit( 0 ); |
1235 } | |
1236 } | |
1237 win->ImageData=(unsigned char *)win->xImage->data; | |
1238 win->ImageDataw=(unsigned short int *)win->xImage->data; | |
1239 win->ImageDatadw=(unsigned int *)win->xImage->data; | |
1240 } | |
1241 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1242 void wsResizeImage( wsTWindow * win,int Width,int Height ) |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1243 { wsDestroyImage( win ); wsCreateImage( win,Width,Height ); } |
1693 | 1244 |
1245 int wsGetOutMask( void ) | |
1246 { | |
1247 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB32; | |
1248 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR32; | |
1249 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB24; | |
1250 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR24; | |
1251 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0xf800 )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB16; | |
1252 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0xf800 ) ) return wsBGR16; | |
1253 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x7c00 )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB15; | |
1254 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x7c00 ) ) return wsBGR15; | |
1255 return 0; | |
1256 } | |
1257 | |
1258 void wsSetTitle( wsTWindow * win,char * name ) | |
1259 { XStoreName( wsDisplay,win->WindowID,name ); } | |
1260 | |
1261 void wsSetMousePosition( wsTWindow * win,int x, int y ) | |
1262 { XWarpPointer( wsDisplay,wsRootWin,win->WindowID,0,0,0,0,x,y ); } | |
1263 | |
1264 static int dpms_disabled=0; | |
1265 static int timeout_save=0; | |
1266 | |
1267 void wsScreenSaverOn( Display *mDisplay ) | |
1268 { | |
1269 int nothing; | |
4566 | 1270 #ifdef HAVE_XDPMS |
1693 | 1271 if ( dpms_disabled ) |
1272 { | |
1273 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) | |
1274 { | |
5919 | 1275 if ( !DPMSEnable( mDisplay ) ) mp_msg( MSGT_GPLAYER,MSGL_ERR,"DPMS not available ?\n" ); // restoring power saving settings |
1693 | 1276 else |
1277 { | |
1278 // DPMS does not seem to be enabled unless we call DPMSInfo | |
1279 BOOL onoff; | |
1280 CARD16 state; | |
1281 DPMSInfo( mDisplay,&state,&onoff ); | |
5919 | 1282 if ( onoff ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Successfully enabled DPMS.\n" ); |
1283 else mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Could not enable DPMS.\n" ); | |
1693 | 1284 } |
1285 } | |
1286 } | |
4566 | 1287 #endif |
1693 | 1288 if ( timeout_save ) |
1289 { | |
1290 int dummy, interval, prefer_blank, allow_exp; | |
1291 XGetScreenSaver( mDisplay,&dummy,&interval,&prefer_blank,&allow_exp ); | |
1292 XSetScreenSaver( mDisplay,timeout_save,interval,prefer_blank,allow_exp ); | |
1293 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); | |
1294 } | |
1295 } | |
1296 | |
1297 void wsScreenSaverOff( Display * mDisplay ) | |
1298 { | |
1299 int interval,prefer_blank,allow_exp,nothing; | |
4566 | 1300 #ifdef HAVE_XDPMS |
1693 | 1301 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) |
1302 { | |
1303 BOOL onoff; | |
1304 CARD16 state; | |
1305 DPMSInfo( mDisplay,&state,&onoff ); | |
1306 if ( onoff ) | |
1307 { | |
1308 Status stat; | |
5919 | 1309 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"Disabling DPMS.\n" ); |
1693 | 1310 dpms_disabled=1; |
1311 stat=DPMSDisable( mDisplay ); // monitor powersave off | |
5919 | 1312 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"stat: %d.\n",stat ); |
1693 | 1313 } |
1314 } | |
4566 | 1315 #endif |
1693 | 1316 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); |
1317 if ( timeout_save ) XSetScreenSaver( mDisplay,0,interval,prefer_blank,allow_exp ); // turning off screensaver | |
1318 } | |
1319 | |
1320 void wsSetShape( wsTWindow * win,char * data ) | |
1321 { | |
1322 #ifdef HAVE_XSHAPE | |
1852 | 1323 if ( !wsUseXShape ) return; |
1324 if ( data ) | |
1325 { | |
1326 win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height ); | |
1327 XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet ); | |
1328 XFreePixmap( wsDisplay,win->Mask ); | |
1329 } | |
1330 else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet ); | |
1693 | 1331 #endif |
1332 } | |
1333 | |
6651 | 1334 void wsSetIcon( Display * dsp,Window win,Pixmap icon,Pixmap mask ) |
1335 { | |
1336 XWMHints * wm; | |
1337 long data[2]; | |
1338 Atom iconatom; | |
1339 | |
1340 wm=XGetWMHints( dsp,win ); | |
1341 if ( !wm ) wm=XAllocWMHints(); | |
1342 | |
1343 wm->icon_pixmap=icon; | |
1344 wm->icon_mask=mask; | |
1345 wm->flags|=IconPixmapHint | IconMaskHint; | |
1346 | |
1347 XSetWMHints( dsp,win,wm ); | |
1348 | |
1349 data[0]=icon; | |
1350 data[1]=mask; | |
1351 iconatom=XInternAtom( dsp,"KWM_WIN_ICON",0 ); | |
1352 XChangeProperty( dsp,win,iconatom,iconatom,32,PropModeReplace,(unsigned char *)data,2 ); | |
1353 | |
1354 XFree( wm ); | |
1355 } | |
1356 | |
1693 | 1357 #include "wsmkeys.h" |