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