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