annotate gui/wm/ws.c @ 24650:f4143e50206d

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