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