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