annotate gui/wm/ws.c @ 32741:872b714d47bd

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