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