Mercurial > mplayer.hg
annotate Gui/wm/ws.c @ 6619:f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
author | pontscho |
---|---|
date | Tue, 02 Jul 2002 13:35:04 +0000 |
parents | a4bbda72ce86 |
children | da08877b9512 |
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 | |
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 { | |
877 win->ReDraw( wsDisplay,win->WindowID ); | |
878 XFlush( wsDisplay ); | |
879 } | |
880 } | |
881 | |
882 // ---------------------------------------------------------------------------------------------- | |
883 // Do Exit. | |
884 // ---------------------------------------------------------------------------------------------- | |
885 void wsDoExit( void ) | |
886 { wsTrue=False; wsResizeWindow( wsWindowList[0],32,32 ); } | |
887 | |
888 // ---------------------------------------------------------------------------------------------- | |
889 // Put 'Image' to window. | |
890 // ---------------------------------------------------------------------------------------------- | |
891 void wsConvert( wsTWindow * win,unsigned char * Image,unsigned int Size ) | |
2733 | 892 { if ( wsConvFunc ) wsConvFunc( Image,win->ImageData,win->xImage->width * win->xImage->height * 4 ); } |
1693 | 893 |
894 void wsPutImage( wsTWindow * win ) | |
895 { | |
896 if ( wsUseXShm ) | |
897 { | |
898 XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
899 0,0, | |
900 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
901 win->xImage->width,win->xImage->height,0 ); | |
902 } | |
903 else | |
904 { | |
905 XPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, | |
906 0,0, | |
907 ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, | |
908 win->xImage->width,win->xImage->height ); | |
909 } | |
910 } | |
911 | |
912 // ---------------------------------------------------------------------------------------------- | |
913 // Move window to x, y. | |
914 // ---------------------------------------------------------------------------------------------- | |
2854 | 915 void wsMoveWindow( wsTWindow * win,int b,int x, int y ) |
1693 | 916 { |
2854 | 917 if ( b ) |
1693 | 918 { |
2854 | 919 switch ( x ) |
920 { | |
921 case -1: win->X=( wsMaxX / 2 ) - ( win->Width / 2 ); break; | |
922 case -2: win->X=wsMaxX - win->Width; break; | |
923 default: win->X=x; break; | |
924 } | |
925 switch ( y ) | |
926 { | |
927 case -1: win->Y=( wsMaxY / 2 ) - ( win->Height / 2 ); break; | |
928 case -2: win->Y=wsMaxY - win->Height; break; | |
929 default: win->Y=y; break; | |
930 } | |
1693 | 931 } |
2854 | 932 else { win->X=x; win->Y=y; } |
1693 | 933 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
934 win->SizeHint.flags=PPosition | PWinGravity; |
1693 | 935 win->SizeHint.x=win->X; |
936 win->SizeHint.y=win->Y; | |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
937 win->SizeHint.win_gravity=StaticGravity; |
1693 | 938 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
939 | |
940 XMoveWindow( wsDisplay,win->WindowID,win->X,win->Y ); | |
1810 | 941 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 942 } |
943 | |
944 // ---------------------------------------------------------------------------------------------- | |
945 // Resize window to sx, sy. | |
946 // ---------------------------------------------------------------------------------------------- | |
947 void wsResizeWindow( wsTWindow * win,int sx, int sy ) | |
948 { | |
949 win->Width=sx; | |
950 win->Height=sy; | |
951 | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
952 win->SizeHint.flags=PPosition | PSize | PWinGravity;// | PBaseSize; |
5986 | 953 win->SizeHint.x=win->X; |
954 win->SizeHint.y=win->Y; | |
1693 | 955 win->SizeHint.width=win->Width; |
956 win->SizeHint.height=win->Height; | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
957 |
1693 | 958 if ( win->Property & wsMinSize ) |
959 { | |
960 win->SizeHint.flags|=PMinSize; | |
961 win->SizeHint.min_width=win->Width; | |
962 win->SizeHint.min_height=win->Height; | |
963 } | |
964 if ( win->Property & wsMaxSize ) | |
965 { | |
966 win->SizeHint.flags|=PMaxSize; | |
967 win->SizeHint.max_width=win->Width; | |
968 win->SizeHint.max_height=win->Height; | |
969 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
970 |
2851
b64fa5d25142
add roleld mouse support and some small bugfix. neked jol a testedbe.
pontscho
parents:
2782
diff
changeset
|
971 win->SizeHint.win_gravity=StaticGravity; |
5986 | 972 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
|
973 |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
974 if ( wsWMType == wsWMUnknown ) XUnmapWindow( wsDisplay,win->WindowID ); |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
975 |
1693 | 976 XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); |
977 XResizeWindow( wsDisplay,win->WindowID,sx,sy ); | |
5986 | 978 XMapRaised( wsDisplay,win->WindowID ); |
1810 | 979 if ( win->ReSize ) win->ReSize( win->X,win->Y,win->Width,win->Height ); |
1693 | 980 } |
981 | |
982 // ---------------------------------------------------------------------------------------------- | |
983 // Iconify window. | |
984 // ---------------------------------------------------------------------------------------------- | |
985 void wsIconify( wsTWindow win ) | |
986 { XIconifyWindow( wsDisplay,win.WindowID,0 ); } | |
987 | |
988 // ---------------------------------------------------------------------------------------------- | |
989 // Move top the window. | |
990 // ---------------------------------------------------------------------------------------------- | |
6146 | 991 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
|
992 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
993 switch ( wsWMType ) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
994 { |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
995 case wsWMIceWM: |
6146 | 996 XUnmapWindow( wsDisplay,win ); |
997 XMapWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
998 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
999 case wsWMNetWM: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1000 case wsWMKDE: |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1001 { |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1002 XEvent e; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1003 e.xclient.type=ClientMessage; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1004 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
|
1005 e.xclient.display=wsDisplay; |
6146 | 1006 e.xclient.window=win; |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1007 e.xclient.format=32; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1008 e.xclient.data.l[0]=0; |
6146 | 1009 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
|
1010 break; |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1011 } |
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1012 default: |
6146 | 1013 XMapRaised( wsDisplay,win ); |
1014 XRaiseWindow( wsDisplay,win ); | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
1015 break; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1016 } |
2045 | 1017 } |
1693 | 1018 |
1019 // ---------------------------------------------------------------------------------------------- | |
1020 // Set window background to 'color'. | |
1021 // ---------------------------------------------------------------------------------------------- | |
1022 void wsSetBackground( wsTWindow * win,int color ) | |
1023 { XSetWindowBackground( wsDisplay,win->WindowID,color ); } | |
1024 | |
1025 void wsSetBackgroundRGB( wsTWindow * win,int r,int g,int b ) | |
1026 { | |
1027 int color = 0; | |
1028 switch ( wsOutMask ) | |
1029 { | |
1030 case wsRGB32: | |
1031 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1032 case wsBGR32: | |
1033 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1034 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1035 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1036 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1037 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1693 | 1038 } |
1039 XSetWindowBackground( wsDisplay,win->WindowID,color ); | |
1040 } | |
1041 | |
1814 | 1042 void wsSetForegroundRGB( wsTWindow * win,int r,int g,int b ) |
1043 { | |
1044 int color = 0; | |
1045 switch ( wsOutMask ) | |
1046 { | |
1047 case wsRGB32: | |
1048 case wsRGB24: color=( r << 16 ) + ( g << 8 ) + b; break; | |
1049 case wsBGR32: | |
1050 case wsBGR24: color=( b << 16 ) + ( g << 8 ) + r; break; | |
2733 | 1051 case wsRGB16: PACK_RGB16( b,g,r,color ); break; |
1052 case wsBGR16: PACK_RGB16( r,g,b,color ); break; | |
1053 case wsRGB15: PACK_RGB15( b,g,r,color ); break; | |
1054 case wsBGR15: PACK_RGB15( r,g,b,color ); break; | |
1814 | 1055 } |
1056 XSetForeground( wsDisplay,win->wGC,color ); | |
1057 } | |
1693 | 1058 |
1059 // ---------------------------------------------------------------------------------------------- | |
1060 // Draw string at x,y with fc ( foreground color ) and bc ( background color ). | |
1061 // ---------------------------------------------------------------------------------------------- | |
1062 void wsDrawString( wsTWindow win,int x,int y,char * str,int fc,int bc ) | |
1063 { | |
1064 XSetForeground( wsDisplay,win.wGC,bc ); | |
1065 XFillRectangle( wsDisplay,win.WindowID,win.wGC,x,y, | |
1066 XTextWidth( win.Font,str,strlen( str ) ) + 20, | |
1067 win.FontHeight + 2 ); | |
1068 XSetForeground( wsDisplay,win.wGC,fc ); | |
1069 XDrawString( wsDisplay,win.WindowID,win.wGC,x + 10,y + 13,str,strlen( str ) ); | |
1070 } | |
1071 | |
1072 // ---------------------------------------------------------------------------------------------- | |
1073 // Calculation string width. | |
1074 // ---------------------------------------------------------------------------------------------- | |
1075 int wsTextWidth( wsTWindow win,char * str ) | |
1076 { return XTextWidth( win.Font,str,strlen( str ) ) + 20; } | |
1077 | |
1078 // ---------------------------------------------------------------------------------------------- | |
1079 // Show / hide mouse cursor. | |
1080 // ---------------------------------------------------------------------------------------------- | |
1081 void wsVisibleMouse( wsTWindow * win,int m ) | |
1082 { | |
1083 switch ( m ) | |
1084 { | |
1085 case wsShowMouseCursor: | |
1086 if ( win->wsCursor != None ) | |
1087 { | |
1088 XFreeCursor( wsDisplay,win->wsCursor ); | |
1089 win->wsCursor=None; | |
1090 } | |
1091 XDefineCursor( wsDisplay,win->WindowID,0 ); | |
1092 break; | |
1093 case wsHideMouseCursor: | |
1094 win->wsCursor=XCreatePixmapCursor( wsDisplay,win->wsCursorPixmap,win->wsCursorPixmap,&win->wsColor,&win->wsColor,0,0 ); | |
1095 XDefineCursor( wsDisplay,win->WindowID,win->wsCursor ); | |
1096 break; | |
1097 } | |
1098 XFlush( wsDisplay ); | |
1099 } | |
1100 | |
1101 int wsGetDepthOnScreen( void ) | |
1102 { | |
1103 int bpp,ibpp; | |
1104 XImage * mXImage; | |
1105 XWindowAttributes attribs; | |
1106 | |
1107 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1108 bpp=mXImage->bits_per_pixel; | |
1109 | |
1110 XGetWindowAttributes( wsDisplay,wsRootWin,&attribs ); | |
1111 ibpp=attribs.depth; | |
1112 mXImage=XGetImage( wsDisplay,wsRootWin,0,0,1,1,AllPlanes,ZPixmap ); | |
1113 bpp=mXImage->bits_per_pixel; | |
1114 if ( ( ibpp + 7 ) / 8 != ( bpp + 7 ) / 8 ) ibpp=bpp; | |
1115 wsDepthOnScreen=ibpp; | |
1116 wsRedMask=mXImage->red_mask; | |
1117 wsGreenMask=mXImage->green_mask; | |
1118 wsBlueMask=mXImage->blue_mask; | |
1119 XDestroyImage( mXImage ); | |
1120 return ibpp; | |
1121 } | |
1122 | |
1123 void wsXDone( void ) | |
1124 { | |
1125 XCloseDisplay( wsDisplay ); | |
1126 } | |
1127 | |
1128 void wsVisibleWindow( wsTWindow * win,int show ) | |
1129 { | |
1130 switch( show ) | |
1131 { | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
1132 case wsShowWindow: XMapRaised( wsDisplay,win->WindowID ); break; |
1693 | 1133 case wsHideWindow: XUnmapWindow( wsDisplay,win->WindowID ); break; |
1134 } | |
1135 XFlush( wsDisplay ); | |
1136 } | |
1137 | |
1138 void wsDestroyImage( wsTWindow * win ) | |
1139 { | |
1140 if ( win->xImage ) | |
1141 { | |
1142 XDestroyImage( win->xImage ); | |
1143 if ( wsUseXShm ) | |
1144 { | |
1145 XShmDetach( wsDisplay,&win->Shminfo ); | |
1146 shmdt( win->Shminfo.shmaddr ); | |
1147 } | |
1148 } | |
1149 win->xImage=NULL; | |
1150 } | |
1151 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1152 void wsCreateImage( wsTWindow * win,int Width,int Height ) |
1693 | 1153 { |
1154 int CompletionType = -1; | |
1155 if ( wsUseXShm ) | |
1156 { | |
1157 CompletionType=XShmGetEventBase( wsDisplay ) + ShmCompletion; | |
1158 win->xImage=XShmCreateImage( wsDisplay,win->VisualInfo.visual, | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1159 win->Attribs.depth,ZPixmap,NULL,&win->Shminfo,Width,Height ); |
1693 | 1160 if ( win->xImage == NULL ) |
1161 { | |
5919 | 1162 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1163 exit( 0 ); |
1164 } | |
1165 win->Shminfo.shmid=shmget( IPC_PRIVATE,win->xImage->bytes_per_line * win->xImage->height,IPC_CREAT|0777 ); | |
1166 if ( win->Shminfo.shmid < 0 ) | |
1167 { | |
1168 XDestroyImage( win->xImage ); | |
5919 | 1169 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1170 exit( 0 ); |
1171 } | |
1172 win->Shminfo.shmaddr=(char *)shmat( win->Shminfo.shmid,0,0 ); | |
1173 | |
1174 if ( win->Shminfo.shmaddr == ((char *) -1) ) | |
1175 { | |
1176 XDestroyImage( win->xImage ); | |
1177 if ( win->Shminfo.shmaddr != ((char *) -1) ) shmdt( win->Shminfo.shmaddr ); | |
5919 | 1178 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] shared memory extension error.\n" ); |
1693 | 1179 exit( 0 ); |
1180 } | |
1181 win->xImage->data=win->Shminfo.shmaddr; | |
1182 win->Shminfo.readOnly=0; | |
1183 XShmAttach( wsDisplay,&win->Shminfo ); | |
1184 shmctl( win->Shminfo.shmid,IPC_RMID,0 ); | |
1185 } | |
1186 else | |
1187 { | |
1188 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
|
1189 ZPixmap,0,0,Width,Height, |
1693 | 1190 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen, |
1191 0 ); | |
1192 if ( ( win->xImage->data=malloc( win->xImage->bytes_per_line * win->xImage->height ) ) == NULL ) | |
1193 { | |
5919 | 1194 mp_msg( MSGT_GPLAYER,MSGL_FATAL,"[ws] sorry, not enough memory for draw buffer.\n" ); |
1693 | 1195 exit( 0 ); |
1196 } | |
1197 } | |
1198 win->ImageData=(unsigned char *)win->xImage->data; | |
1199 win->ImageDataw=(unsigned short int *)win->xImage->data; | |
1200 win->ImageDatadw=(unsigned int *)win->xImage->data; | |
1201 } | |
1202 | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1203 void wsResizeImage( wsTWindow * win,int Width,int Height ) |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1853
diff
changeset
|
1204 { wsDestroyImage( win ); wsCreateImage( win,Width,Height ); } |
1693 | 1205 |
1206 int wsGetOutMask( void ) | |
1207 { | |
1208 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB32; | |
1209 if ( ( wsDepthOnScreen == 32 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR32; | |
1210 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0xff0000 )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0x0000ff ) ) return wsRGB24; | |
1211 if ( ( wsDepthOnScreen == 24 )&&( wsRedMask == 0x0000ff )&&( wsGreenMask == 0x00ff00 )&&( wsBlueMask == 0xff0000 ) ) return wsBGR24; | |
1212 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0xf800 )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB16; | |
1213 if ( ( wsDepthOnScreen == 16 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x7e0 )&&( wsBlueMask == 0xf800 ) ) return wsBGR16; | |
1214 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x7c00 )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x1f ) ) return wsRGB15; | |
1215 if ( ( wsDepthOnScreen == 15 )&&( wsRedMask == 0x1f )&&( wsGreenMask == 0x3e0 )&&( wsBlueMask == 0x7c00 ) ) return wsBGR15; | |
1216 return 0; | |
1217 } | |
1218 | |
1219 void wsSetTitle( wsTWindow * win,char * name ) | |
1220 { XStoreName( wsDisplay,win->WindowID,name ); } | |
1221 | |
1222 void wsSetMousePosition( wsTWindow * win,int x, int y ) | |
1223 { XWarpPointer( wsDisplay,wsRootWin,win->WindowID,0,0,0,0,x,y ); } | |
1224 | |
1225 static int dpms_disabled=0; | |
1226 static int timeout_save=0; | |
1227 | |
1228 void wsScreenSaverOn( Display *mDisplay ) | |
1229 { | |
1230 int nothing; | |
4566 | 1231 #ifdef HAVE_XDPMS |
1693 | 1232 if ( dpms_disabled ) |
1233 { | |
1234 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) | |
1235 { | |
5919 | 1236 if ( !DPMSEnable( mDisplay ) ) mp_msg( MSGT_GPLAYER,MSGL_ERR,"DPMS not available ?\n" ); // restoring power saving settings |
1693 | 1237 else |
1238 { | |
1239 // DPMS does not seem to be enabled unless we call DPMSInfo | |
1240 BOOL onoff; | |
1241 CARD16 state; | |
1242 DPMSInfo( mDisplay,&state,&onoff ); | |
5919 | 1243 if ( onoff ) mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Successfully enabled DPMS.\n" ); |
1244 else mp_msg( MSGT_GPLAYER,MSGL_STATUS,"Could not enable DPMS.\n" ); | |
1693 | 1245 } |
1246 } | |
1247 } | |
4566 | 1248 #endif |
1693 | 1249 if ( timeout_save ) |
1250 { | |
1251 int dummy, interval, prefer_blank, allow_exp; | |
1252 XGetScreenSaver( mDisplay,&dummy,&interval,&prefer_blank,&allow_exp ); | |
1253 XSetScreenSaver( mDisplay,timeout_save,interval,prefer_blank,allow_exp ); | |
1254 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); | |
1255 } | |
1256 } | |
1257 | |
1258 void wsScreenSaverOff( Display * mDisplay ) | |
1259 { | |
1260 int interval,prefer_blank,allow_exp,nothing; | |
4566 | 1261 #ifdef HAVE_XDPMS |
1693 | 1262 if ( DPMSQueryExtension( mDisplay,¬hing,¬hing ) ) |
1263 { | |
1264 BOOL onoff; | |
1265 CARD16 state; | |
1266 DPMSInfo( mDisplay,&state,&onoff ); | |
1267 if ( onoff ) | |
1268 { | |
1269 Status stat; | |
5919 | 1270 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"Disabling DPMS.\n" ); |
1693 | 1271 dpms_disabled=1; |
1272 stat=DPMSDisable( mDisplay ); // monitor powersave off | |
5919 | 1273 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"stat: %d.\n",stat ); |
1693 | 1274 } |
1275 } | |
4566 | 1276 #endif |
1693 | 1277 XGetScreenSaver( mDisplay,&timeout_save,&interval,&prefer_blank,&allow_exp ); |
1278 if ( timeout_save ) XSetScreenSaver( mDisplay,0,interval,prefer_blank,allow_exp ); // turning off screensaver | |
1279 } | |
1280 | |
1281 void wsSetShape( wsTWindow * win,char * data ) | |
1282 { | |
1283 #ifdef HAVE_XSHAPE | |
1852 | 1284 if ( !wsUseXShape ) return; |
1285 if ( data ) | |
1286 { | |
1287 win->Mask=XCreateBitmapFromData( wsDisplay,win->WindowID,data,win->Width,win->Height ); | |
1288 XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,win->Mask,ShapeSet ); | |
1289 XFreePixmap( wsDisplay,win->Mask ); | |
1290 } | |
1291 else XShapeCombineMask( wsDisplay,win->WindowID,ShapeBounding,0,0,None,ShapeSet ); | |
1693 | 1292 #endif |
1293 } | |
1294 | |
1295 #include "wsmkeys.h" |