annotate gui/wm/ws.c @ 33544:b71fac188432

Check whether a specific icon is available. If icons are no longer included in the source, but will be read from files, then reading may fail and a particular icon (size) may not be available. This is a preparation for differently sized icons to come.
author ib
date Thu, 16 Jun 2011 17:40:55 +0000
parents 10f9498fada1
children 38aee97cc4fc
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
33123
9566100d88a1 Replace inttypes.h by stdint.h and remove inttypes.h where unneeded.
ib
parents: 32833
diff changeset
34 #include <stdint.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35
33264
284fc94290b9 Replace all GUI exits by guiExit().
ib
parents: 33123
diff changeset
36 #include "gui/interface.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
37 #include "config.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
38 #include "libvo/x11_common.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
39 #include "libvo/video_out.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
40 #include "cpudetect.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
41 #include "libswscale/swscale.h"
32833
c4891d10ddbb Adjust #include paths after the merge of libavcore into libavutil in FFmpeg.
diego
parents: 32741
diff changeset
42 #include "libavutil/imgutils.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
43 #include "libmpcodecs/vf_scale.h"
33264
284fc94290b9 Replace all GUI exits by guiExit().
ib
parents: 33123
diff changeset
44 #include "mp_core.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
45 #include "mp_msg.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
46 #include "help_mp.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
47 #include "mplayer.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 23795
diff changeset
48 #include "mpbswap.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 #include "ws.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 #include "wsxdnd.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52 #include <X11/extensions/XShm.h>
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
53 #ifdef CONFIG_XSHAPE
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54 #include <X11/extensions/shape.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
57 #ifdef CONFIG_XINERAMA
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 #include <X11/extensions/Xinerama.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
61 #ifdef CONFIG_XF86VM
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 #include <X11/extensions/xf86vmode.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 #include <sys/ipc.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 #include <sys/shm.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
68 #undef ENABLE_DPMS
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
70 typedef struct {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
71 unsigned long flags;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
72 unsigned long functions;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
73 unsigned long decorations;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
74 long input_mode;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
75 unsigned long status;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 } MotifWmHints;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
78 Atom wsMotifHints;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
80 int wsMaxX = 0; // Screen width.
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
81 int wsMaxY = 0; // Screen height.
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
82 int wsOrgX = 0; // Screen origin x.
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
83 int wsOrgY = 0; // Screen origin y.
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
85 Display *wsDisplay;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
86 int wsScreen;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
87 Window wsRootWin;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
88 XEvent wsEvent;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
89 int wsWindowDepth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
90 GC wsHGC;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
91 MotifWmHints wsMotifWmHints;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
92 Atom wsTextProperlyAtom = None;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
93 int wsLayer = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
95 int wsDepthOnScreen = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
96 int wsRedMask = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
97 int wsGreenMask = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
98 int wsBlueMask = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
99 int wsOutMask = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
100 int wsNonNativeOrder = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
102 int wsTrue = True;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
104 #define wsWLCount 5
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
105 wsTWindow *wsWindowList[wsWLCount] = { NULL, NULL, NULL, NULL, NULL };
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
106
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
107 unsigned long wsKeyTable[512];
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
109 int wsUseXShm = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
110 int wsUseXShape = 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
112 static int wsSearch(Window win)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
113 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
114 int i;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
116 for (i = 0; i < wsWLCount; i++)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
117 if (wsWindowList[i] && wsWindowList[i]->WindowID == win)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
118 return i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
119
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
120 return -1;
31325
e45b8fb721fd Move wsSearch function and make it static.
reimar
parents: 31324
diff changeset
121 }
e45b8fb721fd Move wsSearch function and make it static.
reimar
parents: 31324
diff changeset
122
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 // ---
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
125 #define PACK_RGB16(r, g, b, pixel) pixel = (b >> 3); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
126 pixel <<= 6; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
127 pixel |= (g >> 2); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
128 pixel <<= 5; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
129 pixel |= (r >> 3)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
131 #define PACK_RGB15(r, g, b, pixel) pixel = (b >> 3); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
132 pixel <<= 5; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
133 pixel |= (g >> 3); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
134 pixel <<= 5; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
135 pixel |= (r >> 3)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
137 struct SwsContext *sws_ctx = NULL;
32028
9e6fdede8ece gui: remove direct usage of rgb2rgb interface, use swscale instead
ramiro
parents: 31325
diff changeset
138 enum PixelFormat out_pix_fmt = PIX_FMT_NONE;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 // ---
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 #define MWM_HINTS_FUNCTIONS (1L << 0)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 #define MWM_HINTS_DECORATIONS (1L << 1)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 #define MWM_HINTS_INPUT_MODE (1L << 2)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 #define MWM_HINTS_STATUS (1L << 3)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 #define MWM_FUNC_ALL (1L << 0)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 #define MWM_FUNC_RESIZE (1L << 1)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 #define MWM_FUNC_MOVE (1L << 2)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 #define MWM_FUNC_MINIMIZE (1L << 3)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151 #define MWM_FUNC_MAXIMIZE (1L << 4)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 #define MWM_FUNC_CLOSE (1L << 5)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 #define MWM_DECOR_ALL (1L << 0)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 #define MWM_DECOR_BORDER (1L << 1)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 #define MWM_DECOR_RESIZEH (1L << 2)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 #define MWM_DECOR_TITLE (1L << 3)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 #define MWM_DECOR_MENU (1L << 4)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 #define MWM_DECOR_MINIMIZE (1L << 5)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 #define MWM_DECOR_MAXIMIZE (1L << 6)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 #define MWM_INPUT_MODELESS 0
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 #define MWM_INPUT_SYSTEM_MODAL 2
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
168 #define MWM_TEAROFF_WINDOW (1L << 0)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
170 void wsWindowDecoration(wsTWindow *win, long d)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
172 wsMotifHints = XInternAtom(wsDisplay, "_MOTIF_WM_HINTS", 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
173
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
174 if (wsMotifHints == None)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
175 return;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
177 memset(&wsMotifWmHints, 0, sizeof(MotifWmHints));
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
178 wsMotifWmHints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
179
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
180 if (d) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
181 wsMotifWmHints.functions = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
182 wsMotifWmHints.decorations = MWM_DECOR_ALL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
183 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
184
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
185 XChangeProperty(wsDisplay, win->WindowID, wsMotifHints, wsMotifHints, 32,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
186 PropModeReplace, (unsigned char *)&wsMotifWmHints, 5);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 // Init X Window System.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
193 static int wsErrorHandler(Display *dpy, XErrorEvent *Event)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
195 char type[128];
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
196
33541
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
197 XGetErrorText(dpy, Event->error_code, type, 128);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
198 fprintf(stderr, "[ws] Error in display.\n");
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
199 fprintf(stderr, "[ws] Error code: %d ( %s )\n", Event->error_code, type);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
200 fprintf(stderr, "[ws] Request code: %d\n", Event->request_code);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
201 fprintf(stderr, "[ws] Minor code: %d\n", Event->minor_code);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
202 fprintf(stderr, "[ws] Modules: %s\n", current_module ? current_module : "(NULL)");
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
203 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
206 void wsXInit(Display *mDisplay)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
208 int eventbase;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
209 int errorbase;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
211 // NOTE TO MYSELF: Use global mDisplay, get rid of wsDisplay.
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
212 wsDisplay = mDisplay;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
214 XSetErrorHandler(wsErrorHandler);
31323
c674bb16fa6d Install error handler as early as possible to avoid crashing.
reimar
parents: 31314
diff changeset
215
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216 /* enable DND atoms */
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
217 wsXDNDInitialize();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
218
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
219 { /* on remote display XShm will be disabled - LGB */
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
220 char *dispname = DisplayString(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
221 int localdisp = 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
222
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
223 if (dispname && *dispname != ':') {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
224 localdisp = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
225 wsUseXShm = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
226 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
227
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
228 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[ws] display name: %s => %s display.\n", dispname, localdisp ? "local" : "REMOTE");
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
230 if (!localdisp)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
231 mp_msg(MSGT_GPLAYER, MSGL_V, MSGTR_WS_RemoteDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
232 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
233
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
234 if (!XShmQueryExtension(wsDisplay)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
235 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_WS_NoXshm);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
236 wsUseXShm = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
237 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
238
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
239 #ifdef CONFIG_XSHAPE
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
240
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
241 if (!XShapeQueryExtension(wsDisplay, &eventbase, &errorbase)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
242 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_WS_NoXshape);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
243 wsUseXShape = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
244 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
245
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 #else
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
247 wsUseXShape = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
250 XSynchronize(wsDisplay, True);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
251
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
252 wsScreen = DefaultScreen(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
253 wsRootWin = RootWindow(wsDisplay, wsScreen);
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
254 #ifdef CONFIG_XF86VM
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
255 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
256 int clock;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
257 XF86VidModeModeLine modeline;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
258
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
259 XF86VidModeGetModeLine(wsDisplay, wsScreen, &clock, &modeline);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
260 wsMaxX = modeline.hdisplay;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
261 wsMaxY = modeline.vdisplay;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
262 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
263 #endif
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
264 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
265 wsOrgX = wsOrgY = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
266
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
267 if (!wsMaxX)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
268 wsMaxX = DisplayWidth(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
269
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
270 if (!wsMaxY)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
271 wsMaxY = DisplayHeight(wsDisplay, wsScreen);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
272 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
273 vo_screenwidth = wsMaxX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
274 vo_screenheight = wsMaxY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
275 xinerama_x = wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
276 xinerama_y = wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
277 update_xinerama_info();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
278 wsMaxX = vo_screenwidth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
279 wsMaxY = vo_screenheight;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
280 wsOrgX = xinerama_x;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
281 wsOrgY = xinerama_y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
282
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
283 wsGetDepthOnScreen();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
284 #ifdef DEBUG
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
285 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
286 int minor, major, shp;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
287 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] Screen depth: %d\n", wsDepthOnScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
288 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] size: %dx%d\n", wsMaxX, wsMaxY);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
289 #ifdef CONFIG_XINERAMA
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
290 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] origin: +%d+%d\n", wsOrgX, wsOrgY);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
291 #endif
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
292 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] red mask: 0x%x\n", wsRedMask);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
293 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] green mask: 0x%x\n", wsGreenMask);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
294 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] blue mask: 0x%x\n", wsBlueMask);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
295
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
296 if (wsUseXShm) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
297 XShmQueryVersion(wsDisplay, &major, &minor, &shp);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
298 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] XShm version is %d.%d\n", major, minor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
299 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
300
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
301 #ifdef CONFIG_XSHAPE
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
302
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
303 if (wsUseXShape) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
304 XShapeQueryVersion(wsDisplay, &major, &minor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
305 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] XShape version is %d.%d\n", major, minor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
306 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
307
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
308 #endif
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
309 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
310 #endif
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
311 wsOutMask = wsGetOutMask();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
312
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
313 switch (wsOutMask) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
314 case wsRGB32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
315 out_pix_fmt = PIX_FMT_RGB32;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
316 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
317
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
318 case wsBGR32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
319 out_pix_fmt = PIX_FMT_BGR32;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
320 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
321
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
322 case wsRGB24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
323 out_pix_fmt = PIX_FMT_RGB24;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
324 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
325
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
326 case wsBGR24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
327 out_pix_fmt = PIX_FMT_BGR24;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
328 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
329
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
330 case wsRGB16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
331 out_pix_fmt = PIX_FMT_RGB565;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
332 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
333
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
334 case wsBGR16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
335 out_pix_fmt = PIX_FMT_BGR565;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
336 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
337
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
338 case wsRGB15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
339 out_pix_fmt = PIX_FMT_RGB555;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
340 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
341
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
342 case wsBGR15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
343 out_pix_fmt = PIX_FMT_BGR555;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
344 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
345 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
346 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
347
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
348 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
349 // Create window.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
350 // X,Y : window position
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
351 // wX,wY : size of window
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
352 // bW : border width
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
353 // cV : visible mouse cursor on window
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
354 // D : visible frame, title, etc.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
355 // sR : screen ratio
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
356 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
357
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
358 XClassHint wsClassHint;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
359 XTextProperty wsTextProperty;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
360 Window LeaderWindow;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
361
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
362 void wsCreateWindow(wsTWindow *win, int X, int Y, int wX, int hY, int bW, int cV, unsigned char D, char *label)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
363 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
364 int depth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
365
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
366 win->Property = D;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
367
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
368 if (D & wsShowFrame)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
369 win->Decorations = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
370
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
371 wsHGC = DefaultGC(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
372
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
373 // The window position and size.
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
374 switch (X) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
375 case -1:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
376 win->X = (wsMaxX / 2) - (wX / 2) + wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
377 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
378
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
379 case -2:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
380 win->X = wsMaxX - wX - 1 + wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
381 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
382
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
383 default:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
384 win->X = X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
385 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
386 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
387
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
388 switch (Y) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
389 case -1:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
390 win->Y = (wsMaxY / 2) - (hY / 2) + wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
391 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
392
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
393 case -2:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
394 win->Y = wsMaxY - hY - 1 + wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
395 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
396
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
397 default:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
398 win->Y = Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
399 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
400 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
401
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
402 win->Width = wX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
403 win->Height = hY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
404 win->OldX = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
405 win->OldY = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
406 win->OldWidth = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
407 win->OldHeight = win->Height;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
408
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
409 // Border size for window.
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
410 win->BorderWidth = bW;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
411 // Hide Mouse Cursor
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
412 win->wsCursor = None;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
413 win->wsMouseEventType = cV;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
414 win->wsCursorData[0] = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
415 win->wsCursorPixmap = XCreateBitmapFromData(wsDisplay, wsRootWin, win->wsCursorData, 1, 1);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
416
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
417 if (!(cV & wsShowMouseCursor))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
418 win->wsCursor = XCreatePixmapCursor(wsDisplay, win->wsCursorPixmap, win->wsCursorPixmap, &win->wsColor, &win->wsColor, 0, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
419
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
420 depth = vo_find_depth_from_visuals(wsDisplay, wsScreen, NULL);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
421
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
422 if (depth < 15) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
423 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ColorDepthTooLow);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
424 guiExit(EXIT_ERROR);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
425 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
426
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
427 XMatchVisualInfo(wsDisplay, wsScreen, depth, TrueColor, &win->VisualInfo);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
428
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
429 // ---
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
430 win->AtomLeaderClient = XInternAtom(wsDisplay, "WM_CLIENT_LEADER", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
431 win->AtomDeleteWindow = XInternAtom(wsDisplay, "WM_DELETE_WINDOW", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
432 win->AtomTakeFocus = XInternAtom(wsDisplay, "WM_TAKE_FOCUS", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
433 win->AtomRolle = XInternAtom(wsDisplay, "WM_WINDOW_ROLE", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
434 win->AtomWMSizeHint = XInternAtom(wsDisplay, "WM_SIZE_HINT", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
435 win->AtomWMNormalHint = XInternAtom(wsDisplay, "WM_NORMAL_HINT", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
436 win->AtomProtocols = XInternAtom(wsDisplay, "WM_PROTOCOLS", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
437 win->AtomsProtocols[0] = win->AtomDeleteWindow;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
438 win->AtomsProtocols[1] = win->AtomTakeFocus;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
439 win->AtomsProtocols[2] = win->AtomRolle;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
440 // ---
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
441
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
442 win->WindowAttrib.background_pixel = BlackPixel(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
443 win->WindowAttrib.border_pixel = WhitePixel(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
444 win->WindowAttrib.colormap = XCreateColormap(wsDisplay, wsRootWin, win->VisualInfo.visual, AllocNone);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
445 win->WindowAttrib.event_mask = StructureNotifyMask | FocusChangeMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
446 ExposureMask | PropertyChangeMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
447 EnterWindowMask | LeaveWindowMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
448 VisibilityChangeMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
449 KeyPressMask | KeyReleaseMask;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
450
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
451 if ((cV & wsHandleMouseButton))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
452 win->WindowAttrib.event_mask |= ButtonPressMask | ButtonReleaseMask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
453
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
454 if ((cV & wsHandleMouseMove))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
455 win->WindowAttrib.event_mask |= PointerMotionMask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
456
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
457 win->WindowAttrib.cursor = win->wsCursor;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
458 win->WindowAttrib.override_redirect = False;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
459
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
460 if (D & wsOverredirect)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
461 win->WindowAttrib.override_redirect = True;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
462
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
463 win->WindowMask = CWBackPixel | CWBorderPixel |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
464 CWColormap | CWEventMask | CWCursor |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
465 CWOverrideRedirect;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
466
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
467 win->WindowID = XCreateWindow(wsDisplay,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
468 (win->Parent != 0 ? win->Parent : wsRootWin),
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
469 win->X, win->Y, win->Width, win->Height, win->BorderWidth,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
470 win->VisualInfo.depth,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
471 InputOutput,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
472 win->VisualInfo.visual,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
473 win->WindowMask, &win->WindowAttrib);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
474
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
475 wsClassHint.res_name = "MPlayer";
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
476
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
477 wsClassHint.res_class = "MPlayer";
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
478 XSetClassHint(wsDisplay, win->WindowID, &wsClassHint);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
479
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
480 win->SizeHint.flags = PPosition | PSize | PResizeInc | PWinGravity; // | PBaseSize;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
481 win->SizeHint.x = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
482 win->SizeHint.y = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
483 win->SizeHint.width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
484 win->SizeHint.height = win->Height;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
485
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
486 if (D & wsMinSize) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
487 win->SizeHint.flags |= PMinSize;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
488 win->SizeHint.min_width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
489 win->SizeHint.min_height = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
490 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
491
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
492 if (D & wsMaxSize) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
493 win->SizeHint.flags |= PMaxSize;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
494 win->SizeHint.max_width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
495 win->SizeHint.max_height = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
496 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
497
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
498 win->SizeHint.height_inc = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
499 win->SizeHint.width_inc = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
500 win->SizeHint.base_width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
501 win->SizeHint.base_height = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
502 win->SizeHint.win_gravity = StaticGravity;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
503 XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
504
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
505 win->WMHints.flags = InputHint | StateHint;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
506 win->WMHints.input = True;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
507 win->WMHints.initial_state = NormalState;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
508 XSetWMHints(wsDisplay, win->WindowID, &win->WMHints);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
509
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
510 wsWindowDecoration(win, win->Decorations);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
511 XStoreName(wsDisplay, win->WindowID, label);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
512 XmbSetWMProperties(wsDisplay, win->WindowID, label, label, NULL, 0, NULL, NULL, NULL);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
513
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
514 XSetWMProtocols(wsDisplay, win->WindowID, win->AtomsProtocols, 3);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
515 XChangeProperty(wsDisplay, win->WindowID,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
516 win->AtomLeaderClient,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
517 XA_WINDOW, 32, PropModeReplace,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
518 (unsigned char *)&LeaderWindow, 1);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
519
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
520 wsTextProperty.value = label;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
521 wsTextProperty.encoding = XA_STRING;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
522 wsTextProperty.format = 8;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
523 wsTextProperty.nitems = strlen(label);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
524 XSetWMIconName(wsDisplay, win->WindowID, &wsTextProperty);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
525
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
526 win->wGC = XCreateGC(wsDisplay, win->WindowID,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
527 GCForeground | GCBackground,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
528 &win->wGCV);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
529
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
530 win->Visible = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
531 win->Focused = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
532 win->Mapped = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
533 win->Rolled = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
534
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
535 if (D & wsShowWindow)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
536 XMapWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
537
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
538 wsCreateImage(win, win->Width, win->Height);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
539 // --- End of creating --------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
540
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
541 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
542 int i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
543
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
544 for (i = 0; i < wsWLCount; i++)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
545 if (wsWindowList[i] == NULL)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
546 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
547
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
548 if (i == wsWLCount) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
549 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_TooManyOpenWindows);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
550 guiExit(EXIT_ERROR);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
551 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
552
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
553 wsWindowList[i] = win;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
554 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
555
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
556 XFlush(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
557 XSync(wsDisplay, False);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
558
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
559 win->ReDraw = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
560 win->ReSize = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
561 win->Idle = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
562 win->MouseHandler = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
563 win->KeyHandler = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
564 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[ws] window is created. ( %s ).\n", label);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
565 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
566
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
567 void wsDestroyWindow(wsTWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
568 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
569 int l;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
570
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
571 l = wsSearch(win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
572 wsWindowList[l] = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
573
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
574 if (win->wsCursor != None) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
575 XFreeCursor(wsDisplay, win->wsCursor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
576 win->wsCursor = None;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
577 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
578
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
579 XFreeGC(wsDisplay, win->wGC);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
580 XUnmapWindow(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
581 wsDestroyImage(win);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
582 XDestroyWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
583 #if 0
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
584 win->ReDraw = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
585 win->ReSize = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
586 win->Idle = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
587 win->MouseHandler = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
588 win->KeyHandler = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
589 win->Visible = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
590 win->Focused = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
591 win->Mapped = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
592 win->Rolled = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
593 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
594 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
595
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
596 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
597 // Handle events.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
598 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
599
33541
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
600 Bool wsEvents(Display *display, XEvent *Event)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
601 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
602 unsigned long i = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
603 int l;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
604 int x, y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
605 Window child_window = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
606
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
607 l = wsSearch(Event->xany.window);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
608
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
609 if (l == -1)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
610 return !wsTrue;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
611
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
612 wsWindowList[l]->State = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
613
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
614 switch (Event->type) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
615 case ClientMessage:
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
616
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
617 if (Event->xclient.message_type == wsWindowList[l]->AtomProtocols) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
618 if ((Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
619 i = wsWindowClosed;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
620 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
621 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
622
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
623 if ((Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
624 i = wsWindowFocusIn;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
625 wsWindowList[l]->Focused = wsFocused;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
626 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
627 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
628
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
629 if ((Atom)Event->xclient.data.l[0] == wsWindowList[l]->AtomRolle) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
630 mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] role set.\n");
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
631 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
632 } else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
633 /* try to process DND events */
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
634 wsXDNDProcessClientMessage(wsWindowList[l], &Event->xclient);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
635 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
636
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
637 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
638
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
639 case MapNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
640 i = wsWindowMapped;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
641 wsWindowList[l]->Mapped = wsMapped;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
642 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
643
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
644 case UnmapNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
645 i = wsWindowUnmapped;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
646 wsWindowList[l]->Mapped = wsNone;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
647 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
648
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
649 case FocusIn:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
650
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
651 if (wsWindowList[l]->Focused == wsFocused)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
652 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
653
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
654 i = wsWindowFocusIn;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
655 wsWindowList[l]->Focused = wsFocused;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
656 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
657
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
658 case FocusOut:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
659
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
660 if (wsWindowList[l]->Focused == wsNone)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
661 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
662
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
663 i = wsWindowFocusOut;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
664 wsWindowList[l]->Focused = wsNone;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
665 goto expose;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
666
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
667 case VisibilityNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
668
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
669 switch (Event->xvisibility.state) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
670 case VisibilityUnobscured:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
671 i = wsWindowVisible;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
672 wsWindowList[l]->Visible = wsVisible;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
673 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
674
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
675 case VisibilityFullyObscured:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
676 i = wsWindowNotVisible;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
677 wsWindowList[l]->Visible = wsNotVisible;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
678 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
679
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
680 case VisibilityPartiallyObscured:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
681 i = wsWindowPartialVisible;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
682 wsWindowList[l]->Visible = wsPVisible;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
683 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
684 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
685
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
686 expose:
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
687 wsWindowList[l]->State = i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
688
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
689 if (wsWindowList[l]->ReDraw)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
690 wsWindowList[l]->ReDraw();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
691
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
692 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
693
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
694 case Expose:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
695 wsWindowList[l]->State = wsWindowExpose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
696
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
697 if ((wsWindowList[l]->ReDraw) && (!Event->xexpose.count))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
698 wsWindowList[l]->ReDraw();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
699
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
700 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
701
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
702 case ConfigureNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
703 XTranslateCoordinates(wsDisplay, wsWindowList[l]->WindowID, wsRootWin, 0, 0, &x, &y, &child_window);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
704
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
705 if ((wsWindowList[l]->X != x) || (wsWindowList[l]->Y != y) || (wsWindowList[l]->Width != Event->xconfigure.width) || (wsWindowList[l]->Height != Event->xconfigure.height)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
706 wsWindowList[l]->X = x;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
707 wsWindowList[l]->Y = y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
708 wsWindowList[l]->Width = Event->xconfigure.width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
709 wsWindowList[l]->Height = Event->xconfigure.height;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
710
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
711 if (wsWindowList[l]->ReSize)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
712 wsWindowList[l]->ReSize(wsWindowList[l]->X, wsWindowList[l]->Y, wsWindowList[l]->Width, wsWindowList[l]->Height);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
713 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
714
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
715 wsWindowList[l]->Rolled = wsNone;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
716
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
717 if (Event->xconfigure.y < 0) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
718 i = wsWindowRolled;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
719 wsWindowList[l]->Rolled = wsRolled;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
720 goto expose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
721 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
722
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
723 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
724
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
725 case KeyPress:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
726 i = wsKeyPressed;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
727 goto keypressed;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
728
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
729 case KeyRelease:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
730 i = wsKeyReleased;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
731 keypressed:
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
732 wsWindowList[l]->Alt = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
733 wsWindowList[l]->Shift = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
734 wsWindowList[l]->NumLock = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
735 wsWindowList[l]->Control = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
736 wsWindowList[l]->CapsLock = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
737
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
738 if (Event->xkey.state & Mod1Mask)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
739 wsWindowList[l]->Alt = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
740
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
741 if (Event->xkey.state & Mod2Mask)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
742 wsWindowList[l]->NumLock = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
743
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
744 if (Event->xkey.state & ControlMask)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
745 wsWindowList[l]->Control = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
746
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
747 if (Event->xkey.state & ShiftMask)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
748 wsWindowList[l]->Shift = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
749
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
750 if (Event->xkey.state & LockMask)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
751 wsWindowList[l]->CapsLock = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
752
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
753 #if 0
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
754 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
755 KeySym keySym;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
756 keySym = XKeycodeToKeysym(wsDisplay, Event->xkey.keycode, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
757
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
758 if (keySym != NoSymbol) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
759 keySym = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym));
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
760 wsKeyTable[keySym] = i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
761
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
762 if (wsWindowList[l]->KeyHandler)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
763 wsWindowList[l]->KeyHandler(Event->xkey.state, i, keySym);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
764 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
765 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
766 #else
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
767 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
768 int key;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
769 char buf[100];
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
770 KeySym keySym;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
771 static XComposeStatus stat;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
772
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
773 XLookupString(&Event->xkey, buf, sizeof(buf), &keySym, &stat);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
774 key = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym));
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
775 wsKeyTable[key] = i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
776
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
777 if (wsWindowList[l]->KeyHandler)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
778 wsWindowList[l]->KeyHandler(Event->xkey.keycode, i, key);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
779 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
780 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
781 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
782
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
783 case MotionNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
784 i = wsMoveMouse;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
785 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
786 /* pump all motion events from the display queue:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
787 * this way it works faster when moving the window */
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
788 static XEvent e;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
789
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
790 if (Event->xmotion.state) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
791 while (XCheckTypedWindowEvent(display, Event->xany.window, MotionNotify, &e)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
792 /* FIXME: need to make sure we didn't release/press the button in between...*/
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
793 /* FIXME: do we need some timeout here to make sure we don't spend too much time
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
794 * removing events from the queue? */
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
795 Event = &e;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
796 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
797 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
798 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
799 goto buttonreleased;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
800
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
801 case ButtonRelease:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
802 i = Event->xbutton.button + 128;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
803 goto buttonreleased;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
804
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
805 case ButtonPress:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
806 i = Event->xbutton.button;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
807 goto buttonreleased;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
808
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
809 case EnterNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
810 i = wsEnterWindow;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
811 goto buttonreleased;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
812
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
813 case LeaveNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
814 i = wsLeaveWindow;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
815 buttonreleased:
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
816
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
817 if (wsWindowList[l]->MouseHandler)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
818 wsWindowList[l]->MouseHandler(i, Event->xbutton.x, Event->xbutton.y, Event->xmotion.x_root, Event->xmotion.y_root);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
819
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
820 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
821
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
822 case SelectionNotify:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
823 /* Handle DandD */
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
824 wsXDNDProcessSelection(wsWindowList[l], Event);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
825 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
826 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
827
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
828 XFlush(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
829 XSync(wsDisplay, False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
830 return !wsTrue;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
831 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
832
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
833 void wsHandleEvents(void)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
834 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
835 // handle pending events
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
836 while (XPending(wsDisplay)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
837 XNextEvent(wsDisplay, &wsEvent);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
838 // printf("### X event: %d [%d]\n",wsEvent.type,delay);
33541
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
839 wsEvents(wsDisplay, &wsEvent);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
840 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
841 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
842
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
843 void wsMainLoop(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
844 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
845 int delay = 20;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
846
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
847 mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] init threads: %d\n", XInitThreads());
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
848 XSynchronize(wsDisplay, False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
849 XLockDisplay(wsDisplay);
33541
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
850 // XIfEvent( wsDisplay,&wsEvent,wsEvents );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
851
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
852 while (wsTrue) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
853 // handle pending events
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
854 while (XPending(wsDisplay)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
855 XNextEvent(wsDisplay, &wsEvent);
33541
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
856 wsEvents(wsDisplay, &wsEvent);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
857 delay = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
858 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
859
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
860 usleep(delay * 1000); // FIXME!
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
861
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
862 if (delay < 10 * 20)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
863 delay += 20; // pump up delay up to 0.2 sec (low activity)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
864 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
865
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
866 XUnlockDisplay(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
867 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
868
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
869 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
870 // Move window to selected layer
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
871 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
872
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
873 #define WIN_LAYER_ONBOTTOM 2
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
874 #define WIN_LAYER_NORMAL 4
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
875 #define WIN_LAYER_ONTOP 10
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
876
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
877 void wsSetLayer(Display *wsDisplay, Window win, int layer)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
878 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
879 vo_x11_setlayer(wsDisplay, win, layer);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
880 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
881
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
882 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
883 // Switch to fullscreen.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
884 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
885 void wsFullScreen(wsTWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
886 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
887 int decoration = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
888
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
889 if (win->isFullScreen) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
890 vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
891
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
892 if (!(vo_fs_type & vo_wm_FULLSCREEN)) { // shouldn't be needed with EWMH fs
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
893 win->X = win->OldX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
894 win->Y = win->OldY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
895 win->Width = win->OldWidth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
896 win->Height = win->OldHeight;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
897 decoration = win->Decorations;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
898 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
899
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
900 #ifdef ENABLE_DPMS
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
901 wsScreenSaverOn(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
902 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
903
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
904 win->isFullScreen = False;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
905 } else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
906 if (!(vo_fs_type & vo_wm_FULLSCREEN)) { // shouldn't be needed with EWMH fs
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
907 win->OldX = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
908 win->OldY = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
909 win->OldWidth = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
910 win->OldHeight = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
911 vo_dx = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
912 vo_dy = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
913 vo_dwidth = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
914 vo_dheight = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
915 vo_screenwidth = wsMaxX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
916 vo_screenheight = wsMaxY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
917 xinerama_x = wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
918 xinerama_y = wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
919 update_xinerama_info();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
920 wsMaxX = vo_screenwidth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
921 wsMaxY = vo_screenheight;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
922 wsOrgX = xinerama_x;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
923 wsOrgY = xinerama_y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
924 win->X = wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
925 win->Y = wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
926 win->Width = wsMaxX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
927 win->Height = wsMaxY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
928 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
929
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
930 win->isFullScreen = True;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
931 #ifdef ENABLE_DPMS
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
932 wsScreenSaverOff(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
933 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
934
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
935 vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // adds fullscreen state if wm supports EWMH
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
936 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
937
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
938 if (!(vo_fs_type & vo_wm_FULLSCREEN)) { // shouldn't be needed with EWMH fs
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
939 vo_x11_decoration(wsDisplay, win->WindowID, decoration);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
940 vo_x11_sizehint(win->X, win->Y, win->Width, win->Height, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
941 vo_x11_setlayer(wsDisplay, win->WindowID, win->isFullScreen);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
942
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
943 if ((!(win->isFullScreen)) & vo_ontop)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
944 vo_x11_setlayer(wsDisplay, win->WindowID, 1);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
945
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
946 XMoveResizeWindow(wsDisplay, win->WindowID, win->X, win->Y, win->Width, win->Height);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
947 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
948
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
949 if (vo_wm_type == 0 && !(vo_fsmode & 16)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
950 XWithdrawWindow(wsDisplay, win->WindowID, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
951 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
952
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
953 XMapRaised(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
954 XRaiseWindow(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
955 XFlush(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
956 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
957
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
958 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
959 // Redraw screen.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
960 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
961 void wsPostRedisplay(wsTWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
962 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
963 if (win->ReDraw) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
964 win->State = wsWindowExpose;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
965 win->ReDraw();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
966 XFlush(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
967 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
968 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
969
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
970 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
971 // Do Exit.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
972 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
973 void wsDoExit(void)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
974 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
975 wsTrue = False;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
976 wsResizeWindow(wsWindowList[0], 32, 32);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
977 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
978
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
979 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
980 // Put 'Image' to window.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
981 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
982 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
983 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
984 const uint8_t *src[4] = { Image, NULL, NULL, NULL };
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
985 int src_stride[4] = { 4 * win->xImage->width, 0, 0, 0 };
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
986 uint8_t *dst[4] = { win->ImageData, NULL, NULL, NULL };
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
987 int dst_stride[4];
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
988 int i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
989
33541
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
990 (void)Size;
729826b857cf Avoid compiler warnings.
ib
parents: 33540
diff changeset
991
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
992 sws_ctx = sws_getCachedContext(sws_ctx, win->xImage->width, win->xImage->height, PIX_FMT_RGB32,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
993 win->xImage->width, win->xImage->height, out_pix_fmt,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
994 SWS_POINT, NULL, NULL, NULL);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
995 av_image_fill_linesizes(dst_stride, out_pix_fmt, win->xImage->width);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
996 sws_scale(sws_ctx, src, src_stride, 0, win->xImage->height, dst, dst_stride);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
997
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
998 if (!wsNonNativeOrder)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
999 return;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1000
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1001 switch (win->xImage->bits_per_pixel) {
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1002 case 32:
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1003 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1004 uint32_t *d = (uint32_t *)win->ImageData;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1005
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1006 for (i = 0; i < win->xImage->width * win->xImage->height; i++)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1007 d[i] = bswap_32(d[i]);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1008
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1009 break;
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1010 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1011
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1012 case 16:
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1013 case 15:
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1014 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1015 uint16_t *d = (uint16_t *)win->ImageData;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1016
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1017 for (i = 0; i < win->xImage->width * win->xImage->height; i++)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1018 d[i] = bswap_16(d[i]);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1019
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1020 break;
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1021 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1022 }
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1023 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1024
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1025 void wsPutImage(wsTWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1026 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1027 if (wsUseXShm) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1028 XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1029 0, 0,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1030 (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1031 win->xImage->width, win->xImage->height, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1032 } else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1033 XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1034 0, 0,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1035 (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1036 win->xImage->width, win->xImage->height);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1037 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1038 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1039
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1040 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1041 // Move window to x, y.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1042 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1043 void wsMoveWindow(wsTWindow *win, int b, int x, int y)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1044 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1045 if (b) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1046 switch (x) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1047 case -1:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1048 win->X = (wsMaxX / 2) - (win->Width / 2) + wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1049 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1050
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1051 case -2:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1052 win->X = wsMaxX - win->Width + wsOrgX;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1053 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1054
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1055 default:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1056 win->X = x;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1057 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1058 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1059
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1060 switch (y) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1061 case -1:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1062 win->Y = (wsMaxY / 2) - (win->Height / 2) + wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1063 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1064
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1065 case -2:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1066 win->Y = wsMaxY - win->Height + wsOrgY;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1067 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1068
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1069 default:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1070 win->Y = y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1071 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1072 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1073 } else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1074 win->X = x;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1075 win->Y = y;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1076 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1077
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1078 win->SizeHint.flags = PPosition | PWinGravity;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1079 win->SizeHint.x = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1080 win->SizeHint.y = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1081 win->SizeHint.win_gravity = StaticGravity;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1082 XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1083
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1084 XMoveWindow(wsDisplay, win->WindowID, win->X, win->Y);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1085
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1086 if (win->ReSize)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1087 win->ReSize(win->X, win->Y, win->Width, win->Height);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1088 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1089
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1090 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1091 // Resize window to sx, sy.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1092 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1093 void wsResizeWindow(wsTWindow *win, int sx, int sy)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1094 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1095 win->Width = sx;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1096 win->Height = sy;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1097
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1098 win->SizeHint.flags = PPosition | PSize | PWinGravity; // | PBaseSize;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1099 win->SizeHint.x = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1100 win->SizeHint.y = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1101 win->SizeHint.width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1102 win->SizeHint.height = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1103
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1104 if (win->Property & wsMinSize) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1105 win->SizeHint.flags |= PMinSize;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1106 win->SizeHint.min_width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1107 win->SizeHint.min_height = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1108 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1109
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1110 if (win->Property & wsMaxSize) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1111 win->SizeHint.flags |= PMaxSize;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1112 win->SizeHint.max_width = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1113 win->SizeHint.max_height = win->Height;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1114 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1115
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1116 win->SizeHint.win_gravity = StaticGravity;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1117 win->SizeHint.base_width = sx;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1118 win->SizeHint.base_height = sy;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1119
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1120 if (vo_wm_type == 0)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1121 XUnmapWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1122
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1123 XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1124 XResizeWindow(wsDisplay, win->WindowID, sx, sy);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1125 XMapRaised(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1126
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1127 if (win->ReSize)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1128 win->ReSize(win->X, win->Y, win->Width, win->Height);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1129 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1130
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1131 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1132 // Iconify window.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1133 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1134 void wsIconify(wsTWindow win)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1135 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1136 XIconifyWindow(wsDisplay, win.WindowID, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1137 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1138
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1139 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1140 // Move top the window.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1141 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1142 void wsMoveTopWindow(Display *wsDisplay, Window win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1143 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1144 // XUnmapWindow( wsDisplay,win );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1145 // XMapWindow( wsDisplay,win );
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1146 XMapRaised(wsDisplay, win);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1147 XRaiseWindow(wsDisplay, win);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1148 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1149
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1150 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1151 // Set window background to 'color'.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1152 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1153 void wsSetBackground(wsTWindow *win, int color)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1154 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1155 XSetWindowBackground(wsDisplay, win->WindowID, color);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1156 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1157
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1158 void wsSetBackgroundRGB(wsTWindow *win, int r, int g, int b)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1159 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1160 int color = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1161
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1162 switch (wsOutMask) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1163 case wsRGB32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1164 case wsRGB24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1165 color = (r << 16) + (g << 8) + b;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1166 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1167
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1168 case wsBGR32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1169 case wsBGR24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1170 color = (b << 16) + (g << 8) + r;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1171 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1172
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1173 case wsRGB16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1174 PACK_RGB16(b, g, r, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1175 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1176
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1177 case wsBGR16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1178 PACK_RGB16(r, g, b, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1179 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1180
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1181 case wsRGB15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1182 PACK_RGB15(b, g, r, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1183 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1184
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1185 case wsBGR15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1186 PACK_RGB15(r, g, b, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1187 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1188 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1189
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1190 XSetWindowBackground(wsDisplay, win->WindowID, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1191 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1192
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1193 void wsSetForegroundRGB(wsTWindow *win, int r, int g, int b)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1194 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1195 int color = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1196
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1197 switch (wsOutMask) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1198 case wsRGB32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1199 case wsRGB24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1200 color = (r << 16) + (g << 8) + b;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1201 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1202
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1203 case wsBGR32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1204 case wsBGR24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1205 color = (b << 16) + (g << 8) + r;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1206 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1207
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1208 case wsRGB16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1209 PACK_RGB16(b, g, r, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1210 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1211
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1212 case wsBGR16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1213 PACK_RGB16(r, g, b, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1214 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1215
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1216 case wsRGB15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1217 PACK_RGB15(b, g, r, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1218 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1219
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1220 case wsBGR15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1221 PACK_RGB15(r, g, b, color);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1222 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1223 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1224
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1225 XSetForeground(wsDisplay, win->wGC, color);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1226 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1227
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1228 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1229 // Draw string at x,y with fc ( foreground color ) and bc ( background color ).
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1230 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1231 void wsDrawString(wsTWindow win, int x, int y, char *str, int fc, int bc)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1232 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1233 XSetForeground(wsDisplay, win.wGC, bc);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1234 XFillRectangle(wsDisplay, win.WindowID, win.wGC, x, y,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1235 XTextWidth(win.Font, str, strlen(str)) + 20,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1236 win.FontHeight + 2);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1237 XSetForeground(wsDisplay, win.wGC, fc);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1238 XDrawString(wsDisplay, win.WindowID, win.wGC, x + 10, y + 13, str, strlen(str));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1239 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1240
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1241 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1242 // Calculation string width.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1243 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1244 int wsTextWidth(wsTWindow win, char *str)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1245 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1246 return XTextWidth(win.Font, str, strlen(str)) + 20;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1247 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1248
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1249 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1250 // Show / hide mouse cursor.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1251 // ----------------------------------------------------------------------------------------------
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1252 void wsVisibleMouse(wsTWindow *win, int m)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1253 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1254 switch (m) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1255 case wsShowMouseCursor:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1256
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1257 if (win->wsCursor != None) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1258 XFreeCursor(wsDisplay, win->wsCursor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1259 win->wsCursor = None;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1260 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1261
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1262 XDefineCursor(wsDisplay, win->WindowID, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1263 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1264
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1265 case wsHideMouseCursor:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1266 win->wsCursor = XCreatePixmapCursor(wsDisplay, win->wsCursorPixmap, win->wsCursorPixmap, &win->wsColor, &win->wsColor, 0, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1267 XDefineCursor(wsDisplay, win->WindowID, win->wsCursor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1268 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1269 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1270
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1271 XFlush(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1272 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1273
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1274 int wsGetDepthOnScreen(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1275 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1276 int depth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1277 XImage *mXImage;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1278 Visual *visual;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1279
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1280 if ((depth = vo_find_depth_from_visuals(wsDisplay, wsScreen, &visual)) > 0) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1281 mXImage = XCreateImage(wsDisplay, visual, depth, ZPixmap, 0, NULL,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1282 1, 1, 32, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1283 wsDepthOnScreen = mXImage->bits_per_pixel;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1284 wsRedMask = mXImage->red_mask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1285 wsGreenMask = mXImage->green_mask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1286 wsBlueMask = mXImage->blue_mask;
29401
f01023c524c3 Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents: 29263
diff changeset
1287 #if HAVE_BIGENDIAN
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1288 wsNonNativeOrder = mXImage->byte_order == LSBFirst;
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1289 #else
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1290 wsNonNativeOrder = mXImage->byte_order == MSBFirst;
23453
3e18bed9618a Make gmplayer show right colors if X server does not use native byteorder.
reimar
parents: 23077
diff changeset
1291 #endif
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1292 XDestroyImage(mXImage);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1293 } else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1294 int bpp, ibpp;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1295 XWindowAttributes attribs;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1296
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1297 mXImage = XGetImage(wsDisplay, wsRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1298 bpp = mXImage->bits_per_pixel;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1299
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1300 XGetWindowAttributes(wsDisplay, wsRootWin, &attribs);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1301 ibpp = attribs.depth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1302 mXImage = XGetImage(wsDisplay, wsRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1303 bpp = mXImage->bits_per_pixel;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1304
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1305 if ((ibpp + 7) / 8 != (bpp + 7) / 8)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1306 ibpp = bpp;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1307
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1308 wsDepthOnScreen = ibpp;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1309 wsRedMask = mXImage->red_mask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1310 wsGreenMask = mXImage->green_mask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1311 wsBlueMask = mXImage->blue_mask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1312 XDestroyImage(mXImage);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1313 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1314
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1315 return wsDepthOnScreen;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1316 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1317
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1318 void wsXDone(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1319 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1320 XCloseDisplay(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1321 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1322
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1323 void wsVisibleWindow(wsTWindow *win, int show)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1324 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1325 switch (show) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1326 case wsShowWindow:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1327 XMapRaised(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1328 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1329
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1330 case wsHideWindow:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1331 XUnmapWindow(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1332 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1333 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1334
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1335 XFlush(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1336 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1337
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1338 void wsDestroyImage(wsTWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1339 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1340 if (win->xImage) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1341 XDestroyImage(win->xImage);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1342
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1343 if (wsUseXShm) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1344 XShmDetach(wsDisplay, &win->Shminfo);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1345 shmdt(win->Shminfo.shmaddr);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1346 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1347 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1348
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1349 win->xImage = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1350 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1351
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1352 void wsCreateImage(wsTWindow *win, int Width, int Height)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1353 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1354 if (wsUseXShm) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1355 win->xImage = XShmCreateImage(wsDisplay, win->VisualInfo.visual,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1356 win->VisualInfo.depth, ZPixmap, NULL, &win->Shminfo, Width, Height);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1357
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1358 if (win->xImage == NULL) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1359 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1360 guiExit(EXIT_ERROR);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1361 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1362
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1363 win->Shminfo.shmid = shmget(IPC_PRIVATE, win->xImage->bytes_per_line * win->xImage->height, IPC_CREAT | 0777);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1364
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1365 if (win->Shminfo.shmid < 0) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1366 XDestroyImage(win->xImage);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1367 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1368 guiExit(EXIT_ERROR);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1369 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1370
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1371 win->Shminfo.shmaddr = (char *)shmat(win->Shminfo.shmid, 0, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1372
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1373 if (win->Shminfo.shmaddr == ((char *)-1)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1374 XDestroyImage(win->xImage);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1375
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1376 if (win->Shminfo.shmaddr != ((char *)-1))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1377 shmdt(win->Shminfo.shmaddr);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1378
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1379 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1380 guiExit(EXIT_ERROR);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1381 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1382
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1383 win->xImage->data = win->Shminfo.shmaddr;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1384 win->Shminfo.readOnly = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1385 XShmAttach(wsDisplay, &win->Shminfo);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1386 XSync(wsDisplay, False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1387 shmctl(win->Shminfo.shmid, IPC_RMID, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1388 } else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1389 win->xImage = XCreateImage(wsDisplay, win->VisualInfo.visual, win->VisualInfo.depth,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1390 ZPixmap, 0, 0, Width, Height,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1391 (wsDepthOnScreen == 3) ? 32 : wsDepthOnScreen,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1392 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1393
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1394 if ((win->xImage->data = malloc(win->xImage->bytes_per_line * win->xImage->height)) == NULL) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1395 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_NotEnoughMemoryDrawBuffer);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1396 guiExit(EXIT_ERROR);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1397 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1398 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1399
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1400 win->ImageData = (unsigned char *)win->xImage->data;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1401 win->ImageDataw = (unsigned short int *)win->xImage->data;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1402 win->ImageDatadw = (unsigned int *)win->xImage->data;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1403 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1404
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1405 void wsResizeImage(wsTWindow *win, int Width, int Height)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1406 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1407 wsDestroyImage(win);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1408 wsCreateImage(win, Width, Height);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1409 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1410
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1411 int wsGetOutMask(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1412 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1413 if ((wsDepthOnScreen == 32) && (wsRedMask == 0xff0000) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0x0000ff))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1414 return wsRGB32;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1415
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1416 if ((wsDepthOnScreen == 32) && (wsRedMask == 0x0000ff) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0xff0000))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1417 return wsBGR32;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1418
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1419 if ((wsDepthOnScreen == 24) && (wsRedMask == 0xff0000) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0x0000ff))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1420 return wsRGB24;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1421
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1422 if ((wsDepthOnScreen == 24) && (wsRedMask == 0x0000ff) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0xff0000))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1423 return wsBGR24;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1424
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1425 if ((wsDepthOnScreen == 16) && (wsRedMask == 0xf800) && (wsGreenMask == 0x7e0) && (wsBlueMask == 0x1f))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1426 return wsRGB16;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1427
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1428 if ((wsDepthOnScreen == 16) && (wsRedMask == 0x1f) && (wsGreenMask == 0x7e0) && (wsBlueMask == 0xf800))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1429 return wsBGR16;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1430
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1431 if ((wsDepthOnScreen == 15) && (wsRedMask == 0x7c00) && (wsGreenMask == 0x3e0) && (wsBlueMask == 0x1f))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1432 return wsRGB15;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1433
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1434 if ((wsDepthOnScreen == 15) && (wsRedMask == 0x1f) && (wsGreenMask == 0x3e0) && (wsBlueMask == 0x7c00))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1435 return wsBGR15;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1436
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1437 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1438 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1439
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1440 void wsSetTitle(wsTWindow *win, char *name)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1441 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1442 XStoreName(wsDisplay, win->WindowID, name);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1443 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1444
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1445 void wsSetMousePosition(wsTWindow *win, int x, int y)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1446 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1447 XWarpPointer(wsDisplay, wsRootWin, win->WindowID, 0, 0, 0, 0, x, y);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1448 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1449
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1450 #ifdef ENABLE_DPMS
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1451 static int dpms_disabled = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1452 static int timeout_save = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1453
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1454 void wsScreenSaverOn(Display *mDisplay)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1455 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1456 int nothing;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1457
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
1458 #ifdef CONFIG_XDPMS
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1459
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1460 if (dpms_disabled) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1461 if (DPMSQueryExtension(mDisplay, &nothing, &nothing)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1462 if (!DPMSEnable(mDisplay))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1463 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_WS_DpmsUnavailable); // restoring power saving settings
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1464 else {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1465 // DPMS does not seem to be enabled unless we call DPMSInfo
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1466 BOOL onoff;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1467 CARD16 state;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1468 DPMSInfo(mDisplay, &state, &onoff);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1469
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1470 if (onoff)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1471 mp_msg(MSGT_GPLAYER, MSGL_V, "Successfully enabled DPMS.\n");
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1472 else
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1473 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_WS_DpmsNotEnabled);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1474 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1475 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1476 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1477
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1478 #endif
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1479
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1480 if (timeout_save) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1481 int dummy, interval, prefer_blank, allow_exp;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1482 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1483 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1484 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1485 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1486 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1487
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1488 void wsScreenSaverOff(Display *mDisplay)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1489 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1490 int interval, prefer_blank, allow_exp, nothing;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1491
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1492 #ifdef CONFIG_XDPMS
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1493
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1494 if (DPMSQueryExtension(mDisplay, &nothing, &nothing)) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1495 BOOL onoff;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1496 CARD16 state;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1497 DPMSInfo(mDisplay, &state, &onoff);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1498
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1499 if (onoff) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1500 Status stat;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1501 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "Disabling DPMS.\n");
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1502 dpms_disabled = 1;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1503 stat = DPMSDisable(mDisplay); // monitor powersave off
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1504 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "stat: %d.\n", stat);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1505 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1506 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1507
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1508 #endif
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1509 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1510
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1511 if (timeout_save)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1512 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp); // turning off screensaver
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1513 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1514
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1515 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1516
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1517 void wsSetShape(wsTWindow *win, char *data)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1518 {
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
1519 #ifdef CONFIG_XSHAPE
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1520
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1521 if (!wsUseXShape)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1522 return;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1523
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1524 if (data) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1525 win->Mask = XCreateBitmapFromData(wsDisplay, win->WindowID, data, win->Width, win->Height);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1526 XShapeCombineMask(wsDisplay, win->WindowID, ShapeBounding, 0, 0, win->Mask, ShapeSet);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1527 XFreePixmap(wsDisplay, win->Mask);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1528 } else
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1529 XShapeCombineMask(wsDisplay, win->WindowID, ShapeBounding, 0, 0, None, ShapeSet);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1530
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1531 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1532 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1533
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1534 void wsSetIcon(Display *dsp, Window win, guiIcon_t *icon)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1535 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1536 XWMHints *wm;
33540
0dec83e053cc Revise wsSetIcon().
ib
parents: 33539
diff changeset
1537 Atom iconatom;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1538 CARD32 data[2];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
1539
33544
b71fac188432 Check whether a specific icon is available.
ib
parents: 33543
diff changeset
1540 if (icon->normal) {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1541 wm = XGetWMHints(dsp, win);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1542
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1543 if (!wm)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1544 wm = XAllocWMHints();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1545
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1546 wm->icon_pixmap = icon->normal;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1547 wm->icon_mask = icon->normal_mask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1548 wm->flags |= IconPixmapHint | IconMaskHint;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1549
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1550 XSetWMHints(dsp, win, wm);
33540
0dec83e053cc Revise wsSetIcon().
ib
parents: 33539
diff changeset
1551 XFree(wm);
33544
b71fac188432 Check whether a specific icon is available.
ib
parents: 33543
diff changeset
1552 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1553
33544
b71fac188432 Check whether a specific icon is available.
ib
parents: 33543
diff changeset
1554 if (icon->small || icon->normal) {
33540
0dec83e053cc Revise wsSetIcon().
ib
parents: 33539
diff changeset
1555 iconatom = XInternAtom(dsp, "KWM_WIN_ICON", False);
33543
10f9498fada1 Use small icon for property KWM_WIN_ICON, if available.
ib
parents: 33542
diff changeset
1556 data[0] = (icon->small ? icon->small : icon->normal);
10f9498fada1 Use small icon for property KWM_WIN_ICON, if available.
ib
parents: 33542
diff changeset
1557 data[1] = (icon->small ? icon->small_mask : icon->normal_mask);
33540
0dec83e053cc Revise wsSetIcon().
ib
parents: 33539
diff changeset
1558
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1559 XChangeProperty(dsp, win, iconatom, iconatom, 32, PropModeReplace, (unsigned char *)data, 2);
33544
b71fac188432 Check whether a specific icon is available.
ib
parents: 33543
diff changeset
1560 }
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33541
diff changeset
1561
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33541
diff changeset
1562 if (icon->collection) {
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33541
diff changeset
1563 iconatom = XInternAtom(dsp, "_NET_WM_ICON", False);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33541
diff changeset
1564 XChangeProperty(dsp, win, iconatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)icon->collection, icon->collection_size);
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33541
diff changeset
1565 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1566 }