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