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