Mercurial > mplayer.hg
annotate Gui/wm/ws.c @ 6965:f8ea0af8edb0
optimization
author | michael |
---|---|
date | Sun, 11 Aug 2002 10:12:15 +0000 |
parents | 77980ab4e296 |
children | 0fa27966ac47 |
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" ); |
6794 | 296 wsConvFunc=(void *)BGR8880_to_RGB8880_c; |
1693 | 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" ); |
6794 | 308 wsConvFunc=(void *)BGR8880_to_BGR888_c; |
1693 | 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" ); |
6794 | 316 wsConvFunc=(void *)BGR8880_to_BGR565_c; |
1693 | 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" ); |
6794 | 324 wsConvFunc=(void *)BGR8880_to_BGR555_c; |
1693 | 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; |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
665 // mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is IceWM.\n" ); |
5997
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 { |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
669 // mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is KDE.\n" ); |
5997
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 { |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6619
diff
changeset
|
674 // mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is WindowMaker style.\n" ); |
5997
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 | |
1693 | 702 void wsMainLoop( void ) |
703 { | |
1699 | 704 int delay=20; |
5919 | 705 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[ws] init threads: %d\n",XInitThreads() ); |
1693 | 706 XSynchronize( wsDisplay,False ); |
707 XLockDisplay( wsDisplay ); | |
708 // XIfEvent( wsDisplay,&wsEvent,wsEvents,NULL ); | |
1699 | 709 |
710 #if 1 | |
711 | |
712 while(wsTrue){ | |
713 // handle pending events | |
714 while ( XPending(wsDisplay) ){ | |
715 XNextEvent( wsDisplay,&wsEvent ); | |
716 wsEvents( wsDisplay,&wsEvent,NULL ); | |
1701 | 717 delay=0; |
1699 | 718 } |
719 usleep(delay*1000); // FIXME! | |
1701 | 720 if(delay<10*20) delay+=20; // pump up delay up to 0.2 sec (low activity) |
1699 | 721 } |
722 | |
723 #else | |
724 | |
1693 | 725 while( wsTrue ) |
726 { | |
727 XIfEvent( wsDisplay,&wsEvent,wsDummyEvents,NULL ); | |
728 wsEvents( wsDisplay,&wsEvent,NULL ); | |
729 } | |
1699 | 730 #endif |
731 | |
1693 | 732 XUnlockDisplay( wsDisplay ); |
733 } | |
734 | |
735 // ---------------------------------------------------------------------------------------------- | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
736 // Move window to selected layer |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
737 // ---------------------------------------------------------------------------------------------- |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
738 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
739 #define WIN_LAYER_ONBOTTOM 2 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
740 #define WIN_LAYER_NORMAL 4 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
741 #define WIN_LAYER_ONTOP 6 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
742 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
743 void wsSetLayer( Display * wsDisplay, Window win, int layer ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
744 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
745 Atom type; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
746 int format; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
747 unsigned long nitems, bytesafter; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
748 unsigned char * args = NULL; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
749 |
6034
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
750 if ( wsWMType == wsWMIceWM ) |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
751 { |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
752 switch ( layer ) |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
753 { |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
754 case -1: layer=2; break; // WinLayerBelow |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
755 case 0: layer=4; break; // WinLayerNormal |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
756 case 1: layer=8; break; // WinLayerOnTop |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
757 } |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
758 XChangeProperty( wsDisplay,win, |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
759 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
|
760 return; |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
761 } |
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
762 |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
763 type=XInternAtom( wsDisplay,"_NET_SUPPORTED",False ); |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
764 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
|
765 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
766 XEvent e; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
767 e.xclient.type=ClientMessage; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
768 e.xclient.message_type=XInternAtom( wsDisplay,"_NET_WM_STATE",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
769 e.xclient.display=wsDisplay; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
770 e.xclient.window=win; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
771 e.xclient.format=32; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
772 e.xclient.data.l[0]=layer; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
773 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
|
774 e.xclient.data.l[2]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
775 e.xclient.data.l[3]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
776 e.xclient.data.l[4]=0l; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
777 XSendEvent( wsDisplay,wsRootWin,False,SubstructureRedirectMask,&e ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
778 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
779 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
780 return; |
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 type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False ); |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
783 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
|
784 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
785 XClientMessageEvent xev; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
786 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
787 memset( &xev,0,sizeof( xev ) ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
788 xev.type=ClientMessage; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
789 xev.window=win; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
790 xev.message_type=XInternAtom( wsDisplay,"_WIN_LAYER",False ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
791 xev.format=32; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
792 switch ( layer ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
793 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
794 case -1: xev.data.l[0] = WIN_LAYER_ONBOTTOM; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
795 case 0: xev.data.l[0] = WIN_LAYER_NORMAL; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
796 case 1: xev.data.l[0] = WIN_LAYER_ONTOP; break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
797 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
798 XSendEvent( wsDisplay,wsRootWin,False,SubstructureNotifyMask,(XEvent*)&xev ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
799 if ( layer ) XRaiseWindow( wsDisplay,win ); |
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 XFree( args ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
802 return; |
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 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
805 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
806 // ---------------------------------------------------------------------------------------------- |
1693 | 807 // Switch to fullscreen. |
808 // ---------------------------------------------------------------------------------------------- | |
809 void wsFullScreen( wsTWindow * win ) | |
810 { | |
811 int decoration = 0; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
812 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
813 switch ( wsWMType ) |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
814 { |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
815 case wsWMUnknown: |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
816 XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
817 break; |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
818 case wsWMIceWM: |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
819 if ( !win->isFullScreen ) 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 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
822 |
1693 | 823 if ( win->isFullScreen ) |
824 { | |
825 win->X=win->OldX; | |
826 win->Y=win->OldY; | |
827 win->Width=win->OldWidth; | |
828 win->Height=win->OldHeight; | |
829 win->isFullScreen=False; | |
830 decoration=win->Decorations; | |
831 wsScreenSaverOn( wsDisplay ); | |
832 } | |
833 else | |
834 { | |
835 win->OldX=win->X; win->OldY=win->Y; | |
836 win->OldWidth=win->Width; win->OldHeight=win->Height; | |
837 win->X=0; win->Y=0; | |
838 win->Width=wsMaxX; win->Height=wsMaxY; | |
839 win->isFullScreen=True; | |
840 wsScreenSaverOff( wsDisplay ); | |
841 } | |
842 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
843 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
|
844 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
|
845 win->SizeHint.width=win->Width; win->SizeHint.height=win->Height; |
6034
7570f4666c15
fullscreen -- round three -- icewm fullscreen fixed
pontscho
parents:
6013
diff
changeset
|
846 // 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
|
847 |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
848 win->SizeHint.win_gravity=StaticGravity; |
1860 | 849 if ( win->Property & wsMaxSize ) |
850 { | |
851 win->SizeHint.flags|=PMaxSize; | |
852 win->SizeHint.max_width=win->Width; | |
853 win->SizeHint.max_height=win->Height; | |
854 } | |
855 if ( win->Property & wsMinSize ) | |
856 { | |
857 win->SizeHint.flags|=PMinSize; | |
858 win->SizeHint.min_width=win->Width; | |
859 win->SizeHint.min_height=win->Height; | |
860 } | |
1693 | 861 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
862 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
863 wsSetLayer( wsDisplay,win->WindowID,win->isFullScreen ); |
1693 | 864 XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height ); |
865 wsWindowDecoration( win,decoration ); | |
5910
20c335d98ab3
fix fullscreen bug es ilyen libvo not initialized bug with gui igy
pontscho
parents:
5031
diff
changeset
|
866 XMapRaised( wsDisplay,win->WindowID ); |
1693 | 867 XRaiseWindow( wsDisplay,win->WindowID ); |
868 } | |
869 | |
870 // ---------------------------------------------------------------------------------------------- | |
871 // Redraw screen. | |
872 // ---------------------------------------------------------------------------------------------- | |
873 void wsPostRedisplay( wsTWindow * win ) | |
874 { | |
875 if ( win->ReDraw ) | |
876 { | |
6794 | 877 win->State=wsWindowExpose; |
1693 | 878 win->ReDraw( wsDisplay,win->WindowID ); |
879 XFlush( wsDisplay ); | |
880 } | |
881 } | |
882 | |
883 // ---------------------------------------------------------------------------------------------- | |
884 // Do Exit. | |
885 // ---------------------------------------------------------------------------------------------- | |
886 void wsDoExit( void ) | |
887 { wsTrue=False; wsResizeWindow( wsWindowList[0],32,32 ); } | |
888 | |
889 // ---------------------------------------------------------------------------------------------- | |
890 // Put 'Image' to window. | |
891 // ---------------------------------------------------------------------------------------------- | |
892 void wsConvert( wsTWindow * win,unsigned char * Image,unsigned int Size ) | |
2733 | 893 { if ( wsConvFunc ) wsConvFunc( Image,win->ImageData,win->xImage->width * win->xImage->height * 4 ); } |
1693 | 894 |
895 void wsPutImage( wsTWindow * win ) | |
896 { | |
897 if ( wsUseXShm ) | |
898 { | |
899 XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
900 0,0, | |
901 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
902 win->xImage->width,win->xImage->height,0 ); | |
903 } | |
904 else | |
905 { | |
906 XPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
907 0,0, | |
908 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
909 win->xImage->width,win->xImage->height ); | |
910 } | |
911 } | |
912 | |
913 // ---------------------------------------------------------------------------------------------- | |
914 // Move window to x, y. | |
915 // ---------------------------------------------------------------------------------------------- | |
2854 | 916 void wsMoveWindow( wsTWindow * win,int b,int x, int y ) |
1693 | 917 { |
2854 | 918 if ( b ) |
1693 | 919 { |
2854 | 920 switch ( x ) |
921 { | |
922 case -1: win->X=( wsMaxX / 2 ) - ( win->Width / 2 ); break; | |
923 case -2: win->X=wsMaxX - win->Width; break; | |
924 default: win->X=x; break; | |
925 } | |
926 switch ( y ) | |
927 { | |
928 case -1: win->Y=( wsMaxY / 2 ) - ( win->Height / 2 ); break; | |
929 case -2: win->Y=wsMaxY - win->Height; break; | |
930 default: win->Y=y; break; | |
931 } | |
1693 | 932 } |
2854 | 933 else { win->X=x; win->Y=y; } |
1693 | 934 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
935 win->SizeHint.flags=PPosition | PWinGravity; |
1693 | 936 win->SizeHint.x=win->X; |
937 win->SizeHint.y=win->Y; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
938 win->SizeHint.win_gravity=StaticGravity; |
1693 | 939 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
940 | |
941 XMoveWindow( wsDisplay,win->WindowID,win->X,win->Y ); | |
1810 | 942 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 943 } |
944 | |
945 // ---------------------------------------------------------------------------------------------- | |
946 // Resize window to sx, sy. | |
947 // ---------------------------------------------------------------------------------------------- | |
948 void wsResizeWindow( wsTWindow * win,int sx, int sy ) | |
949 { | |
950 win->Width=sx; | |
951 win->Height=sy; | |
952 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
953 win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize; |
5986 | 954 win->SizeHint.x=win->X; |
955 win->SizeHint.y=win->Y; | |
1693 | 956 win->SizeHint.width=win->Width; |
957 win->SizeHint.height=win->Height; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
958 |
1693 | 959 if ( win->Property & wsMinSize ) |
960 { | |
961 win->SizeHint.flags|=PMinSize; | |
962 win->SizeHint.min_width=win->Width; | |
963 win->SizeHint.min_height=win->Height; | |
964 } | |
965 if ( win->Property & wsMaxSize ) | |
966 { | |
967 win->SizeHint.flags|=PMaxSize; | |
968 win->SizeHint.max_width=win->Width; | |
969 win->SizeHint.max_height=win->Height; | |
970 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
971 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
972 win->SizeHint.win_gravity=StaticGravity; |
5986 | 973 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
|
974 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
975 if ( wsWMType == wsWMUnknown ) XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
976 |
1693 | 977 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
978 XResizeWindow( wsDisplay,win->WindowID,sx,sy ); | |
5986 | 979 XMapRaised( wsDisplay,win->WindowID ); |
1810 | 980 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 981 } |
982 | |
983 // ---------------------------------------------------------------------------------------------- | |
984 // Iconify window. | |
985 // ---------------------------------------------------------------------------------------------- | |
986 void wsIconify( wsTWindow win ) | |
987 { XIconifyWindow( wsDisplay,win.WindowID,0 ); } | |
988 | |
989 // ---------------------------------------------------------------------------------------------- | |
990 // Move top the window. | |
991 // ---------------------------------------------------------------------------------------------- | |
6146 | 992 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
|
993 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
994 switch ( wsWMType ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
995 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
996 case wsWMIceWM: |
6146 | 997 XUnmapWindow( wsDisplay,win ); |
998 XMapWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
999 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1000 case wsWMNetWM: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1001 case wsWMKDE: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1002 { |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1003 XEvent e; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1004 e.xclient.type=ClientMessage; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1005 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
|
1006 e.xclient.display=wsDisplay; |
6146 | 1007 e.xclient.window=win; |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1008 e.xclient.format=32; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1009 e.xclient.data.l[0]=0; |
6146 | 1010 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
|
1011 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1012 } |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1013 default: |
6146 | 1014 XMapRaised( wsDisplay,win ); |
1015 XRaiseWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1016 break; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1017 } |
2045 | 1018 } |
1693 | 1019 |
1020 // ---------------------------------------------------------------------------------------------- | |
1021 // Set window background to 'color'. | |
1022 // ---------------------------------------------------------------------------------------------- | |
1023 void wsSetBackground( wsTWindow * win,int color ) | |
1024 { XSetWindowBackground( wsDisplay,win->WindowID,color ); } | |
1025 | |
1026 void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b ) | |
1027 { | |
1028 int color = 0; | |
1029 switch ( wsOutMask ) | |
1030 { | |
1031 case wsRGB32: | |
1032 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1033 case wsBGR32: | |
1034 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1035 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1036 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1037 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1038 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1693 | 1039 } |
1040 XSetWindowBackground( wsDisplay,win->WindowID,color ); | |
1041 } | |
1042 | |
1814 | 1043 void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b ) |
1044 { | |
1045 int color = 0; | |
1046 switch ( wsOutMask ) | |
1047 { | |
1048 case wsRGB32: | |
1049 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1050 case wsBGR32: | |
1051 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1052 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1053 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1054 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1055 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1814 | 1056 } |
1057 XSetForeground( wsDisplay,win->wGC,color ); | |
1058 } | |
1693 | 1059 |
1060 // ---------------------------------------------------------------------------------------------- | |
1061 // Draw string at x,y with fc ( foreground color ) and bc ( background color ). | |
1062 // ---------------------------------------------------------------------------------------------- | |
1063 void wsDrawString( wsTWindow win,int x,int y,char * str,int fc,int bc ) | |
1064 { | |
1065 XSetForeground( wsDisplay,win.wGC,bc ); | |
1066 XFillRectangle( wsDisplay,win.WindowID,win.wGC,x,y, | |
1067 XTextWidth( win.Font,str,strlen( str ) ) + 20, | |
1068 win.FontHeight + 2 ); | |
1069 XSetForeground( wsDisplay,win.wGC,fc ); | |
1070 XDrawString( wsDisplay,win.WindowID,win.wGC,x + 10,y + 13,str,strlen( str ) ); | |
1071 } | |
1072 | |
1073 // ---------------------------------------------------------------------------------------------- | |
1074 // Calculation string width. | |
1075 // ---------------------------------------------------------------------------------------------- | |
1076 int wsTextWidth( wsTWindow win,char * str ) | |
1077 { return XTextWidth( win.Font,str,strlen( str ) ) + 20; } | |
1078 | |
1079 // ---------------------------------------------------------------------------------------------- | |
1080 // Show / hide mouse cursor. | |
1081 // ---------------------------------------------------------------------------------------------- | |
1082 void wsVisibleMouse( wsTWindow * win,int m ) | |
1083 { | |
1084 switch ( m ) | |
1085 { | |
1086 case wsShowMouseCursor: | |
1087 if ( win->wsCursor != None ) | |
1088 { | |
1089 XFreeCursor( wsDisplay,win->wsCursor ); | |
1090 win->wsCursor=None; | |
1091 } | |
1092 XDefineCursor( wsDisplay,win->WindowID,0 ); | |
1093 break; | |
1094 case wsHideMouseCursor: | |
1095 win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 ); | |
1096 XDefineCursor( wsDisplay,win->WindowID,win->wsCursor ); | |
1097 break; | |
1098 } | |
1099 XFlush( wsDisplay ); | |
1100 } | |
1101 | |
1102 int wsGetDepthOnScreen( void ) | |
1103 { | |
1104 int bpp,ibpp; | |
1105 XImage * mXImage; | |
1106 XWindowAttributes attribs; | |
1107 | |
1108 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1109 bpp=mXImage->bits_per_pixel; | |
1110 | |
1111 XGetWindowAttributes( wsDisplay,wsRootWin,&attribs ); | |
1112 ibpp=attribs.depth; | |
1113 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1114 bpp=mXImage->bits_per_pixel; | |
1115 if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp; | |
1116 wsDepthOnScreen=ibpp; | |
1117 wsRedMask=mXImage->red_mask; | |
1118 wsGreenMask=mXImage->green_mask; | |
1119 wsBlueMask=mXImage->blue_mask; | |
1120 XDestroyImage( mXImage ); | |
1121 return ibpp; | |
1122 } | |
1123 | |
1124 void wsXDone( void ) | |
1125 { | |
1126 XCloseDisplay( wsDisplay ); | |
1127 } | |
1128 | |
1129 void wsVisibleWindow( wsTWindow * win,int show ) | |
1130 { | |
1131 switch( show ) | |
1132 { | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1133 case wsShowWindow: XMapRaised( wsDisplay,win->WindowID ); break; |
1693 | 1134 case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break; |
1135 } | |
1136 XFlush( wsDisplay ); | |
1137 } | |
1138 | |
1139 void wsDestroyImage( wsTWindow * win ) | |
1140 { | |
1141 if ( win->xImage ) | |
1142 { | |
1143 XDestroyImage( win->xImage ); | |
1144 if ( wsUseXShm ) | |
1145 { | |
1146 XShmDetach( wsDisplay,&win->Shminfo ); | |
1147 shmdt( win->Shminfo.shmaddr ); | |
1148 } | |
1149 } | |
1150 win->xImage=NULL; | |
1151 } | |
1152 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1153 void wsCreateImage( wsTWindow * win,int Width,int Height ) |
1693 | 1154 { |
1155 int CompletionType = -1; | |
1156 if ( wsUseXShm ) | |
1157 { | |
1158 CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion; | |
1159 win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual, | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1160 win->Attribs.depth,ZPixmap,NULL,&win->Shminfo,Width,Height ); |
1693 | 1161 if ( win->xImage == NULL ) |
1162 { | |
5919 | 1163 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1164 exit( 0 ); |
1165 } | |
1166 win->Shminfo.shmid=shmget( IPC_PRIVATE,win->xImage->bytes_per_line * win->xImage->height,IPC_CREAT|0777 ); | |
1167 if ( win->Shminfo.shmid < 0 ) | |
1168 { | |
1169 XDestroyImage( win->xImage ); | |
5919 | 1170 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1171 exit( 0 ); |
1172 } | |
1173 win->Shminfo.shmaddr=(char *)shmat( win->Shminfo.shmid,0,0 ); | |
1174 | |
1175 if ( win->Shminfo.shmaddr == ((char *) -1) ) | |
1176 { | |
1177 XDestroyImage( win->xImage ); | |
1178 if ( win->Shminfo.shmaddr != ((char *) -1) ) shmdt( win->Shminfo.shmaddr ); | |
5919 | 1179 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1180 exit( 0 ); |
1181 } | |
1182 win->xImage->data=win->Shminfo.shmaddr; | |
1183 win->Shminfo.readOnly=0; | |
1184 XShmAttach( wsDisplay,&win->Shminfo ); | |
1185 shmctl( win->Shminfo.shmid,IPC_RMID,0 ); | |
1186 } | |
1187 else | |
1188 { | |
1189 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
|
1190 ZPixmap,0,0,Width,Height, |
1693 | 1191 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen, |
1192 0 ); | |
1193 if ( ( win->xImage->data=malloc( win->xImage->bytes_per_line * win->xImage->height ) ) == NULL ) | |
1194 { | |
5919 | 1195 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, not enough memory for draw buffer.\n" ); |
1693 | 1196 exit( 0 ); |
1197 } | |
1198 } | |
1199 win->ImageData=(unsigned char *)win->xImage->data; | |
1200 win->ImageDataw=(unsigned short int *)win->xImage->data; | |
1201 win->ImageDatadw=(unsigned int *)win->xImage->data; | |
1202 } | |
1203 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1204 void wsResizeImage( wsTWindow * win,int Width,int Height ) |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1205 { wsDestroyImage( win ); wsCreateImage( win,Width,Height ); } |
1693 | 1206 |
1207 int wsGetOutMask( void ) | |
1208 { | |
1209 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB32; | |
1210 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR32; | |
1211 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB24; | |
1212 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR24; | |
1213 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0xf800 )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB16; | |
1214 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0xf800 ) ) return wsBGR16; | |
1215 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x7c00 )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB15; | |
1216 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x7c00 ) ) return wsBGR15; | |
1217 return 0; | |
1218 } | |
1219 | |
1220 void wsSetTitle( wsTWindow * win,char * name ) | |
1221 { XStoreName( wsDisplay,win->WindowID,name ); } | |
1222 | |
1223 void wsSetMousePosition( wsTWindow * win,int x, int y ) | |
1224 { XWarpPointer( wsDisplay,wsRootWin,win->WindowID,0,0,0,0,x,y ); } | |
1225 | |
1226 static int dpms_disabled=0; | |
1227 static int timeout_save=0; | |
1228 | |
1229 void wsScreenSaverOn( Display *mDisplay ) | |
1230 { | |
1231 int nothing; | |
4566 | 1232 #ifdef HAVE_XDPMS |
1693 | 1233 if ( dpms_disabled ) |
1234 { | |
1235 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) | |
1236 { | |
5919 | 1237 if ( !DPMSEnable( mDisplay ) ) mp_msg( MSGT_GPLAYER,MSGL_ERR,"DPMS not available ?\n" ); // restoring power saving settings |
1693 | 1238 else |
1239 { | |
1240 // DPMS does not seem to be enabled unless we call DPMSInfo | |
1241 BOOL onoff; | |
1242 CARD16 state; | |
1243 DPMSInfo( mDisplay,&state,&onoff ); | |
5919 | 1244 if ( onoff ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Successfully enabled DPMS.\n" ); |
1245 else mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Could not enable DPMS.\n" ); | |
1693 | 1246 } |
1247 } | |
1248 } | |
4566 | 1249 #endif |
1693 | 1250 if ( timeout_save ) |
1251 { | |
1252 int dummy, interval, prefer_blank, allow_exp; | |
1253 XGetScreenSaver( mDisplay,&dummy,&interval,&prefer_blank,&allow_exp ); | |
1254 XSetScreenSaver( mDisplay,timeout_save,interval,prefer_blank,allow_exp ); | |
1255 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); | |
1256 } | |
1257 } | |
1258 | |
1259 void wsScreenSaverOff( Display * mDisplay ) | |
1260 { | |
1261 int interval,prefer_blank,allow_exp,nothing; | |
4566 | 1262 #ifdef HAVE_XDPMS |
1693 | 1263 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) |
1264 { | |
1265 BOOL onoff; | |
1266 CARD16 state; | |
1267 DPMSInfo( mDisplay,&state,&onoff ); | |
1268 if ( onoff ) | |
1269 { | |
1270 Status stat; | |
5919 | 1271 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"Disabling DPMS.\n" ); |
1693 | 1272 dpms_disabled=1; |
1273 stat=DPMSDisable( mDisplay ); // monitor powersave off | |
5919 | 1274 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"stat: %d.\n",stat ); |
1693 | 1275 } |
1276 } | |
4566 | 1277 #endif |
1693 | 1278 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); |
1279 if ( timeout_save ) XSetScreenSaver( mDisplay,0,interval,prefer_blank,allow_exp ); // turning off screensaver | |
1280 } | |
1281 | |
1282 void wsSetShape( wsTWindow * win,char * data ) | |
1283 { | |
1284 #ifdef HAVE_XSHAPE | |
1852 | 1285 if ( !wsUseXShape ) return; |
1286 if ( data ) | |
1287 { | |
1288 win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height ); | |
1289 XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet ); | |
1290 XFreePixmap( wsDisplay,win->Mask ); | |
1291 } | |
1292 else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet ); | |
1693 | 1293 #endif |
1294 } | |
1295 | |
6651 | 1296 void wsSetIcon( Display * dsp,Window win,Pixmap icon,Pixmap mask ) |
1297 { | |
1298 XWMHints * wm; | |
1299 long data[2]; | |
1300 Atom iconatom; | |
1301 | |
1302 wm=XGetWMHints( dsp,win ); | |
1303 if ( !wm ) wm=XAllocWMHints(); | |
1304 | |
1305 wm->icon_pixmap=icon; | |
1306 wm->icon_mask=mask; | |
1307 wm->flags|=IconPixmapHint | IconMaskHint; | |
1308 | |
1309 XSetWMHints( dsp,win,wm ); | |
1310 | |
1311 data[0]=icon; | |
1312 data[1]=mask; | |
1313 iconatom=XInternAtom( dsp,"KWM_WIN_ICON",0 ); | |
1314 XChangeProperty( dsp,win,iconatom,iconatom,32,PropModeReplace,(unsigned char *)data,2 ); | |
1315 | |
1316 XFree( wm ); | |
1317 } | |
1318 | |
1693 | 1319 #include "wsmkeys.h" |