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