annotate gui/wm/ws.c @ 35700:7820bad7c1f8

Cosmetic: Rename ws functions for the sake of consistency. These have been forgotten in r35775: wsSizeHint -> wsWindowSizeHint wsMapWait -> wsWindowMapWait
author ib
date Sat, 19 Jan 2013 13:00:41 +0000
parents 36527758158b
children a1d362602a70
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 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * 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
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * 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
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35666
01ac3cd2f101 Cosmetic: Relocate and revise comments on code origin.
ib
parents: 35665
diff changeset
17 *
01ac3cd2f101 Cosmetic: Relocate and revise comments on code origin.
ib
parents: 35665
diff changeset
18 * based on: AutoSpace Window System for Linux/Win32,
01ac3cd2f101 Cosmetic: Relocate and revise comments on code origin.
ib
parents: 35665
diff changeset
19 * written by pontscho/fresh!mindworkz
26458
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>
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
62 #ifdef HAVE_SHM
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 #include <sys/shm.h>
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
64 #endif
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65
34034
8c75091726d8 Replace numeric constant for cursor autohide time by symbolic constant.
ib
parents: 34033
diff changeset
66 #define MOUSEHIDE_DELAY 1000 // in milliseconds
8c75091726d8 Replace numeric constant for cursor autohide time by symbolic constant.
ib
parents: 34033
diff changeset
67
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35655
diff changeset
68 static wsWindow *mouse_win;
34081
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
69 static unsigned int mouse_time;
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
70
35667
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
71 int wsMaxX; // Screen width.
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
72 int wsMaxY; // Screen height.
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
73 int wsOrgX; // Screen origin x.
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
74 int wsOrgY; // Screen origin y.
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
76 Display *wsDisplay;
35667
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
77 static int wsScreen;
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
78 static Window wsRootWin;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79
35678
2261c68180a7 Make variable wsScreenDepth static.
ib
parents: 35677
diff changeset
80 static int wsScreenDepth;
35667
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
81 static int wsRedMask;
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
82 static int wsGreenMask;
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
83 static int wsBlueMask;
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
84 static int wsOutMask;
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
85 static int wsNonNativeOrder;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
87 #define wsWLCount 5
35667
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
88 static wsWindow *wsWindowList[wsWLCount];
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
89
35667
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
90 static int wsUseXShm = True;
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
91 static int wsUseXShape = True;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34470
diff changeset
93 /* --- */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
95 #define PACK_RGB16(r, g, b, pixel) pixel = (b >> 3); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
96 pixel <<= 6; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
97 pixel |= (g >> 2); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
98 pixel <<= 5; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
99 pixel |= (r >> 3)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
101 #define PACK_RGB15(r, g, b, pixel) pixel = (b >> 3); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
102 pixel <<= 5; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
103 pixel |= (g >> 3); \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
104 pixel <<= 5; \
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
105 pixel |= (r >> 3)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106
35667
3ed198bf4f21 Make variables static that only have file scope.
ib
parents: 35666
diff changeset
107 static enum PixelFormat out_pix_fmt = PIX_FMT_NONE;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34470
diff changeset
109 /* --- */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 #define MWM_HINTS_FUNCTIONS (1L << 0)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 #define MWM_HINTS_DECORATIONS (1L << 1)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 #define MWM_FUNC_RESIZE (1L << 1)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 #define MWM_FUNC_MOVE (1L << 2)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 #define MWM_FUNC_MINIMIZE (1L << 3)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 #define MWM_FUNC_MAXIMIZE (1L << 4)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 #define MWM_FUNC_CLOSE (1L << 5)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 #define MWM_DECOR_ALL (1L << 0)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121
33994
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
122 /**
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
123 * @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
124 * from xinerama information.
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
125 *
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
126 * Set wsOrgX, wsOrgY, wsMaxX and wsMaxY as well as
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
127 * win->X, win->Y, win->Width and win->Height.
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
128 *
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
129 * @param win pointer to a ws window structure or NULL
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
130 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
131 static void wsWindowUpdateXinerama(wsWindow *win)
33994
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
132 {
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
133 if (win) {
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
134 vo_dx = win->X;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
135 vo_dy = win->Y;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
136 vo_dwidth = win->Width;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
137 vo_dheight = win->Height;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
138 }
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
139
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
140 vo_screenwidth = wsMaxX;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
141 vo_screenheight = wsMaxY;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
142
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
143 update_xinerama_info();
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
144
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
145 wsMaxX = vo_screenwidth;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
146 wsMaxY = vo_screenheight;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
147 wsOrgX = xinerama_x;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
148 wsOrgY = xinerama_y;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
149
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
150 if (win) {
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
151 win->X = wsOrgX;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
152 win->Y = wsOrgY;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
153 win->Width = wsMaxX;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
154 win->Height = wsMaxY;
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
155 }
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
156 }
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
157
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
158 static int wsGetScreenDepth(void)
35636
840e473ba4c0 Restore GUI's X error handler after gtk_init().
ib
parents: 35635
diff changeset
159 {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
160 int depth;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
161 XImage *mXImage;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
162 Visual *visual;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
163
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
164 if ((depth = vo_find_depth_from_visuals(wsDisplay, wsScreen, &visual)) > 0) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
165 mXImage = XCreateImage(wsDisplay, visual, depth, ZPixmap, 0, NULL,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
166 1, 1, 32, 0);
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
167 wsScreenDepth = mXImage->bits_per_pixel;
35677
539f3d45dcf5 Cosmetic: Adjust indent.
ib
parents: 35676
diff changeset
168 wsRedMask = mXImage->red_mask;
539f3d45dcf5 Cosmetic: Adjust indent.
ib
parents: 35676
diff changeset
169 wsGreenMask = mXImage->green_mask;
539f3d45dcf5 Cosmetic: Adjust indent.
ib
parents: 35676
diff changeset
170 wsBlueMask = mXImage->blue_mask;
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
171 #if HAVE_BIGENDIAN
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
172 wsNonNativeOrder = mXImage->byte_order == LSBFirst;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
173 #else
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
174 wsNonNativeOrder = mXImage->byte_order == MSBFirst;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
175 #endif
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
176 XDestroyImage(mXImage);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
177 } else {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
178 int bpp, ibpp;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
179 XWindowAttributes attribs;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
180
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
181 mXImage = XGetImage(wsDisplay, wsRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
182 bpp = mXImage->bits_per_pixel;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
183
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
184 XGetWindowAttributes(wsDisplay, wsRootWin, &attribs);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
185 ibpp = attribs.depth;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
186 mXImage = XGetImage(wsDisplay, wsRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
187 bpp = mXImage->bits_per_pixel;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
188
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
189 if ((ibpp + 7) / 8 != (bpp + 7) / 8)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
190 ibpp = bpp;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
191
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
192 wsScreenDepth = ibpp;
35677
539f3d45dcf5 Cosmetic: Adjust indent.
ib
parents: 35676
diff changeset
193 wsRedMask = mXImage->red_mask;
539f3d45dcf5 Cosmetic: Adjust indent.
ib
parents: 35676
diff changeset
194 wsGreenMask = mXImage->green_mask;
539f3d45dcf5 Cosmetic: Adjust indent.
ib
parents: 35676
diff changeset
195 wsBlueMask = mXImage->blue_mask;
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
196 XDestroyImage(mXImage);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
197 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
198
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
199 return wsScreenDepth;
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
200 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
201
35673
2b7f93ef711d Make functions static that only have file scope.
ib
parents: 35672
diff changeset
202 static int wsGetOutMask(void)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
203 {
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
204 if ((wsScreenDepth == 32) && (wsRedMask == 0xff0000) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0x0000ff))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
205 return wsRGB32;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
206
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
207 if ((wsScreenDepth == 32) && (wsRedMask == 0x0000ff) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0xff0000))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
208 return wsBGR32;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
209
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
210 if ((wsScreenDepth == 24) && (wsRedMask == 0xff0000) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0x0000ff))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
211 return wsRGB24;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
212
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
213 if ((wsScreenDepth == 24) && (wsRedMask == 0x0000ff) && (wsGreenMask == 0x00ff00) && (wsBlueMask == 0xff0000))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
214 return wsBGR24;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
215
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
216 if ((wsScreenDepth == 16) && (wsRedMask == 0xf800) && (wsGreenMask == 0x7e0) && (wsBlueMask == 0x1f))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
217 return wsRGB16;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
218
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
219 if ((wsScreenDepth == 16) && (wsRedMask == 0x1f) && (wsGreenMask == 0x7e0) && (wsBlueMask == 0xf800))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
220 return wsBGR16;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
221
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
222 if ((wsScreenDepth == 15) && (wsRedMask == 0x7c00) && (wsGreenMask == 0x3e0) && (wsBlueMask == 0x1f))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
223 return wsRGB15;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
224
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
225 if ((wsScreenDepth == 15) && (wsRedMask == 0x1f) && (wsGreenMask == 0x3e0) && (wsBlueMask == 0x7c00))
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
226 return wsBGR15;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
227
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
228 return 0;
35636
840e473ba4c0 Restore GUI's X error handler after gtk_init().
ib
parents: 35635
diff changeset
229 }
840e473ba4c0 Restore GUI's X error handler after gtk_init().
ib
parents: 35635
diff changeset
230
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
231 void wsInit(Display *display)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
233 int eventbase;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
234 int errorbase;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235
35622
59456592c6d1 Add a message indicating start of initialization of X.
ib
parents: 35541
diff changeset
236 mp_msg(MSGT_GPLAYER, MSGL_V, "X init.\n");
59456592c6d1 Add a message indicating start of initialization of X.
ib
parents: 35541
diff changeset
237
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 35622
diff changeset
238 wsDisplay = display;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239
35636
840e473ba4c0 Restore GUI's X error handler after gtk_init().
ib
parents: 35635
diff changeset
240 wsSetErrorHandler();
31323
c674bb16fa6d Install error handler as early as possible to avoid crashing.
reimar
parents: 31314
diff changeset
241
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 /* enable DND atoms */
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
243 wsXDNDInitialize();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
244
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
245 { /* on remote display XShm will be disabled - LGB */
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
246 char *dispname = DisplayString(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
247 int localdisp = 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
248
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
249 if (dispname && *dispname != ':') {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
250 localdisp = 0;
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35492
diff changeset
251 wsUseXShm = False;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
252 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
253
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
254 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
255
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
256 if (!localdisp)
33549
4f6e515e5bd1 Adjust message levels in wsXInit().
ib
parents: 33548
diff changeset
257 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_WS_RemoteDisplay);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
258 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
259
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
260 #ifdef HAVE_SHM
34461
e3d6a010e8ae Cosmetic: Remove braces.
ib
parents: 34460
diff changeset
261 if (!XShmQueryExtension(wsDisplay))
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
262 #endif
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35492
diff changeset
263 wsUseXShm = False;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
264
34460
c4731df07bfe Always inform / warn about missing shared memory / shape extension
ib
parents: 34459
diff changeset
265 if (!wsUseXShm)
c4731df07bfe Always inform / warn about missing shared memory / shape extension
ib
parents: 34459
diff changeset
266 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_WS_NoXshm);
c4731df07bfe Always inform / warn about missing shared memory / shape extension
ib
parents: 34459
diff changeset
267
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
268 #ifdef CONFIG_XSHAPE
34461
e3d6a010e8ae Cosmetic: Remove braces.
ib
parents: 34460
diff changeset
269 if (!XShapeQueryExtension(wsDisplay, &eventbase, &errorbase))
34462
f305c10d20f8 Simplify XShape handling and setting of wsUseXShape.
ib
parents: 34461
diff changeset
270 #endif
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35492
diff changeset
271 wsUseXShape = False;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
272
34460
c4731df07bfe Always inform / warn about missing shared memory / shape extension
ib
parents: 34459
diff changeset
273 if (!wsUseXShape)
c4731df07bfe Always inform / warn about missing shared memory / shape extension
ib
parents: 34459
diff changeset
274 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_WS_NoXshape);
c4731df07bfe Always inform / warn about missing shared memory / shape extension
ib
parents: 34459
diff changeset
275
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
276 XSynchronize(wsDisplay, True);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
277
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
278 wsScreen = DefaultScreen(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
279 wsRootWin = RootWindow(wsDisplay, wsScreen);
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
280 #ifdef CONFIG_XF86VM
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
281 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
282 int clock;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
283 XF86VidModeModeLine modeline;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
284
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
285 XF86VidModeGetModeLine(wsDisplay, wsScreen, &clock, &modeline);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
286 wsMaxX = modeline.hdisplay;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
287 wsMaxY = modeline.vdisplay;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
288 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
289 #endif
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
290 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
291 wsOrgX = wsOrgY = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
292
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
293 if (!wsMaxX)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
294 wsMaxX = DisplayWidth(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
295
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
296 if (!wsMaxY)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
297 wsMaxY = DisplayHeight(wsDisplay, wsScreen);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
298 }
33994
8e5680eccf54 Move common code to new function wsUpdateXineramaInfo().
ib
parents: 33993
diff changeset
299
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
300 wsWindowUpdateXinerama(NULL);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
301
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
302 wsGetScreenDepth();
33549
4f6e515e5bd1 Adjust message levels in wsXInit().
ib
parents: 33548
diff changeset
303
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
304 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] Screen depth: %d\n", wsScreenDepth);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
305 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
306
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
307 #ifdef CONFIG_XINERAMA
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
308 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
309 #endif
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] red mask: 0x%x\n", wsRedMask);
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
312 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
313 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
314
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
315 #ifdef HAVE_SHM
33550
fea429f90bfd Cosmetic: Adjust indent.
ib
parents: 33549
diff changeset
316 if (wsUseXShm) {
fea429f90bfd Cosmetic: Adjust indent.
ib
parents: 33549
diff changeset
317 int minor, major, shp;
33549
4f6e515e5bd1 Adjust message levels in wsXInit().
ib
parents: 33548
diff changeset
318
33550
fea429f90bfd Cosmetic: Adjust indent.
ib
parents: 33549
diff changeset
319 XShmQueryVersion(wsDisplay, &major, &minor, &shp);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
320 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
321 }
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
322 #endif
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
323
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
324 #ifdef CONFIG_XSHAPE
33550
fea429f90bfd Cosmetic: Adjust indent.
ib
parents: 33549
diff changeset
325 if (wsUseXShape) {
fea429f90bfd Cosmetic: Adjust indent.
ib
parents: 33549
diff changeset
326 int minor, major;
33549
4f6e515e5bd1 Adjust message levels in wsXInit().
ib
parents: 33548
diff changeset
327
33550
fea429f90bfd Cosmetic: Adjust indent.
ib
parents: 33549
diff changeset
328 XShapeQueryVersion(wsDisplay, &major, &minor);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
329 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
330 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
331 #endif
33549
4f6e515e5bd1 Adjust message levels in wsXInit().
ib
parents: 33548
diff changeset
332
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
333 wsOutMask = wsGetOutMask();
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
334
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
335 switch (wsOutMask) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
336 case wsRGB32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
337 out_pix_fmt = PIX_FMT_RGB32;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
338 break;
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 case wsBGR32:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
341 out_pix_fmt = PIX_FMT_BGR32;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
342 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
343
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
344 case wsRGB24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
345 out_pix_fmt = PIX_FMT_RGB24;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
346 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
347
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
348 case wsBGR24:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
349 out_pix_fmt = PIX_FMT_BGR24;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
350 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
351
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
352 case wsRGB16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
353 out_pix_fmt = PIX_FMT_RGB565;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
354 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
355
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
356 case wsBGR16:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
357 out_pix_fmt = PIX_FMT_BGR565;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
358 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
359
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
360 case wsRGB15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
361 out_pix_fmt = PIX_FMT_RGB555;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
362 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
363
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
364 case wsBGR15:
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
365 out_pix_fmt = PIX_FMT_BGR555;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
366 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
367 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
368 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
369
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
370 void wsDone(void)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
371 {
35680
eca669983e9a Don't close the display.
ib
parents: 35679
diff changeset
372 //XCloseDisplay(wsDisplay);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
373 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
374
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
375 /**
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
376 * @brief Inform about an X error that has occurred.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
377 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
378 * @param display display
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
379 * @param event pointer to an X error event structure
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
380 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
381 * @return 0
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
382 */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
383 static int wsErrorHandler(Display *display, XErrorEvent *event)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
384 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
385 char type[128];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
386
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
387 XGetErrorText(display, event->error_code, type, sizeof(type));
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
388
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
389 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[ws] " MSGTR_WS_XError);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
390 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[ws] Error code: %d - %s\n", event->error_code, type);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
391 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] Request code: %d (minor code: %d)\n", event->request_code, event->minor_code);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
392 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] MPlayer module: %s\n", current_module ? current_module : "(none)");
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
393
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
394 return 0;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
395 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
396
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
397 /**
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
398 * @brief Set the X error handler.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
399 */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
400 void wsSetErrorHandler(void)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
401 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
402 XSetErrorHandler(wsErrorHandler);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
403 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
404
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
405 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
406 // Handle events.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
407 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
408
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
409 static int wsWindowListSearch(Window win)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
410 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
411 int i;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
412
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
413 for (i = 0; i < wsWLCount; i++)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
414 if (wsWindowList[i] && wsWindowList[i]->WindowID == win)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
415 return i;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
416
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
417 return -1;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
418 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
419
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
420 void wsEvent(XEvent *event)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
421 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
422 unsigned long i = 0;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
423 int l;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
424 int x, y;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
425 Window child_window = 0;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
426
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
427 l = wsWindowListSearch(event->xany.window);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
428
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
429 if (l == -1)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
430 return;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
431
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
432 wsWindowList[l]->State = wsNone;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
433
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
434 switch (event->type) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
435 case ClientMessage:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
436
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
437 if (event->xclient.message_type == wsWindowList[l]->AtomProtocols) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
438 if ((Atom)event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
439 i = wsWindowClosed;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
440 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
441 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
442
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
443 if ((Atom)event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
444 i = wsWindowFocusIn;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
445 wsWindowList[l]->Focused = wsFocused;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
446 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
447 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
448
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
449 if ((Atom)event->xclient.data.l[0] == wsWindowList[l]->AtomRolle) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
450 mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] role set.\n");
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
451 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
452 } else {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
453 /* try to process DND events */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
454 wsXDNDProcessClientMessage(&event->xclient);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
455 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
456
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
457 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
458
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
459 case MapNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
460
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
461 i = wsWindowMapped;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
462 wsWindowList[l]->Mapped = wsMapped;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
463 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
464
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
465 case UnmapNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
466
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
467 i = wsWindowUnmapped;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
468 wsWindowList[l]->Mapped = wsNo;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
469 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
470
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
471 case FocusIn:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
472
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
473 if (wsWindowList[l]->Focused == wsFocused)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
474 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
475
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
476 i = wsWindowFocusIn;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
477 wsWindowList[l]->Focused = wsFocused;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
478 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
479
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
480 case FocusOut:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
481
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
482 if (wsWindowList[l]->Focused == wsNo)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
483 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
484
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
485 i = wsWindowFocusOut;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
486 wsWindowList[l]->Focused = wsNo;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
487 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
488
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
489 case VisibilityNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
490
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
491 switch (event->xvisibility.state) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
492 case VisibilityUnobscured:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
493 i = wsWindowVisible;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
494 wsWindowList[l]->Visible = wsVisible;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
495 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
496
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
497 case VisibilityFullyObscured:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
498 i = wsWindowNotVisible;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
499 wsWindowList[l]->Visible = wsNotVisible;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
500 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
501
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
502 case VisibilityPartiallyObscured:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
503 i = wsWindowPartialVisible;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
504 wsWindowList[l]->Visible = wsPVisible;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
505 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
506 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
507
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
508 expose:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
509 wsWindowList[l]->State = i;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
510
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
511 if (wsWindowList[l]->ReDraw)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
512 wsWindowList[l]->ReDraw();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
513
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
514 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
515
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
516 case Expose:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
517
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
518 wsWindowList[l]->State = wsWindowExpose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
519
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
520 if ((wsWindowList[l]->ReDraw) && (!event->xexpose.count))
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
521 wsWindowList[l]->ReDraw();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
522
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
523 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
524
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
525 case ConfigureNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
526
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
527 XTranslateCoordinates(wsDisplay, wsWindowList[l]->WindowID, wsRootWin, 0, 0, &x, &y, &child_window);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
528
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
529 if ((wsWindowList[l]->X != x) || (wsWindowList[l]->Y != y) || (wsWindowList[l]->Width != event->xconfigure.width) || (wsWindowList[l]->Height != event->xconfigure.height)) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
530 wsWindowList[l]->X = x;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
531 wsWindowList[l]->Y = y;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
532 wsWindowList[l]->Width = event->xconfigure.width;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
533 wsWindowList[l]->Height = event->xconfigure.height;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
534 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
535
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
536 wsWindowList[l]->Rolled = wsNo;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
537
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
538 if (event->xconfigure.y < 0) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
539 i = wsWindowRolled;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
540 wsWindowList[l]->Rolled = wsRolled;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
541 goto expose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
542 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
543
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
544 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
545
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
546 case KeyPress:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
547
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
548 i = wsKeyPressed;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
549 goto keypressed;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
550
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
551 case KeyRelease:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
552
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
553 i = wsKeyReleased;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
554 keypressed:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
555 wsWindowList[l]->Alt = False;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
556 wsWindowList[l]->Shift = False;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
557 wsWindowList[l]->NumLock = False;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
558 wsWindowList[l]->Control = False;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
559 wsWindowList[l]->CapsLock = False;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
560
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
561 if (event->xkey.state & Mod1Mask)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
562 wsWindowList[l]->Alt = True;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
563
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
564 if (event->xkey.state & Mod2Mask)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
565 wsWindowList[l]->NumLock = True;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
566
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
567 if (event->xkey.state & ControlMask)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
568 wsWindowList[l]->Control = True;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
569
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
570 if (event->xkey.state & ShiftMask)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
571 wsWindowList[l]->Shift = True;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
572
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
573 if (event->xkey.state & LockMask)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
574 wsWindowList[l]->CapsLock = True;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
575
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
576 #if 0
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
577 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
578 KeySym keySym;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
579 keySym = XKeycodeToKeysym(wsDisplay, event->xkey.keycode, 0);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
580
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
581 if (keySym != NoSymbol) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
582 keySym = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym));
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
583
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
584 if (wsWindowList[l]->KeyHandler)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
585 wsWindowList[l]->KeyHandler(event->xkey.state, i, keySym);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
586 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
587 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
588 #else
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
589 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
590 int key;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
591 char buf[100];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
592 KeySym keySym;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
593 static XComposeStatus stat;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
594
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
595 XLookupString(&event->xkey, buf, sizeof(buf), &keySym, &stat);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
596 key = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym));
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
597
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
598 if (wsWindowList[l]->KeyHandler)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
599 wsWindowList[l]->KeyHandler(event->xkey.keycode, i, key);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
600 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
601 #endif
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
602 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
603
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
604 case MotionNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
605
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
606 i = wsMoveMouse;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
607 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
608 /* pump all motion events from the display queue:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
609 * this way it works faster when moving the window */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
610 static XEvent e;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
611
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
612 if (event->xmotion.state) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
613 while (XCheckTypedWindowEvent(wsDisplay, event->xany.window, MotionNotify, &e)) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
614 /* FIXME: need to make sure we didn't release/press the button in between...*/
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
615 /* FIXME: do we need some timeout here to make sure we don't spend too much time
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
616 * removing events from the queue? */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
617 event = &e;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
618 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
619 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
620 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
621
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
622 if (wsWindowList[l]->wsCursor != None) {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
623 wsMouseVisibility(wsWindowList[l], wsShowMouseCursor);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
624 mouse_win = wsWindowList[l];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
625 mouse_time = GetTimerMS();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
626 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
627
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
628 goto buttonreleased;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
629
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
630 case ButtonRelease:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
631
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
632 i = event->xbutton.button + 128;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
633
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
634 if (wsWindowList[l]->wsCursor != None) {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
635 wsMouseVisibility(wsWindowList[l], wsShowMouseCursor);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
636 mouse_win = wsWindowList[l];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
637 mouse_time = GetTimerMS();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
638 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
639
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
640 goto buttonreleased;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
641
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
642 case ButtonPress:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
643
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
644 i = event->xbutton.button;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
645
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
646 if (wsWindowList[l]->wsCursor != None) {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
647 wsMouseVisibility(wsWindowList[l], wsShowMouseCursor);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
648 mouse_win = wsWindowList[l];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
649 mouse_time = GetTimerMS();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
650 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
651
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
652 goto buttonreleased;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
653
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
654 case EnterNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
655
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
656 i = wsEnterWindow;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
657 goto buttonreleased;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
658
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
659 case LeaveNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
660
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
661 i = wsLeaveWindow;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
662 buttonreleased:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
663
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
664 if (wsWindowList[l]->MouseHandler)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
665 wsWindowList[l]->MouseHandler(i, event->xbutton.x, event->xbutton.y, event->xmotion.x_root, event->xmotion.y_root);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
666
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
667 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
668
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
669 case SelectionNotify:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
670
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
671 /* Handle DandD */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
672 wsXDNDProcessSelection(wsWindowList[l], event);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
673 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
674 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
675
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
676 XFlush(wsDisplay);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
677 XSync(wsDisplay, False);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
678 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
679
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
680 void wsEvents(void)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
681 {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
682 XEvent xev;
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
683 /* handle pending events */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
684 while (XPending(wsDisplay)) {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
685 XNextEvent(wsDisplay, &xev);
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
686 // printf("### X event: %d [%d]\n",xev.type,delay);
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
687 wsEvent(&xev);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
688 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
689 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
690
33995
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
691 /**
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
692 * @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
693 *
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
694 * @param win pointer to a ws window structure
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
695 * @param x x position of the window (real/absolute or mock)
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
696 * @param y y position of the window (real/absolute or mock)
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
697 * @param width width of the area to place the window in
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
698 * @param height height of the area to place the window in
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
699 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
700 static void wsWindowUpdatePosition(wsWindow *win, int x, int y, int width, int height)
33995
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
701 {
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
702 switch (x) {
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
703 case -1:
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
704 win->X = wsOrgX + (wsMaxX - width) / 2;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
705 break;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
706
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
707 case -2:
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
708 win->X = wsOrgX + wsMaxX - width;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
709 break;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
710
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
711 default:
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
712 win->X = x;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
713 break;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
714 }
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
715
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
716 switch (y) {
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
717 case -1:
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
718 win->Y = wsOrgY + (wsMaxY - height) / 2;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
719 break;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
720
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
721 case -2:
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
722 win->Y = wsOrgY + wsMaxY - height;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
723 break;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
724
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
725 default:
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
726 win->Y = y;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
727 break;
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
728 }
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
729 }
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
730
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
731 /**
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
732 * @brief Replace the size hints for the WM_NORMAL_HINTS property of a window.
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
733 *
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
734 * @param win pointer to a ws window structure
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
735 */
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
736 static void wsWindowSizeHint(wsWindow *win)
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
737 {
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
738 XSizeHints size;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
739
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
740 size.flags = 0;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
741
35648
238c621810b6 Simplify wsSizeHint() by dropping parameter 'hints'.
ib
parents: 35646
diff changeset
742 /* obsolete, solely for compatibility reasons */
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
743 size.flags |= PPosition;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
744 size.x = win->X;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
745 size.y = win->Y;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
746
35648
238c621810b6 Simplify wsSizeHint() by dropping parameter 'hints'.
ib
parents: 35646
diff changeset
747 /* obsolete, solely for compatibility reasons */
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
748 size.flags |= PSize;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
749 size.width = win->Width;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
750 size.height = win->Height;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
751
35648
238c621810b6 Simplify wsSizeHint() by dropping parameter 'hints'.
ib
parents: 35646
diff changeset
752 /* a minimum of 4 is said to avoid off-by-one errors and be required by mga_vid */
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
753 size.flags |= PMinSize;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
754 size.min_width = 4;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
755 size.min_height = 4;
35648
238c621810b6 Simplify wsSizeHint() by dropping parameter 'hints'.
ib
parents: 35646
diff changeset
756
238c621810b6 Simplify wsSizeHint() by dropping parameter 'hints'.
ib
parents: 35646
diff changeset
757 if (win->Property & wsMinSize) {
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
758 size.min_width = win->Width;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
759 size.min_height = win->Height;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
760 }
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
761
35648
238c621810b6 Simplify wsSizeHint() by dropping parameter 'hints'.
ib
parents: 35646
diff changeset
762 if (win->Property & wsMaxSize) {
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
763 size.flags |= PMaxSize;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
764 size.max_width = win->Width;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
765 size.max_height = win->Height;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
766 }
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
767
35657
eadf0731a29a Add property wsAspect.
ib
parents: 35656
diff changeset
768 if (vo_keepaspect && (win->Property & wsAspect)) {
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
769 size.flags |= PAspect;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
770 size.min_aspect.x = win->Width;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
771 size.min_aspect.y = win->Height;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
772 size.max_aspect.x = win->Width;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
773 size.max_aspect.y = win->Height;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
774 }
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
775
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
776 size.flags |= PBaseSize;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
777 size.base_width = 0;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
778 size.base_height = 0;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
779
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
780 size.flags |= PWinGravity;
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
781 size.win_gravity = StaticGravity;
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
782
35660
8de55114a330 Remove member SizeHint from wsWindow structure.
ib
parents: 35659
diff changeset
783 XSetWMNormalHints(wsDisplay, win->WindowID, &size);
35645
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
784 }
c0ec433fe432 Add new function wsSizeHint().
ib
parents: 35644
diff changeset
785
35699
36527758158b Make wsWindowDecoration() static.
ib
parents: 35698
diff changeset
786 static void wsWindowDecoration(wsWindow *win)
35698
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
787 {
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
788 Atom wsMotifHints;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
789 struct {
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
790 unsigned long flags;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
791 unsigned long functions;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
792 unsigned long decorations;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
793 long input_mode;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
794 unsigned long status;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
795 } wsMotifWmHints;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
796
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
797 wsMotifHints = XInternAtom(wsDisplay, "_MOTIF_WM_HINTS", 0);
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
798
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
799 if (wsMotifHints == None)
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
800 return;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
801
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
802 memset(&wsMotifWmHints, 0, sizeof(wsMotifWmHints));
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
803 wsMotifWmHints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
804
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
805 if (win->Decoration) {
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
806 wsMotifWmHints.functions = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
807
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
808 if (!(win->Property & wsMinSize) || !(win->Property & wsMaxSize))
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
809 wsMotifWmHints.functions |= MWM_FUNC_RESIZE;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
810
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
811 wsMotifWmHints.decorations = MWM_DECOR_ALL;
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
812 }
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
813
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
814 XChangeProperty(wsDisplay, win->WindowID, wsMotifHints, wsMotifHints, 32,
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
815 PropModeReplace, (unsigned char *)&wsMotifWmHints, 5);
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
816 }
e44757ea8f94 Cosmetic: Relocate wsWindowDecoration().
ib
parents: 35697
diff changeset
817
35652
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
818 /**
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
819 * @brief Wait until a window is mapped if its property requires it.
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
820 *
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
821 * @param win pointer to a ws window structure
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
822 */
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
823 static void wsWindowMapWait(wsWindow *win)
35652
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
824 {
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
825 XEvent xev;
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
826
35653
59a6b817a287 Add the 'Mapped' information to wsMapWait().
ib
parents: 35652
diff changeset
827 if (win->Property & wsWaitMap) {
35652
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
828 do
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
829 XNextEvent(wsDisplay, &xev);
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
830 while (xev.type != MapNotify || xev.xmap.event != win->WindowID);
35653
59a6b817a287 Add the 'Mapped' information to wsMapWait().
ib
parents: 35652
diff changeset
831
59a6b817a287 Add the 'Mapped' information to wsMapWait().
ib
parents: 35652
diff changeset
832 win->Mapped = wsMapped;
59a6b817a287 Add the 'Mapped' information to wsMapWait().
ib
parents: 35652
diff changeset
833 }
35652
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
834 }
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
835
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
836 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
837 // Create window.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
838 // X,Y : window position
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
839 // wX,wY : size of window
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
840 // bW : border width
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
841 // cV : visible mouse cursor on window
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
842 // D : visible frame, title, etc.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
843 // sR : screen ratio
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
844 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
845
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
846 XClassHint wsClassHint;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
847 XTextProperty wsTextProperty;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
848 Window LeaderWindow;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
849
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
850 // ----------------------------------------------------------------------------------------------
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
851 // wsWindowCreate: create a new window on the screen.
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
852 // x,y : window position
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
853 // w,h : window size
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
854 // c : mouse cursor visible
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
855 // p : properties - "decoration", visible titlebar, etc ...
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
856 // ----------------------------------------------------------------------------------------------
35687
6996700b8d1f Don't unnecessarily restrict property mask to 8 bits.
ib
parents: 35683
diff changeset
857 void wsWindowCreate(wsWindow *win, int x, int y, int w, int h, int p, int c, char *label)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
858 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
859 int depth;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
860
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
861 win->Property = p;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
862
35697
13f8a04c5524 Remove redundant parameter from function.
ib
parents: 35696
diff changeset
863 win->Decoration = ((p & wsShowFrame) != 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
864
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
865 wsWindowUpdatePosition(win, x, y, w, h);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
866
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
867 win->Width = w;
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
868 win->Height = h;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
869 win->OldX = win->X;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
870 win->OldY = win->Y;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
871 win->OldWidth = win->Width;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
872 win->OldHeight = win->Height;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
873
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34470
diff changeset
874 /* Hide Mouse Cursor */
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
875 win->wsCursor = None;
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
876 win->wsMouseEventType = c;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
877 win->wsCursorData[0] = 0;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
878 win->wsCursorPixmap = XCreateBitmapFromData(wsDisplay, wsRootWin, win->wsCursorData, 1, 1);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
879
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
880 if (!(c & wsShowMouseCursor))
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
881 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
882
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
883 depth = vo_find_depth_from_visuals(wsDisplay, wsScreen, NULL);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
884
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
885 if (depth < 15) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
886 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ColorDepthTooLow);
33768
cee9987bc81d Remove guiExit().
ib
parents: 33550
diff changeset
887 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
888 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
889
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
890 XMatchVisualInfo(wsDisplay, wsScreen, depth, TrueColor, &win->VisualInfo);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
891
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34470
diff changeset
892 /* --- */
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
893 win->AtomLeaderClient = XInternAtom(wsDisplay, "WM_CLIENT_LEADER", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
894 win->AtomDeleteWindow = XInternAtom(wsDisplay, "WM_DELETE_WINDOW", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
895 win->AtomTakeFocus = XInternAtom(wsDisplay, "WM_TAKE_FOCUS", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
896 win->AtomRolle = XInternAtom(wsDisplay, "WM_WINDOW_ROLE", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
897 win->AtomWMSizeHint = XInternAtom(wsDisplay, "WM_SIZE_HINT", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
898 win->AtomWMNormalHint = XInternAtom(wsDisplay, "WM_NORMAL_HINT", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
899 win->AtomProtocols = XInternAtom(wsDisplay, "WM_PROTOCOLS", False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
900 win->AtomsProtocols[0] = win->AtomDeleteWindow;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
901 win->AtomsProtocols[1] = win->AtomTakeFocus;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
902 win->AtomsProtocols[2] = win->AtomRolle;
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34470
diff changeset
903 /* --- */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
904
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
905 win->WindowAttrib.background_pixel = BlackPixel(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
906 win->WindowAttrib.border_pixel = WhitePixel(wsDisplay, wsScreen);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
907 win->WindowAttrib.colormap = XCreateColormap(wsDisplay, wsRootWin, win->VisualInfo.visual, AllocNone);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
908 win->WindowAttrib.event_mask = StructureNotifyMask | FocusChangeMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
909 ExposureMask | PropertyChangeMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
910 EnterWindowMask | LeaveWindowMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
911 VisibilityChangeMask |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
912 KeyPressMask | KeyReleaseMask;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
913
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
914 if ((c & wsHandleMouseButton))
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
915 win->WindowAttrib.event_mask |= ButtonPressMask | ButtonReleaseMask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
916
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
917 if ((c & wsHandleMouseMove))
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
918 win->WindowAttrib.event_mask |= PointerMotionMask;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
919
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
920 win->WindowAttrib.cursor = win->wsCursor;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
921 win->WindowAttrib.override_redirect = False;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
922
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
923 if (p & wsOverredirect)
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
924 win->WindowAttrib.override_redirect = True;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
925
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
926 win->WindowMask = CWBackPixel | CWBorderPixel |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
927 CWColormap | CWEventMask | CWCursor |
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
928 CWOverrideRedirect;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
929
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
930 win->WindowID = XCreateWindow(wsDisplay,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
931 (win->Parent != 0 ? win->Parent : wsRootWin),
35683
75155d8a9c7e Remove parameter for border_width from wsWindowCreate().
ib
parents: 35682
diff changeset
932 win->X, win->Y, win->Width, win->Height, 0,
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
933 win->VisualInfo.depth,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
934 InputOutput,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
935 win->VisualInfo.visual,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
936 win->WindowMask, &win->WindowAttrib);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
937
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
938 wsClassHint.res_name = "MPlayer";
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
939
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
940 wsClassHint.res_class = "MPlayer";
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
941 XSetClassHint(wsDisplay, win->WindowID, &wsClassHint);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
942
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
943 wsWindowSizeHint(win);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
944
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
945 win->WMHints.flags = InputHint | StateHint;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
946 win->WMHints.input = True;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
947 win->WMHints.initial_state = NormalState;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
948 XSetWMHints(wsDisplay, win->WindowID, &win->WMHints);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
949
35697
13f8a04c5524 Remove redundant parameter from function.
ib
parents: 35696
diff changeset
950 wsWindowDecoration(win);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
951 XStoreName(wsDisplay, win->WindowID, label);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
952 XmbSetWMProperties(wsDisplay, win->WindowID, label, label, NULL, 0, NULL, NULL, NULL);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
953
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
954 XSetWMProtocols(wsDisplay, win->WindowID, win->AtomsProtocols, 3);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
955 XChangeProperty(wsDisplay, win->WindowID,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
956 win->AtomLeaderClient,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
957 XA_WINDOW, 32, PropModeReplace,
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
958 (unsigned char *)&LeaderWindow, 1);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
959
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
960 wsTextProperty.value = label;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
961 wsTextProperty.encoding = XA_STRING;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
962 wsTextProperty.format = 8;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
963 wsTextProperty.nitems = strlen(label);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
964 XSetWMIconName(wsDisplay, win->WindowID, &wsTextProperty);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
965
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
966 win->wGC = XCreateGC(wsDisplay, win->WindowID,
35679
23183b261ca9 Remove unused structure member wGCV.
ib
parents: 35678
diff changeset
967 0,
23183b261ca9 Remove unused structure member wGCV.
ib
parents: 35678
diff changeset
968 NULL);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
969
35498
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
970 win->Visible = wsNo;
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
971 win->Focused = wsNo;
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
972 win->Mapped = wsNo;
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
973 win->Rolled = wsNo;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
974
35655
9ea476ced9ab Cosmetic: Change parameter names.
ib
parents: 35653
diff changeset
975 if (p & wsShowWindow) {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
976 XMapWindow(wsDisplay, win->WindowID);
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
977 wsWindowMapWait(win);
35652
f6c00eacd816 Add wsMapWait().
ib
parents: 35651
diff changeset
978 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
979
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
980 wsImageCreate(win, win->Width, win->Height);
34684
b03481253518 Cosmetic: Prefer C style for single line comments.
ib
parents: 34470
diff changeset
981 /* End of creating -------------------------------------------------------------------------- */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
982
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
983 {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
984 int i;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
985
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
986 for (i = 0; i < wsWLCount; i++)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
987 if (wsWindowList[i] == NULL)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
988 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
989
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
990 if (i == wsWLCount) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
991 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_TooManyOpenWindows);
33768
cee9987bc81d Remove guiExit().
ib
parents: 33550
diff changeset
992 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
993 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
994
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
995 wsWindowList[i] = win;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
996 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
997
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
998 XFlush(wsDisplay);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
999 XSync(wsDisplay, False);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1000
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1001 win->ReDraw = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1002 win->MouseHandler = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1003 win->KeyHandler = NULL;
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33977
diff changeset
1004 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] window is created. ( %s ).\n", label);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1005 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1006
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1007 void wsWindowDestroy(wsWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1008 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1009 int l;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1010
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1011 l = wsWindowListSearch(win->WindowID);
35354
2ce3d21157ed Check array index.
ib
parents: 34684
diff changeset
1012
2ce3d21157ed Check array index.
ib
parents: 34684
diff changeset
1013 if (l != -1)
2ce3d21157ed Check array index.
ib
parents: 34684
diff changeset
1014 wsWindowList[l] = NULL;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1015
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1016 if (win->wsCursor != None) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1017 XFreeCursor(wsDisplay, win->wsCursor);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1018 win->wsCursor = None;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1019 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1020
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1021 XFreeGC(wsDisplay, win->wGC);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1022 XUnmapWindow(wsDisplay, win->WindowID);
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1023 wsImageDestroy(win);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1024 XDestroyWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1025 #if 0
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1026 win->ReDraw = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1027 win->MouseHandler = NULL;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1028 win->KeyHandler = NULL;
35498
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
1029 win->Visible = wsNo;
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
1030 win->Focused = wsNo;
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
1031 win->Mapped = wsNo;
c505a4aa9582 Rename wsNone wsNo and use it instead of a numeric constant.
ib
parents: 35497
diff changeset
1032 win->Rolled = wsNo;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1033 #endif
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1034 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1035
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1036 void wsWindowShape(wsWindow *win, char *data)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1037 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1038 #ifdef CONFIG_XSHAPE
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1039 if (!wsUseXShape)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1040 return;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1041
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1042 if (data) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1043 win->Mask = XCreateBitmapFromData(wsDisplay, win->WindowID, data, win->Width, win->Height);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1044 XShapeCombineMask(wsDisplay, win->WindowID, ShapeBounding, 0, 0, win->Mask, ShapeSet);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1045 XFreePixmap(wsDisplay, win->Mask);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1046 } else
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1047 XShapeCombineMask(wsDisplay, win->WindowID, ShapeBounding, 0, 0, None, ShapeSet);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1048 #endif
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1049 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1050
34081
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
1051 /**
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1052 * @brief Set differently sized icons to a window.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1053 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1054 * This function sets the X icon hint as well as
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1055 * the properties KWM_WIN_ICON and _NET_WM_ICON.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1056 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1057 * @param display display
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1058 * @param Win window
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1059 * @param icon pointer to the icons
34081
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
1060 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1061 void wsWindowIcon(Display *display, Window Win, guiIcon_t *icon)
34081
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
1062 {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1063 XWMHints *wm;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1064 Atom iconatom;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1065 long data[2];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1066
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1067 if (icon->normal) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1068 wm = XGetWMHints(display, Win);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1069
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1070 if (!wm)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1071 wm = XAllocWMHints();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1072
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1073 wm->icon_pixmap = icon->normal;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1074 wm->icon_mask = icon->normal_mask;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1075 wm->flags |= IconPixmapHint | IconMaskHint;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1076
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1077 XSetWMHints(display, Win, wm);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1078 XFree(wm);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1079 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1080
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1081 if (icon->small || icon->normal) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1082 iconatom = XInternAtom(display, "KWM_WIN_ICON", False);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1083 data[0] = (icon->small ? icon->small : icon->normal);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1084 data[1] = (icon->small ? icon->small_mask : icon->normal_mask);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1085
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1086 XChangeProperty(display, Win, iconatom, iconatom, 32, PropModeReplace, (unsigned char *)data, 2);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1087 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1088
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1089 if (icon->collection) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1090 iconatom = XInternAtom(display, "_NET_WM_ICON", False);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1091 XChangeProperty(display, Win, iconatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)icon->collection, icon->collection_size);
34081
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
1092 }
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
1093 }
66c5a04a5c32 Fix cursor autohide functionality of the GUI.
ib
parents: 34034
diff changeset
1094
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1095 // ----------------------------------------------------------------------------------------------
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1096 // Set window background to 'color'.
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1097 // ----------------------------------------------------------------------------------------------
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1098 void wsWindowBackground(wsWindow *win, int r, int g, int b)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1099 {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1100 int color = 0;
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35499
diff changeset
1101
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1102 switch (wsOutMask) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1103 case wsRGB32:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1104 case wsRGB24:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1105 color = (r << 16) + (g << 8) + b;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1106 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1107
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1108 case wsBGR32:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1109 case wsBGR24:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1110 color = (b << 16) + (g << 8) + r;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1111 break;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1112
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1113 case wsRGB16:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1114 PACK_RGB16(b, g, r, color);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1115 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1116
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1117 case wsBGR16:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1118 PACK_RGB16(r, g, b, color);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1119 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1120
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1121 case wsRGB15:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1122 PACK_RGB15(b, g, r, color);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1123 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1124
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1125 case wsBGR15:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1126 PACK_RGB15(r, g, b, color);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1127 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1128 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1129
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1130 XSetWindowBackground(wsDisplay, win->WindowID, color);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1131 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1132
34009
5c33025ccfd8 Replace comment for wsFullScreen() by doxygen comment.
ib
parents: 34008
diff changeset
1133 /**
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1134 * @brief Clear the entire area in a window.
34009
5c33025ccfd8 Replace comment for wsFullScreen() by doxygen comment.
ib
parents: 34008
diff changeset
1135 *
5c33025ccfd8 Replace comment for wsFullScreen() by doxygen comment.
ib
parents: 34008
diff changeset
1136 * @param win pointer to a ws window structure
5c33025ccfd8 Replace comment for wsFullScreen() by doxygen comment.
ib
parents: 34008
diff changeset
1137 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1138 void wsWindowClear(wsWindow *win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1139 {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1140 XClearWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1141 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1142
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1143 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1144 // Move window to x, y.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1145 // ----------------------------------------------------------------------------------------------
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1146 void wsWindowMove(wsWindow *win, Bool abs, int x, int y)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1147 {
33993
57d711d3dcca Change parameter b of wsMoveWindow().
ib
parents: 33992
diff changeset
1148 if (abs) {
57d711d3dcca Change parameter b of wsMoveWindow().
ib
parents: 33992
diff changeset
1149 win->X = x;
57d711d3dcca Change parameter b of wsMoveWindow().
ib
parents: 33992
diff changeset
1150 win->Y = y;
33995
9c2779f24077 Move common code to new function wsWindowPosition().
ib
parents: 33994
diff changeset
1151 } else
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1152 wsWindowUpdatePosition(win, x, y, win->Width, win->Height);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1153
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
1154 wsWindowSizeHint(win);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1155 XMoveWindow(wsDisplay, win->WindowID, win->X, win->Y);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1156 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1157
33998
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1158 /**
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1159 * @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
1160 * 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
1161 *
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1162 * @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
1163 * @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
1164 * @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
1165 * @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
1166 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1167 void wsWindowMoveWithin(wsWindow *win, Bool abs, int x, int y)
33998
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1168 {
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1169 Bool fitting = True;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1170
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1171 wsWindowMove(win, abs, x, y);
33998
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1172
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1173 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
1174 fitting = False;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1175 win->X = wsMaxX - win->Width;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1176
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1177 if (win->X < 0)
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1178 win->X = 0;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1179 }
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1180
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1181 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
1182 fitting = False;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1183 win->Y = wsMaxY - win->Height;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1184
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1185 if (win->Y < 0)
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1186 win->Y = 0;
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1187 }
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1188
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1189 if (!fitting)
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1190 wsWindowMove(win, True, win->X, win->Y);
33998
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1191 }
ca20e4098c1d Preserve x and y position of a double-size window if possible.
ib
parents: 33996
diff changeset
1192
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1193 // ----------------------------------------------------------------------------------------------
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1194 // Resize window to sx, sy.
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1195 // ----------------------------------------------------------------------------------------------
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1196 void wsWindowResize(wsWindow *win, int w, int h)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1197 {
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1198 win->Width = w;
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1199 win->Height = h;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1200
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1201 if (vo_wm_type == 0)
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1202 XUnmapWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1203
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
1204 wsWindowSizeHint(win);
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1205 XResizeWindow(wsDisplay, win->WindowID, w, h);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1206
34124
7777da659cbe Fix bug in wsResizeWindow().
ib
parents: 34083
diff changeset
1207 if (vo_wm_type == 0)
7777da659cbe Fix bug in wsResizeWindow().
ib
parents: 34083
diff changeset
1208 XMapWindow(wsDisplay, win->WindowID);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1209 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1210
35355
c8478a499a17 Pass big parameter by reference rather than by value.
ib
parents: 35354
diff changeset
1211 /**
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1212 * @brief Switch window fullscreen state.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1213 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1214 * Switch normal window to fullscreen and fullscreen window to normal.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1215 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1216 * @param win pointer to a ws window structure
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1217 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1218 void wsWindowFullscreen(wsWindow *win)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1219 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1220 if (win->isFullScreen) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1221 if (vo_fs_type & vo_wm_FULLSCREEN)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1222 /* window manager supports EWMH */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1223 vo_x11_ewmh_fullscreen(win->WindowID, _NET_WM_STATE_REMOVE);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1224 else {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1225 win->X = win->OldX;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1226 win->Y = win->OldY;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1227 win->Width = win->OldWidth;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1228 win->Height = win->OldHeight;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1229 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1230
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1231 win->isFullScreen = False;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1232 } else {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1233 if (vo_fs_type & vo_wm_FULLSCREEN)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1234 /* window manager supports EWMH */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1235 vo_x11_ewmh_fullscreen(win->WindowID, _NET_WM_STATE_ADD);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1236 else {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1237 win->OldX = win->X;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1238 win->OldY = win->Y;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1239 win->OldWidth = win->Width;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1240 win->OldHeight = win->Height;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1241 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1242
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1243 win->isFullScreen = True;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1244
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1245 wsWindowUpdateXinerama(win);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1246 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1247
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1248 /* unknown window manager and obsolete option -fsmode used */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1249 if (vo_wm_type == 0 && !(vo_fsmode & 16)) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1250 XUnmapWindow(wsDisplay, win->WindowID); // required for MWM
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1251 XWithdrawWindow(wsDisplay, win->WindowID, wsScreen);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1252 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1253
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1254 /* restore window if window manager doesn't support EWMH */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1255 if (!(vo_fs_type & vo_wm_FULLSCREEN)) {
35697
13f8a04c5524 Remove redundant parameter from function.
ib
parents: 35696
diff changeset
1256 if (!win->isFullScreen)
13f8a04c5524 Remove redundant parameter from function.
ib
parents: 35696
diff changeset
1257 wsWindowDecoration(win);
13f8a04c5524 Remove redundant parameter from function.
ib
parents: 35696
diff changeset
1258
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
1259 wsWindowSizeHint(win);
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1260 wsWindowLayer(wsDisplay, win->WindowID, win->isFullScreen);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1261 XMoveResizeWindow(wsDisplay, win->WindowID, win->X, win->Y, win->Width, win->Height);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1262 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1263
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1264 /* some window managers lose ontop after fullscreen */
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1265 if (!win->isFullScreen & vo_ontop)
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1266 wsWindowLayer(wsDisplay, win->WindowID, vo_ontop);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1267
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1268 wsWindowRaiseTop(wsDisplay, win->WindowID);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1269 XFlush(wsDisplay);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1270 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1271
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1272 /**
35355
c8478a499a17 Pass big parameter by reference rather than by value.
ib
parents: 35354
diff changeset
1273 * @brief Iconify a window.
c8478a499a17 Pass big parameter by reference rather than by value.
ib
parents: 35354
diff changeset
1274 *
c8478a499a17 Pass big parameter by reference rather than by value.
ib
parents: 35354
diff changeset
1275 * @param win pointer to a ws window structure
c8478a499a17 Pass big parameter by reference rather than by value.
ib
parents: 35354
diff changeset
1276 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1277 void wsWindowIconify(wsWindow *win)
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1278 {
35355
c8478a499a17 Pass big parameter by reference rather than by value.
ib
parents: 35354
diff changeset
1279 XIconifyWindow(wsDisplay, win->WindowID, 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1280 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1281
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1282 void wsWindowVisibility(wsWindow *win, int vis)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1283 {
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1284 switch (vis) {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1285 case wsShowWindow:
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35499
diff changeset
1286
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1287 XMapRaised(wsDisplay, win->WindowID);
35700
7820bad7c1f8 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35699
diff changeset
1288 wsWindowMapWait(win);
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35499
diff changeset
1289
33952
75b858ef3666 Keep track of fullscreen state.
ib
parents: 33937
diff changeset
1290 if (vo_fs_type & vo_wm_FULLSCREEN)
75b858ef3666 Keep track of fullscreen state.
ib
parents: 33937
diff changeset
1291 win->isFullScreen = False;
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35499
diff changeset
1292
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1293 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1294
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1295 case wsHideWindow:
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35499
diff changeset
1296
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1297 XUnmapWindow(wsDisplay, win->WindowID);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1298 break;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1299 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1300
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1301 XFlush(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1302 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1303
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1304 /**
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1305 * @brief Map a window and raise it to the top.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1306 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1307 * @param display display
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1308 * @param Win window
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1309 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1310 void wsWindowRaiseTop(Display *display, Window Win)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1311 {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1312 XMapRaised(display, Win); // NOTE TO MYSELF: is that really enough?
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1313 XRaiseWindow(display, Win); // NOTE TO MYSELF: is that really enough?
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1314 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1315
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1316 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1317 // Move window to selected layer
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1318 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1319
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1320 /**
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1321 * @brief Set the layer for a window.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1322 *
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1323 * @param display display
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1324 * @param Win window
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1325 * @param fullscreen whether to set fullscreen or normal layer
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1326 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1327 void wsWindowLayer(Display *display, Window Win, Bool fullscreen)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1328 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1329 vo_x11_setlayer(display, Win, fullscreen);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1330 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1331
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1332 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1333 // Redraw screen.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1334 // ----------------------------------------------------------------------------------------------
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1335 void wsWindowRedraw(wsWindow *win)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1336 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1337 if (win->ReDraw) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1338 win->State = wsWindowExpose;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1339 win->ReDraw();
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1340 XFlush(wsDisplay);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1341 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1342 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1343
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1344 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1345 // Put 'Image' to window.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1346 // ----------------------------------------------------------------------------------------------
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1347 void wsImageCreate(wsWindow *win, int w, int h)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1348 {
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
1349 #ifdef HAVE_SHM
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1350 if (wsUseXShm) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1351 win->xImage = XShmCreateImage(wsDisplay, win->VisualInfo.visual,
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1352 win->VisualInfo.depth, ZPixmap, NULL, &win->Shminfo, w, h);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1353
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1354 if (win->xImage == NULL) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1355 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError);
33768
cee9987bc81d Remove guiExit().
ib
parents: 33550
diff changeset
1356 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1357 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1358
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1359 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
1360
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1361 if (win->Shminfo.shmid < 0) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1362 XDestroyImage(win->xImage);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1363 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError);
33768
cee9987bc81d Remove guiExit().
ib
parents: 33550
diff changeset
1364 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
33539
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
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1367 win->Shminfo.shmaddr = (char *)shmat(win->Shminfo.shmid, 0, 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1368
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1369 if (win->Shminfo.shmaddr == ((char *)-1)) {
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1370 XDestroyImage(win->xImage);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1371
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1372 if (win->Shminfo.shmaddr != ((char *)-1))
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1373 shmdt(win->Shminfo.shmaddr);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1374
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1375 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_ShmError);
33768
cee9987bc81d Remove guiExit().
ib
parents: 33550
diff changeset
1376 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1377 }
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1378
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1379 win->xImage->data = win->Shminfo.shmaddr;
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35492
diff changeset
1380 win->Shminfo.readOnly = False;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1381 XShmAttach(wsDisplay, &win->Shminfo);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1382 XSync(wsDisplay, False);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1383 shmctl(win->Shminfo.shmid, IPC_RMID, 0);
34465
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
1384 } else
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
1385 #endif
3c1a1038bfc7 Properly handle the lack of XShm.
ib
parents: 34463
diff changeset
1386 {
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1387 win->xImage = XCreateImage(wsDisplay, win->VisualInfo.visual, win->VisualInfo.depth,
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1388 ZPixmap, 0, 0, w, h,
35676
b0ad675bd3b7 Cosmetic: Rename DepthOnScreen ScreenDepth.
ib
parents: 35674
diff changeset
1389 (wsScreenDepth == 3) ? 32 : wsScreenDepth,
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1390 0);
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1391
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1392 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
1393 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_WS_NotEnoughMemoryDrawBuffer);
33768
cee9987bc81d Remove guiExit().
ib
parents: 33550
diff changeset
1394 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1395 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1396 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1397
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1398 win->ImageData = (unsigned char *)win->xImage->data;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1399 win->ImageDataw = (unsigned short int *)win->xImage->data;
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1400 win->ImageDatadw = (unsigned int *)win->xImage->data;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1401 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1402
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1403 void wsImageDestroy(wsWindow *win)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1404 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1405 if (win->xImage) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1406 XDestroyImage(win->xImage);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1407
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1408 #ifdef HAVE_SHM
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1409 if (wsUseXShm) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1410 XShmDetach(wsDisplay, &win->Shminfo);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1411 shmdt(win->Shminfo.shmaddr);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1412 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1413 #endif
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1414 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1415
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1416 win->xImage = NULL;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1417 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1418
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1419 void wsImageConvert(wsWindow *win, unsigned char *img)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1420 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1421 static struct SwsContext *sws_ctx;
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1422 const uint8_t *src[4] = { img, NULL, NULL, NULL };
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1423 int src_stride[4] = { 4 * win->xImage->width, 0, 0, 0 };
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1424 uint8_t *dst[4] = { win->ImageData, NULL, NULL, NULL };
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1425 int dst_stride[4];
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1426 int i;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1427
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1428 sws_ctx = sws_getCachedContext(sws_ctx, win->xImage->width, win->xImage->height, PIX_FMT_RGB32,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1429 win->xImage->width, win->xImage->height, out_pix_fmt,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1430 SWS_POINT, NULL, NULL, NULL);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1431 av_image_fill_linesizes(dst_stride, out_pix_fmt, win->xImage->width);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1432 sws_scale(sws_ctx, src, src_stride, 0, win->xImage->height, dst, dst_stride);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1433
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1434 if (!wsNonNativeOrder)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1435 return;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1436
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1437 switch (win->xImage->bits_per_pixel) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1438 case 32:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1439 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1440 uint32_t *d = (uint32_t *)win->ImageData;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1441
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1442 for (i = 0; i < win->xImage->width * win->xImage->height; i++)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1443 d[i] = bswap_32(d[i]);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1444
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1445 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1446 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1447
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1448 case 16:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1449 case 15:
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1450 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1451 uint16_t *d = (uint16_t *)win->ImageData;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1452
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1453 for (i = 0; i < win->xImage->width * win->xImage->height; i++)
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1454 d[i] = bswap_16(d[i]);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1455
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1456 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1457 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1458 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1459 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1460
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1461 void wsImageDraw(wsWindow *win)
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1462 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1463 #ifdef HAVE_SHM
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1464 if (wsUseXShm) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1465 XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1466 0, 0,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1467 (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1468 win->xImage->width, win->xImage->height, 0);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1469 } else
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1470 #endif
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1471 {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1472 XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1473 0, 0,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1474 (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1475 win->xImage->width, win->xImage->height);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1476 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1477 }
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1478
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1479 void wsImageResize(wsWindow *win, int w, int h)
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1480 {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1481 wsImageDestroy(win);
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1482 wsImageCreate(win, w, h);
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1483 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1484
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1485 // ----------------------------------------------------------------------------------------------
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1486 // Show / hide mouse cursor.
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1487 // ----------------------------------------------------------------------------------------------
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1488 void wsMouseVisibility(wsWindow *win, int vis)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1489 {
35682
fcb8f12cefa7 Cosmetic: Change parameter names.
ib
parents: 35681
diff changeset
1490 switch (vis) {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1491 case wsShowMouseCursor:
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1492
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1493 if (win->wsCursor != None) {
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1494 XFreeCursor(wsDisplay, win->wsCursor);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1495 win->wsCursor = None;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1496 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1497
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1498 XDefineCursor(wsDisplay, win->WindowID, 0);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1499 break;
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1500
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1501 case wsHideMouseCursor:
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1502
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1503 win->wsCursor = XCreatePixmapCursor(wsDisplay, win->wsCursorPixmap, win->wsCursorPixmap, &win->wsColor, &win->wsColor, 0, 0);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1504 XDefineCursor(wsDisplay, win->WindowID, win->wsCursor);
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1505 break;
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1506 }
33539
5bdc088113f7 Cosmetic: Format to MPlayer coding style.
ib
parents: 33529
diff changeset
1507
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1508 XFlush(wsDisplay);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1509 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1510
35639
2e7f2ecaaf0b Don't define a function by a macro.
ib
parents: 35637
diff changeset
1511 /**
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1512 * @brief Handle automatic hiding of the cursor.
35639
2e7f2ecaaf0b Don't define a function by a macro.
ib
parents: 35637
diff changeset
1513 */
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1514 void wsMouseAutohide(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1515 {
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1516 if (mouse_win && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
35681
80c5c89f77d6 Cosmetic: Rename ws functions for the sake of consistency.
ib
parents: 35680
diff changeset
1517 wsMouseVisibility(mouse_win, wsHideMouseCursor);
35672
144d3a71db7d Cosmetic: Relocate some functions.
ib
parents: 35670
diff changeset
1518 mouse_win = NULL;
33542
107084241b00 Add support for _NET_WM_ICON
ib
parents: 33541
diff changeset
1519 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1520 }