Mercurial > mplayer.hg
annotate Gui/wm/ws.c @ 7281:cc40fdbb0154
sis_vid removed
author | jaf |
---|---|
date | Thu, 05 Sep 2002 05:38:52 +0000 |
parents | 09722d199d83 |
children | 18372010145f |
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; | |
96 | |
97 void rgb32torgb32( const unsigned char * src, unsigned char * dst,int src_size ) | |
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 ); | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
164 fprintf(stderr,"[ws] Modules: %s\n",current_module ); |
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 CWX | CWY | CWWidth | CWHeight | | |
440 CWOverrideRedirect; | |
441 | |
442 win->WindowID=XCreateWindow( wsDisplay, | |
443 (win->Parent != 0?win->Parent:wsRootWin), | |
444 win->X,win->Y,win->Width,win->Height,win->BorderWidth, | |
445 win->VisualInfo.depth, | |
446 InputOutput, | |
447 win->VisualInfo.visual, | |
448 win->WindowMask,&win->WindowAttrib ); | |
449 | |
4411 | 450 wsClassHint.res_name="MPlayer"; |
451 | |
2029 | 452 wsClassHint.res_class="MPlayer"; |
1693 | 453 XSetClassHint( wsDisplay,win->WindowID,&wsClassHint ); |
454 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
455 win->SizeHint.flags=PPosition | PSize | PResizeInc | PWinGravity;// | PBaseSize; |
1693 | 456 win->SizeHint.x=win->X; |
457 win->SizeHint.y=win->Y; | |
458 win->SizeHint.width=win->Width; | |
459 win->SizeHint.height=win->Height; | |
5986 | 460 |
1860 | 461 if ( D & wsMinSize ) |
462 { | |
463 win->SizeHint.flags|=PMinSize; | |
464 win->SizeHint.min_width=win->Width; | |
465 win->SizeHint.min_height=win->Height; | |
466 } | |
1693 | 467 if ( D & wsMaxSize ) |
468 { | |
469 win->SizeHint.flags|=PMaxSize; | |
470 win->SizeHint.max_width=win->Width; | |
471 win->SizeHint.max_height=win->Height; | |
472 } | |
5986 | 473 |
1693 | 474 win->SizeHint.height_inc=1; |
475 win->SizeHint.width_inc=1; | |
5919 | 476 win->SizeHint.base_width=win->Width; |
477 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
|
478 win->SizeHint.win_gravity=StaticGravity; |
1693 | 479 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
480 | |
481 win->WMHints.flags=InputHint | StateHint; | |
482 win->WMHints.input=True; | |
483 win->WMHints.initial_state=NormalState; | |
484 XSetWMHints( wsDisplay,win->WindowID,&win->WMHints ); | |
485 | |
486 wsWindowDecoration( win,win->Decorations ); | |
487 XStoreName( wsDisplay,win->WindowID,label ); | |
488 XmbSetWMProperties( wsDisplay,win->WindowID,label,label,NULL,0,NULL,NULL,NULL ); | |
489 | |
490 XSetWMProtocols( wsDisplay,win->WindowID,win->AtomsProtocols,3 ); | |
491 XChangeProperty( wsDisplay,win->WindowID, | |
492 win->AtomLeaderClient, | |
493 XA_WINDOW,32,PropModeReplace, | |
494 (unsigned char *)&LeaderWindow,1 ); | |
495 | |
496 wsTextProperty.value=label; | |
497 wsTextProperty.encoding=XA_STRING; | |
498 wsTextProperty.format=8; | |
499 wsTextProperty.nitems=strlen( label ); | |
500 XSetWMIconName( wsDisplay,win->WindowID,&wsTextProperty ); | |
501 | |
502 win->wGC=XCreateGC( wsDisplay,win->WindowID, | |
1814 | 503 GCForeground | GCBackground, |
1693 | 504 &win->wGCV ); |
505 | |
506 win->Visible=0; | |
507 win->Focused=0; | |
508 win->Mapped=0; | |
509 win->Rolled=0; | |
510 if ( D & wsShowWindow ) XMapWindow( wsDisplay,win->WindowID ); | |
511 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
512 wsCreateImage( win,win->Width,win->Height ); |
1693 | 513 // --- End of creating -------------------------------------------------------------------------- |
514 | |
515 wsWindowList[wsWLCount++]=win; | |
516 | |
517 XFlush( wsDisplay ); | |
518 XSync( wsDisplay,False ); | |
519 | |
520 win->ReDraw=NULL; | |
521 win->ReSize=NULL; | |
522 win->Idle=NULL; | |
523 win->MouseHandler=NULL; | |
524 win->KeyHandler=NULL; | |
5919 | 525 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[ws] window is created. ( %s ).\n",label ); |
1693 | 526 } |
527 | |
528 void wsDestroyWindow( wsTWindow * win ) | |
529 { | |
530 int l; | |
531 l=wsSearch( win->WindowID ); | |
532 wsWindowList[l]=NULL; | |
533 if ( win->wsCursor != None ) | |
534 { | |
535 XFreeCursor( wsDisplay,win->wsCursor ); | |
536 win->wsCursor=None; | |
537 } | |
538 XUnmapWindow( wsDisplay,win->WindowID ); | |
539 wsDestroyImage( win ); | |
540 XDestroyWindow( wsDisplay,win->WindowID ); | |
541 win->ReDraw=NULL; | |
542 win->ReSize=NULL; | |
543 win->Idle=NULL; | |
544 win->MouseHandler=NULL; | |
545 win->KeyHandler=NULL; | |
546 win->Visible=0; | |
547 win->Focused=0; | |
548 win->Mapped=0; | |
549 win->Rolled=0; | |
550 } | |
551 | |
552 // ---------------------------------------------------------------------------------------------- | |
553 // Handle events. | |
554 // ---------------------------------------------------------------------------------------------- | |
555 | |
556 inline int wsSearch( Window win ) | |
557 { | |
558 int i; | |
559 for ( i=0;i<wsWLCount;i++ ) if ( wsWindowList[i]->WindowID == win ) return i; | |
560 return -1; | |
561 } | |
562 | |
563 Bool wsEvents( Display * display,XEvent * Event,XPointer arg ) | |
564 { | |
565 unsigned long i = 0; | |
566 int l; | |
567 int x,y; | |
568 Window child_window = 0; | |
569 | |
570 l=wsSearch( Event->xany.window ); | |
571 if ( l == -1 ) return !wsTrue; | |
1782 | 572 wsWindowList[l]->State=0; |
1693 | 573 switch( Event->type ) |
574 { | |
575 case ClientMessage: | |
576 if ( Event->xclient.message_type == wsWindowList[l]->AtomProtocols ) | |
577 { | |
578 if ( Event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow ) | |
5919 | 579 { i=wsWindowClosed; goto expose; } |
1693 | 580 if ( Event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus ) |
581 { i=wsWindowFocusIn; wsWindowList[l]->Focused=wsFocused; goto expose; } | |
582 if ( Event->xclient.data.l[0] == wsWindowList[l]->AtomRolle ) | |
5919 | 583 { 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
|
584 } else { |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
585 /* 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
|
586 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
|
587 } |
1693 | 588 break; |
589 | |
590 case MapNotify: i=wsWindowMapped; wsWindowList[l]->Mapped=wsMapped; goto expose; | |
591 case UnmapNotify: i=wsWindowUnmapped; wsWindowList[l]->Mapped=wsNone; goto expose; | |
592 case FocusIn: | |
593 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
|
594 i=wsWindowFocusIn; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
595 wsWindowList[l]->Focused=wsFocused; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
596 goto expose; |
1693 | 597 case FocusOut: |
598 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
|
599 i=wsWindowFocusOut; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
600 wsWindowList[l]->Focused=wsNone; |
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
601 goto expose; |
1693 | 602 case VisibilityNotify: |
603 switch( Event->xvisibility.state ) | |
604 { | |
605 case VisibilityUnobscured: i=wsWindowVisible; wsWindowList[l]->Visible=wsVisible; goto expose; | |
606 case VisibilityFullyObscured: i=wsWindowNotVisible; wsWindowList[l]->Visible=wsNotVisible; goto expose; | |
607 case VisibilityPartiallyObscured: i=wsWindowPartialVisible; wsWindowList[l]->Visible=wsPVisible; goto expose; | |
608 } | |
609 expose: | |
610 wsWindowList[l]->State=i; | |
611 if ( wsWindowList[l]->ReDraw ) wsWindowList[l]->ReDraw( wsDisplay,Event->xany.window ); | |
612 break; | |
613 | |
614 case Expose: | |
615 wsWindowList[l]->State=wsWindowExpose; | |
616 if ( ( wsWindowList[l]->ReDraw )&&( !Event->xexpose.count ) ) wsWindowList[l]->ReDraw( wsDisplay,Event->xany.window ); | |
617 break; | |
618 | |
619 case ConfigureNotify: | |
620 XTranslateCoordinates( wsDisplay,wsWindowList[l]->WindowID,wsRootWin,0,0,&x,&y,&child_window ); | |
621 if ( ( wsWindowList[l]->X != x )||( wsWindowList[l]->Y != y )||( wsWindowList[l]->Width != Event->xconfigure.width )||( wsWindowList[l]->Height != Event->xconfigure.height ) ) | |
622 { | |
623 wsWindowList[l]->X=x; wsWindowList[l]->Y=y; | |
624 wsWindowList[l]->Width=Event->xconfigure.width; wsWindowList[l]->Height=Event->xconfigure.height; | |
625 if ( wsWindowList[l]->ReSize ) wsWindowList[l]->ReSize( wsWindowList[l]->X,wsWindowList[l]->Y,wsWindowList[l]->Width,wsWindowList[l]->Height ); | |
626 } | |
627 | |
628 wsWindowList[l]->Rolled=wsNone; | |
629 if ( Event->xconfigure.y < 0 ) | |
630 { i=wsWindowRolled; wsWindowList[l]->Rolled=wsRolled; goto expose; } | |
631 | |
632 break; | |
633 | |
634 case KeyPress: i=wsKeyPressed; goto keypressed; | |
635 case KeyRelease: i=wsKeyReleased; | |
636 keypressed: | |
637 wsWindowList[l]->Alt=0; | |
638 wsWindowList[l]->Shift=0; | |
639 wsWindowList[l]->NumLock=0; | |
640 wsWindowList[l]->Control=0; | |
641 wsWindowList[l]->CapsLock=0; | |
642 if ( Event->xkey.state & Mod1Mask ) wsWindowList[l]->Alt=1; | |
643 if ( Event->xkey.state & Mod2Mask ) wsWindowList[l]->NumLock=1; | |
644 if ( Event->xkey.state & ControlMask ) wsWindowList[l]->Control=1; | |
645 if ( Event->xkey.state & ShiftMask ) wsWindowList[l]->Shift=1; | |
646 if ( Event->xkey.state & LockMask ) wsWindowList[l]->CapsLock=1; | |
6089 | 647 #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
|
648 { |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
649 KeySym keySym; |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
650 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
|
651 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
|
652 { |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
653 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
|
654 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
|
655 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
|
656 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
|
657 } |
a4bbda72ce86
fix two small bug and add multimedia keyboard support ( i tested with Acer AirKey V only )
pontscho
parents:
6159
diff
changeset
|
658 } |
6089 | 659 #else |
660 { | |
661 int key; | |
662 char buf[100]; | |
663 KeySym keySym; | |
664 static XComposeStatus stat; | |
665 | |
666 XLookupString( &Event->xkey,buf,sizeof(buf),&keySym,&stat ); | |
667 key=( (keySym&0xff00) != 0?( (keySym&0x00ff) + 256 ):( keySym ) ); | |
668 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
|
669 if ( wsWindowList[l]->KeyHandler ) wsWindowList[l]->KeyHandler( Event->xkey.keycode,i,key ); |
6089 | 670 } |
671 #endif | |
1693 | 672 break; |
673 | |
674 case MotionNotify: i=wsMoveMouse; goto buttonreleased; | |
675 case ButtonRelease: i=Event->xbutton.button + 128; goto buttonreleased; | |
676 case ButtonPress: i=Event->xbutton.button; goto buttonreleased; | |
677 case EnterNotify: i=wsEnterWindow; goto buttonreleased; | |
678 case LeaveNotify: i=wsLeaveWindow; | |
679 buttonreleased: | |
680 if ( wsWindowList[l]->MouseHandler ) | |
681 wsWindowList[l]->MouseHandler( i,Event->xbutton.x,Event->xbutton.y,Event->xmotion.x_root,Event->xmotion.y_root ); | |
682 break; | |
683 | |
684 case PropertyNotify: | |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
685 { |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
686 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
|
687 |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
688 if ( !name ) break; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
689 if ( !strncmp( name,"_ICEWM_TRAY",11 ) ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
690 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
691 wsWMType=wsWMIceWM; |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
692 // 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
|
693 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
694 if ( !strncmp( name,"_KDE_",5 ) ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
695 { |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
696 // 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
|
697 wsWMType=wsWMKDE; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
698 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
699 if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
700 { |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
701 // 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
|
702 wsWMType=wsWMWMaker; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
703 } |
5919 | 704 |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
705 // 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
|
706 |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
707 XFree( name ); |
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
708 } |
1693 | 709 break; |
710 | |
6967
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
711 case SelectionNotify: |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
712 /* Handle DandD */ |
0fa27966ac47
add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
6794
diff
changeset
|
713 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
|
714 break; |
1693 | 715 } |
716 XFlush( wsDisplay ); | |
717 XSync( wsDisplay,False ); | |
718 return !wsTrue; | |
719 } | |
720 | |
721 Bool wsDummyEvents( Display * display,XEvent * Event,XPointer arg ) | |
722 { return True; } | |
723 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4566
diff
changeset
|
724 void wsHandleEvents( void ){ |
1709 | 725 // handle pending events |
726 while ( XPending(wsDisplay) ){ | |
727 XNextEvent( wsDisplay,&wsEvent ); | |
728 // printf("### X event: %d [%d]\n",wsEvent.type,delay); | |
729 wsEvents( wsDisplay,&wsEvent,NULL ); | |
730 } | |
731 } | |
732 | |
1693 | 733 void wsMainLoop( void ) |
734 { | |
1699 | 735 int delay=20; |
5919 | 736 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] init threads: %d\n",XInitThreads() ); |
1693 | 737 XSynchronize( wsDisplay,False ); |
738 XLockDisplay( wsDisplay ); | |
739 // XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL ); | |
1699 | 740 |
741 #if 1 | |
742 | |
743 while(wsTrue){ | |
744 // handle pending events | |
745 while ( XPending(wsDisplay) ){ | |
746 XNextEvent( wsDisplay,&wsEvent ); | |
747 wsEvents( wsDisplay,&wsEvent,NULL ); | |
1701 | 748 delay=0; |
1699 | 749 } |
750 usleep(delay*1000); // FIXME! | |
1701 | 751 if(delay<10*20) delay+=20; // pump up delay up to 0.2 sec (low activity) |
1699 | 752 } |
753 | |
754 #else | |
755 | |
1693 | 756 while( wsTrue ) |
757 { | |
758 XIfEvent( wsDisplay,&wsEvent,wsDummyEvents,NULL ); | |
759 wsEvents( wsDisplay,&wsEvent,NULL ); | |
760 } | |
1699 | 761 #endif |
762 | |
1693 | 763 XUnlockDisplay( wsDisplay ); |
764 } | |
765 | |
766 // ---------------------------------------------------------------------------------------------- | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
767 // Move window to selected layer |
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 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
770 #define WIN_LAYER_ONBOTTOM 2 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
771 #define WIN_LAYER_NORMAL 4 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
772 #define WIN_LAYER_ONTOP 6 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
773 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
774 void wsSetLayer( Display * wsDisplay, Window win, int layer ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
775 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
776 Atom type; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
777 int format; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
778 unsigned long nitems, bytesafter; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
779 unsigned char * args = NULL; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
780 |
6034
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
781 if ( wsWMType == wsWMIceWM ) |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
782 { |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
783 switch ( layer ) |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
784 { |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
785 case -1: layer=2; break; // WinLayerBelow |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
786 case 0: layer=4; break; // WinLayerNormal |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
787 case 1: layer=8; break; // WinLayerOnTop |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
788 } |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
789 XChangeProperty( wsDisplay,win, |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
790 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
|
791 return; |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
792 } |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
793 |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
794 type=XInternAtom( wsDisplay,"_NET_SUPPORTED",False ); |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
795 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
|
796 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
797 XEvent e; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
798 e.xclient.type=ClientMessage; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
799 e.xclient.message_type=XInternAtom( wsDisplay,"_NET_WM_STATE",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
800 e.xclient.display=wsDisplay; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
801 e.xclient.window=win; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
802 e.xclient.format=32; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
803 e.xclient.data.l[0]=layer; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
804 e.xclient.data.l[1]=XInternAtom( wsDisplay,"_NET_WM_STATE_STAYS_ON_TOP",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
805 e.xclient.data.l[2]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
806 e.xclient.data.l[3]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
807 e.xclient.data.l[4]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
808 XSendEvent( wsDisplay,wsRootWin,False,SubstructureRedirectMask,&e ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
809 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
810 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
811 return; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
812 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
813 type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False ); |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
814 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
|
815 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
816 XClientMessageEvent xev; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
817 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
818 memset( &xev,0,sizeof( xev ) ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
819 xev.type=ClientMessage; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
820 xev.window=win; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
821 xev.message_type=XInternAtom( wsDisplay,"_WIN_LAYER",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
822 xev.format=32; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
823 switch ( layer ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
824 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
825 case -1: xev.data.l[0] = WIN_LAYER_ONBOTTOM; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
826 case 0: xev.data.l[0] = WIN_LAYER_NORMAL; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
827 case 1: xev.data.l[0] = WIN_LAYER_ONTOP; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
828 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
829 XSendEvent( wsDisplay,wsRootWin,False,SubstructureNotifyMask,(XEvent*)&xev ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
830 if ( layer ) XRaiseWindow( wsDisplay,win ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
831 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
832 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
833 return; |
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 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
836 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
837 // ---------------------------------------------------------------------------------------------- |
1693 | 838 // Switch to fullscreen. |
839 // ---------------------------------------------------------------------------------------------- | |
840 void wsFullScreen( wsTWindow * win ) | |
841 { | |
842 int decoration = 0; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
843 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
844 switch ( wsWMType ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
845 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
846 case wsWMUnknown: |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
847 XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
848 break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
849 case wsWMIceWM: |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
850 if ( !win->isFullScreen ) XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
851 break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
852 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
853 |
1693 | 854 if ( win->isFullScreen ) |
855 { | |
856 win->X=win->OldX; | |
857 win->Y=win->OldY; | |
858 win->Width=win->OldWidth; | |
859 win->Height=win->OldHeight; | |
860 win->isFullScreen=False; | |
861 decoration=win->Decorations; | |
862 wsScreenSaverOn( wsDisplay ); | |
863 } | |
864 else | |
865 { | |
866 win->OldX=win->X; win->OldY=win->Y; | |
867 win->OldWidth=win->Width; win->OldHeight=win->Height; | |
868 win->X=0; win->Y=0; | |
869 win->Width=wsMaxX; win->Height=wsMaxY; | |
870 win->isFullScreen=True; | |
871 wsScreenSaverOff( wsDisplay ); | |
872 } | |
873 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
874 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
|
875 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
|
876 win->SizeHint.width=win->Width; win->SizeHint.height=win->Height; |
6034
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
877 // 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
|
878 |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
879 win->SizeHint.win_gravity=StaticGravity; |
1860 | 880 if ( win->Property & wsMaxSize ) |
881 { | |
882 win->SizeHint.flags|=PMaxSize; | |
883 win->SizeHint.max_width=win->Width; | |
884 win->SizeHint.max_height=win->Height; | |
885 } | |
886 if ( win->Property & wsMinSize ) | |
887 { | |
888 win->SizeHint.flags|=PMinSize; | |
889 win->SizeHint.min_width=win->Width; | |
890 win->SizeHint.min_height=win->Height; | |
891 } | |
1693 | 892 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
893 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
894 wsSetLayer( wsDisplay,win->WindowID,win->isFullScreen ); |
1693 | 895 XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height ); |
896 wsWindowDecoration( win,decoration ); | |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
897 XMapRaised( wsDisplay,win->WindowID ); |
1693 | 898 XRaiseWindow( wsDisplay,win->WindowID ); |
899 } | |
900 | |
901 // ---------------------------------------------------------------------------------------------- | |
902 // Redraw screen. | |
903 // ---------------------------------------------------------------------------------------------- | |
904 void wsPostRedisplay( wsTWindow * win ) | |
905 { | |
906 if ( win->ReDraw ) | |
907 { | |
6794 | 908 win->State=wsWindowExpose; |
1693 | 909 win->ReDraw( wsDisplay,win->WindowID ); |
910 XFlush( wsDisplay ); | |
911 } | |
912 } | |
913 | |
914 // ---------------------------------------------------------------------------------------------- | |
915 // Do Exit. | |
916 // ---------------------------------------------------------------------------------------------- | |
917 void wsDoExit( void ) | |
918 { wsTrue=False; wsResizeWindow( wsWindowList[0],32,32 ); } | |
919 | |
920 // ---------------------------------------------------------------------------------------------- | |
921 // Put 'Image' to window. | |
922 // ---------------------------------------------------------------------------------------------- | |
923 void wsConvert( wsTWindow * win,unsigned char * Image,unsigned int Size ) | |
2733 | 924 { if ( wsConvFunc ) wsConvFunc( Image,win->ImageData,win->xImage->width * win->xImage->height * 4 ); } |
1693 | 925 |
926 void wsPutImage( wsTWindow * win ) | |
927 { | |
928 if ( wsUseXShm ) | |
929 { | |
930 XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
931 0,0, | |
932 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
933 win->xImage->width,win->xImage->height,0 ); | |
934 } | |
935 else | |
936 { | |
937 XPutImage( 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 ); | |
941 } | |
942 } | |
943 | |
944 // ---------------------------------------------------------------------------------------------- | |
945 // Move window to x, y. | |
946 // ---------------------------------------------------------------------------------------------- | |
2854 | 947 void wsMoveWindow( wsTWindow * win,int b,int x, int y ) |
1693 | 948 { |
2854 | 949 if ( b ) |
1693 | 950 { |
2854 | 951 switch ( x ) |
952 { | |
953 case -1: win->X=( wsMaxX / 2 ) - ( win->Width / 2 ); break; | |
954 case -2: win->X=wsMaxX - win->Width; break; | |
955 default: win->X=x; break; | |
956 } | |
957 switch ( y ) | |
958 { | |
959 case -1: win->Y=( wsMaxY / 2 ) - ( win->Height / 2 ); break; | |
960 case -2: win->Y=wsMaxY - win->Height; break; | |
961 default: win->Y=y; break; | |
962 } | |
1693 | 963 } |
2854 | 964 else { win->X=x; win->Y=y; } |
1693 | 965 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
966 win->SizeHint.flags=PPosition | PWinGravity; |
1693 | 967 win->SizeHint.x=win->X; |
968 win->SizeHint.y=win->Y; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
969 win->SizeHint.win_gravity=StaticGravity; |
1693 | 970 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
971 | |
972 XMoveWindow( wsDisplay,win->WindowID,win->X,win->Y ); | |
1810 | 973 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 974 } |
975 | |
976 // ---------------------------------------------------------------------------------------------- | |
977 // Resize window to sx, sy. | |
978 // ---------------------------------------------------------------------------------------------- | |
979 void wsResizeWindow( wsTWindow * win,int sx, int sy ) | |
980 { | |
981 win->Width=sx; | |
982 win->Height=sy; | |
983 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
984 win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize; |
5986 | 985 win->SizeHint.x=win->X; |
986 win->SizeHint.y=win->Y; | |
1693 | 987 win->SizeHint.width=win->Width; |
988 win->SizeHint.height=win->Height; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
989 |
1693 | 990 if ( win->Property & wsMinSize ) |
991 { | |
992 win->SizeHint.flags|=PMinSize; | |
993 win->SizeHint.min_width=win->Width; | |
994 win->SizeHint.min_height=win->Height; | |
995 } | |
996 if ( win->Property & wsMaxSize ) | |
997 { | |
998 win->SizeHint.flags|=PMaxSize; | |
999 win->SizeHint.max_width=win->Width; | |
1000 win->SizeHint.max_height=win->Height; | |
1001 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1002 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
1003 win->SizeHint.win_gravity=StaticGravity; |
5986 | 1004 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
|
1005 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1006 if ( wsWMType == wsWMUnknown ) XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1007 |
1693 | 1008 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
1009 XResizeWindow( wsDisplay,win->WindowID,sx,sy ); | |
5986 | 1010 XMapRaised( wsDisplay,win->WindowID ); |
1810 | 1011 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 1012 } |
1013 | |
1014 // ---------------------------------------------------------------------------------------------- | |
1015 // Iconify window. | |
1016 // ---------------------------------------------------------------------------------------------- | |
1017 void wsIconify( wsTWindow win ) | |
1018 { XIconifyWindow( wsDisplay,win.WindowID,0 ); } | |
1019 | |
1020 // ---------------------------------------------------------------------------------------------- | |
1021 // Move top the window. | |
1022 // ---------------------------------------------------------------------------------------------- | |
6146 | 1023 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
|
1024 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1025 switch ( wsWMType ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1026 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1027 case wsWMIceWM: |
6146 | 1028 XUnmapWindow( wsDisplay,win ); |
1029 XMapWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1030 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1031 case wsWMNetWM: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1032 case wsWMKDE: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1033 { |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1034 XEvent e; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1035 e.xclient.type=ClientMessage; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1036 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
|
1037 e.xclient.display=wsDisplay; |
6146 | 1038 e.xclient.window=win; |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1039 e.xclient.format=32; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1040 e.xclient.data.l[0]=0; |
6146 | 1041 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
|
1042 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1043 } |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1044 default: |
6146 | 1045 XMapRaised( wsDisplay,win ); |
1046 XRaiseWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1047 break; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1048 } |
2045 | 1049 } |
1693 | 1050 |
1051 // ---------------------------------------------------------------------------------------------- | |
1052 // Set window background to 'color'. | |
1053 // ---------------------------------------------------------------------------------------------- | |
1054 void wsSetBackground( wsTWindow * win,int color ) | |
1055 { XSetWindowBackground( wsDisplay,win->WindowID,color ); } | |
1056 | |
1057 void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b ) | |
1058 { | |
1059 int color = 0; | |
1060 switch ( wsOutMask ) | |
1061 { | |
1062 case wsRGB32: | |
1063 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1064 case wsBGR32: | |
1065 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1066 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1067 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1068 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1069 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1693 | 1070 } |
1071 XSetWindowBackground( wsDisplay,win->WindowID,color ); | |
1072 } | |
1073 | |
1814 | 1074 void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b ) |
1075 { | |
1076 int color = 0; | |
1077 switch ( wsOutMask ) | |
1078 { | |
1079 case wsRGB32: | |
1080 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1081 case wsBGR32: | |
1082 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1083 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1084 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1085 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1086 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1814 | 1087 } |
1088 XSetForeground( wsDisplay,win->wGC,color ); | |
1089 } | |
1693 | 1090 |
1091 // ---------------------------------------------------------------------------------------------- | |
1092 // Draw string at x,y with fc ( foreground color ) and bc ( background color ). | |
1093 // ---------------------------------------------------------------------------------------------- | |
1094 void wsDrawString( wsTWindow win,int x,int y,char * str,int fc,int bc ) | |
1095 { | |
1096 XSetForeground( wsDisplay,win.wGC,bc ); | |
1097 XFillRectangle( wsDisplay,win.WindowID,win.wGC,x,y, | |
1098 XTextWidth( win.Font,str,strlen( str ) ) + 20, | |
1099 win.FontHeight + 2 ); | |
1100 XSetForeground( wsDisplay,win.wGC,fc ); | |
1101 XDrawString( wsDisplay,win.WindowID,win.wGC,x + 10,y + 13,str,strlen( str ) ); | |
1102 } | |
1103 | |
1104 // ---------------------------------------------------------------------------------------------- | |
1105 // Calculation string width. | |
1106 // ---------------------------------------------------------------------------------------------- | |
1107 int wsTextWidth( wsTWindow win,char * str ) | |
1108 { return XTextWidth( win.Font,str,strlen( str ) ) + 20; } | |
1109 | |
1110 // ---------------------------------------------------------------------------------------------- | |
1111 // Show / hide mouse cursor. | |
1112 // ---------------------------------------------------------------------------------------------- | |
1113 void wsVisibleMouse( wsTWindow * win,int m ) | |
1114 { | |
1115 switch ( m ) | |
1116 { | |
1117 case wsShowMouseCursor: | |
1118 if ( win->wsCursor != None ) | |
1119 { | |
1120 XFreeCursor( wsDisplay,win->wsCursor ); | |
1121 win->wsCursor=None; | |
1122 } | |
1123 XDefineCursor( wsDisplay,win->WindowID,0 ); | |
1124 break; | |
1125 case wsHideMouseCursor: | |
1126 win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 ); | |
1127 XDefineCursor( wsDisplay,win->WindowID,win->wsCursor ); | |
1128 break; | |
1129 } | |
1130 XFlush( wsDisplay ); | |
1131 } | |
1132 | |
1133 int wsGetDepthOnScreen( void ) | |
1134 { | |
1135 int bpp,ibpp; | |
1136 XImage * mXImage; | |
1137 XWindowAttributes attribs; | |
1138 | |
1139 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1140 bpp=mXImage->bits_per_pixel; | |
1141 | |
1142 XGetWindowAttributes( wsDisplay,wsRootWin,&attribs ); | |
1143 ibpp=attribs.depth; | |
1144 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1145 bpp=mXImage->bits_per_pixel; | |
1146 if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp; | |
1147 wsDepthOnScreen=ibpp; | |
1148 wsRedMask=mXImage->red_mask; | |
1149 wsGreenMask=mXImage->green_mask; | |
1150 wsBlueMask=mXImage->blue_mask; | |
1151 XDestroyImage( mXImage ); | |
1152 return ibpp; | |
1153 } | |
1154 | |
1155 void wsXDone( void ) | |
1156 { | |
1157 XCloseDisplay( wsDisplay ); | |
1158 } | |
1159 | |
1160 void wsVisibleWindow( wsTWindow * win,int show ) | |
1161 { | |
1162 switch( show ) | |
1163 { | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1164 case wsShowWindow: XMapRaised( wsDisplay,win->WindowID ); break; |
1693 | 1165 case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break; |
1166 } | |
1167 XFlush( wsDisplay ); | |
1168 } | |
1169 | |
1170 void wsDestroyImage( wsTWindow * win ) | |
1171 { | |
1172 if ( win->xImage ) | |
1173 { | |
1174 XDestroyImage( win->xImage ); | |
1175 if ( wsUseXShm ) | |
1176 { | |
1177 XShmDetach( wsDisplay,&win->Shminfo ); | |
1178 shmdt( win->Shminfo.shmaddr ); | |
1179 } | |
1180 } | |
1181 win->xImage=NULL; | |
1182 } | |
1183 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1184 void wsCreateImage( wsTWindow * win,int Width,int Height ) |
1693 | 1185 { |
1186 int CompletionType = -1; | |
1187 if ( wsUseXShm ) | |
1188 { | |
1189 CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion; | |
1190 win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual, | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1191 win->Attribs.depth,ZPixmap,NULL,&win->Shminfo,Width,Height ); |
1693 | 1192 if ( win->xImage == NULL ) |
1193 { | |
5919 | 1194 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1195 exit( 0 ); |
1196 } | |
1197 win->Shminfo.shmid=shmget( IPC_PRIVATE,win->xImage->bytes_per_line * win->xImage->height,IPC_CREAT|0777 ); | |
1198 if ( win->Shminfo.shmid < 0 ) | |
1199 { | |
1200 XDestroyImage( win->xImage ); | |
5919 | 1201 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1202 exit( 0 ); |
1203 } | |
1204 win->Shminfo.shmaddr=(char *)shmat( win->Shminfo.shmid,0,0 ); | |
1205 | |
1206 if ( win->Shminfo.shmaddr == ((char *) -1) ) | |
1207 { | |
1208 XDestroyImage( win->xImage ); | |
1209 if ( win->Shminfo.shmaddr != ((char *) -1) ) shmdt( win->Shminfo.shmaddr ); | |
5919 | 1210 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1211 exit( 0 ); |
1212 } | |
1213 win->xImage->data=win->Shminfo.shmaddr; | |
1214 win->Shminfo.readOnly=0; | |
1215 XShmAttach( wsDisplay,&win->Shminfo ); | |
1216 shmctl( win->Shminfo.shmid,IPC_RMID,0 ); | |
1217 } | |
1218 else | |
1219 { | |
1220 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
|
1221 ZPixmap,0,0,Width,Height, |
1693 | 1222 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen, |
1223 0 ); | |
1224 if ( ( win->xImage->data=malloc( win->xImage->bytes_per_line * win->xImage->height ) ) == NULL ) | |
1225 { | |
5919 | 1226 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, not enough memory for draw buffer.\n" ); |
1693 | 1227 exit( 0 ); |
1228 } | |
1229 } | |
1230 win->ImageData=(unsigned char *)win->xImage->data; | |
1231 win->ImageDataw=(unsigned short int *)win->xImage->data; | |
1232 win->ImageDatadw=(unsigned int *)win->xImage->data; | |
1233 } | |
1234 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1235 void wsResizeImage( wsTWindow * win,int Width,int Height ) |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1236 { wsDestroyImage( win ); wsCreateImage( win,Width,Height ); } |
1693 | 1237 |
1238 int wsGetOutMask( void ) | |
1239 { | |
1240 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB32; | |
1241 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR32; | |
1242 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB24; | |
1243 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR24; | |
1244 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0xf800 )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB16; | |
1245 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0xf800 ) ) return wsBGR16; | |
1246 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x7c00 )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB15; | |
1247 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x7c00 ) ) return wsBGR15; | |
1248 return 0; | |
1249 } | |
1250 | |
1251 void wsSetTitle( wsTWindow * win,char * name ) | |
1252 { XStoreName( wsDisplay,win->WindowID,name ); } | |
1253 | |
1254 void wsSetMousePosition( wsTWindow * win,int x, int y ) | |
1255 { XWarpPointer( wsDisplay,wsRootWin,win->WindowID,0,0,0,0,x,y ); } | |
1256 | |
1257 static int dpms_disabled=0; | |
1258 static int timeout_save=0; | |
1259 | |
1260 void wsScreenSaverOn( Display *mDisplay ) | |
1261 { | |
1262 int nothing; | |
4566 | 1263 #ifdef HAVE_XDPMS |
1693 | 1264 if ( dpms_disabled ) |
1265 { | |
1266 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) | |
1267 { | |
5919 | 1268 if ( !DPMSEnable( mDisplay ) ) mp_msg( MSGT_GPLAYER,MSGL_ERR,"DPMS not available ?\n" ); // restoring power saving settings |
1693 | 1269 else |
1270 { | |
1271 // DPMS does not seem to be enabled unless we call DPMSInfo | |
1272 BOOL onoff; | |
1273 CARD16 state; | |
1274 DPMSInfo( mDisplay,&state,&onoff ); | |
5919 | 1275 if ( onoff ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Successfully enabled DPMS.\n" ); |
1276 else mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Could not enable DPMS.\n" ); | |
1693 | 1277 } |
1278 } | |
1279 } | |
4566 | 1280 #endif |
1693 | 1281 if ( timeout_save ) |
1282 { | |
1283 int dummy, interval, prefer_blank, allow_exp; | |
1284 XGetScreenSaver( mDisplay,&dummy,&interval,&prefer_blank,&allow_exp ); | |
1285 XSetScreenSaver( mDisplay,timeout_save,interval,prefer_blank,allow_exp ); | |
1286 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); | |
1287 } | |
1288 } | |
1289 | |
1290 void wsScreenSaverOff( Display * mDisplay ) | |
1291 { | |
1292 int interval,prefer_blank,allow_exp,nothing; | |
4566 | 1293 #ifdef HAVE_XDPMS |
1693 | 1294 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) |
1295 { | |
1296 BOOL onoff; | |
1297 CARD16 state; | |
1298 DPMSInfo( mDisplay,&state,&onoff ); | |
1299 if ( onoff ) | |
1300 { | |
1301 Status stat; | |
5919 | 1302 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"Disabling DPMS.\n" ); |
1693 | 1303 dpms_disabled=1; |
1304 stat=DPMSDisable( mDisplay ); // monitor powersave off | |
5919 | 1305 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"stat: %d.\n",stat ); |
1693 | 1306 } |
1307 } | |
4566 | 1308 #endif |
1693 | 1309 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); |
1310 if ( timeout_save ) XSetScreenSaver( mDisplay,0,interval,prefer_blank,allow_exp ); // turning off screensaver | |
1311 } | |
1312 | |
1313 void wsSetShape( wsTWindow * win,char * data ) | |
1314 { | |
1315 #ifdef HAVE_XSHAPE | |
1852 | 1316 if ( !wsUseXShape ) return; |
1317 if ( data ) | |
1318 { | |
1319 win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height ); | |
1320 XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet ); | |
1321 XFreePixmap( wsDisplay,win->Mask ); | |
1322 } | |
1323 else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet ); | |
1693 | 1324 #endif |
1325 } | |
1326 | |
6651 | 1327 void wsSetIcon( Display * dsp,Window win,Pixmap icon,Pixmap mask ) |
1328 { | |
1329 XWMHints * wm; | |
1330 long data[2]; | |
1331 Atom iconatom; | |
1332 | |
1333 wm=XGetWMHints( dsp,win ); | |
1334 if ( !wm ) wm=XAllocWMHints(); | |
1335 | |
1336 wm->icon_pixmap=icon; | |
1337 wm->icon_mask=mask; | |
1338 wm->flags|=IconPixmapHint | IconMaskHint; | |
1339 | |
1340 XSetWMHints( dsp,win,wm ); | |
1341 | |
1342 data[0]=icon; | |
1343 data[1]=mask; | |
1344 iconatom=XInternAtom( dsp,"KWM_WIN_ICON",0 ); | |
1345 XChangeProperty( dsp,win,iconatom,iconatom,32,PropModeReplace,(unsigned char *)data,2 ); | |
1346 | |
1347 XFree( wm ); | |
1348 } | |
1349 | |
1693 | 1350 #include "wsmkeys.h" |