annotate gui/wm/ws.c @ 29074:cbb6483b9463

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