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