annotate gui/wm/ws.c @ 31137:72638e3330a3

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