annotate gui/wm/ws.c @ 34462:f305c10d20f8

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