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