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