Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 28201:4ff973912251
Rename libaf/af_resample.h to libaf/af_resample_template.c, it is used as
a macro, not as a header file.
author | diego |
---|---|
date | Fri, 02 Jan 2009 16:13:22 +0000 |
parents | b3db050cbd0d |
children | a4aa7ecd8cbe |
rev | line source |
---|---|
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1 |
32 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
4 #include <math.h> |
6401 | 5 #include <inttypes.h> |
27893 | 6 #include <limits.h> |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
7 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
8 #include "config.h" |
5998 | 9 #include "mp_msg.h" |
22823
98eaf29b5dee
Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents:
21964
diff
changeset
|
10 #include "mp_fifo.h" |
6401 | 11 #include "x11_common.h" |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
12 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
13 #ifdef X11_FULLSCREEN |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
14 |
440
d19a3da6ac13
Pontscho's mixer, select, and hell-a-lot-of-stuff patch ;)
gabucino
parents:
416
diff
changeset
|
15 #include <string.h> |
32 | 16 #include <unistd.h> |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
17 #include <assert.h> |
32 | 18 |
19 #include "video_out.h" | |
10889 | 20 #include "aspect.h" |
12032
8cc4d4344c0f
Don't mess with the window position in xinerama when -geometry changes it.
diego
parents:
12031
diff
changeset
|
21 #include "geometry.h" |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
22 #include "help_mp.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
23 #include "osdep/timer.h" |
32 | 24 |
324 | 25 #include <X11/Xmd.h> |
32 | 26 #include <X11/Xlib.h> |
27 #include <X11/Xutil.h> | |
28 #include <X11/Xatom.h> | |
29 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
30 #ifdef CONFIG_XSS |
25482 | 31 #include <X11/extensions/scrnsaver.h> |
32 #endif | |
33 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
34 #ifdef CONFIG_XDPMS |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
35 #include <X11/extensions/dpms.h> |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
36 #endif |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
37 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
38 #ifdef CONFIG_XINERAMA |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
39 #include <X11/extensions/Xinerama.h> |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
40 #endif |
1732 | 41 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
42 #ifdef CONFIG_XF86VM |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
43 #include <X11/extensions/xf86vmode.h> |
14636
408bcfa575bf
Separate XF86 video mode extension check from XF86 keysym check as
diego
parents:
14244
diff
changeset
|
44 #endif |
408bcfa575bf
Separate XF86 video mode extension check from XF86 keysym check as
diego
parents:
14244
diff
changeset
|
45 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
46 #ifdef CONFIG_XF86XK |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
47 #include <X11/XF86keysym.h> |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
48 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
49 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
50 #ifdef CONFIG_XV |
10359 | 51 #include <X11/extensions/Xv.h> |
52 #include <X11/extensions/Xvlib.h> | |
14742 | 53 |
54 #include "subopt-helper.h" | |
10359 | 55 #endif |
56 | |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
57 #include "input/input.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
58 #include "input/mouse.h" |
4658 | 59 |
27343 | 60 #ifdef CONFIG_GUI |
23077 | 61 #include "gui/interface.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
62 #include "mplayer.h" |
4798 | 63 #endif |
64 | |
8660
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
65 #define WIN_LAYER_ONBOTTOM 2 |
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
66 #define WIN_LAYER_NORMAL 4 |
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
67 #define WIN_LAYER_ONTOP 6 |
8669
fd398a0b4b3b
This time the patch is fixing much more that breaking :-)
arpi
parents:
8663
diff
changeset
|
68 #define WIN_LAYER_ABOVE_DOCK 10 |
12582 | 69 |
19850
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
70 extern int enable_mouse_movements; |
12582 | 71 int fs_layer = WIN_LAYER_ABOVE_DOCK; |
72 static int orig_layer = 0; | |
12111
8e31aacc3e81
- win_gravity memorizing and restoring while switching fullscreen mode (by Adam Tla/lka)
rathann
parents:
12096
diff
changeset
|
73 static int old_gravity = NorthWestGravity; |
8866 | 74 |
12582 | 75 int stop_xscreensaver = 0; |
6202 | 76 |
12582 | 77 static int dpms_disabled = 0; |
324 | 78 |
12582 | 79 char *mDisplayName = NULL; |
80 Display *mDisplay = NULL; | |
81 Window mRootWin; | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
82 int mScreen; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
83 int mLocalDisplay; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
84 |
3830 | 85 /* output window id */ |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
86 int vo_mouse_autohide = 0; |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
87 int vo_wm_type = 0; |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
88 int vo_fs_type = 0; // needs to be accessible for GUI X11 code |
12125
f4fc74a88e65
full screen flipping synchronization corrections (by Adam Tla/lka)
rathann
parents:
12123
diff
changeset
|
89 static int vo_fs_flip = 0; |
12582 | 90 char **vo_fstype_list; |
384 | 91 |
21938 | 92 /* 1 means that the WM is metacity (broken as hell) */ |
8835
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
93 int metacity_hack = 0; |
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
94 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
95 static Atom XA_NET_SUPPORTED; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
96 static Atom XA_NET_WM_STATE; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
97 static Atom XA_NET_WM_STATE_FULLSCREEN; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
98 static Atom XA_NET_WM_STATE_ABOVE; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
99 static Atom XA_NET_WM_STATE_STAYS_ON_TOP; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
100 static Atom XA_NET_WM_STATE_BELOW; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
101 static Atom XA_NET_WM_PID; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
102 static Atom XA_WIN_PROTOCOLS; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
103 static Atom XA_WIN_LAYER; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
104 static Atom XA_WIN_HINTS; |
18149
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
105 static Atom XAWM_PROTOCOLS; |
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
106 static Atom XAWM_DELETE_WINDOW; |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
107 |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
108 #define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False) |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
109 |
7435 | 110 static int vo_old_x = 0; |
111 static int vo_old_y = 0; | |
112 static int vo_old_width = 0; | |
113 static int vo_old_height = 0; | |
114 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
115 #ifdef CONFIG_XF86VM |
12582 | 116 XF86VidModeModeInfo **vidmodes = NULL; |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
117 XF86VidModeModeLine modeline; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
118 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
119 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
120 static int vo_x11_get_fs_type(int supported); |
10212
d358fa9a1068
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
alex
parents:
10193
diff
changeset
|
121 |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
122 |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
123 /* |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
124 * Sends the EWMH fullscreen state event. |
21938 | 125 * |
126 * action: could be one of _NET_WM_STATE_REMOVE -- remove state | |
127 * _NET_WM_STATE_ADD -- add state | |
128 * _NET_WM_STATE_TOGGLE -- toggle | |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
129 */ |
12582 | 130 void vo_x11_ewmh_fullscreen(int action) |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
131 { |
12582 | 132 assert(action == _NET_WM_STATE_REMOVE || |
133 action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE); | |
134 | |
135 if (vo_fs_type & vo_wm_FULLSCREEN) | |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
136 { |
12582 | 137 XEvent xev; |
138 | |
21938 | 139 /* init X event structure for _NET_WM_FULLSCREEN client message */ |
12582 | 140 xev.xclient.type = ClientMessage; |
141 xev.xclient.serial = 0; | |
142 xev.xclient.send_event = True; | |
27616
213d9bc30b35
Use already "prefetched" atoms instead of calling XInternAtom each time.
reimar
parents:
27377
diff
changeset
|
143 xev.xclient.message_type = XA_NET_WM_STATE; |
12582 | 144 xev.xclient.window = vo_window; |
145 xev.xclient.format = 32; | |
146 xev.xclient.data.l[0] = action; | |
27616
213d9bc30b35
Use already "prefetched" atoms instead of calling XInternAtom each time.
reimar
parents:
27377
diff
changeset
|
147 xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN; |
12582 | 148 xev.xclient.data.l[2] = 0; |
149 xev.xclient.data.l[3] = 0; | |
150 xev.xclient.data.l[4] = 0; | |
151 | |
152 /* finally send that damn thing */ | |
153 if (!XSendEvent(mDisplay, DefaultRootWindow(mDisplay), False, | |
154 SubstructureRedirectMask | SubstructureNotifyMask, | |
155 &xev)) | |
156 { | |
157 mp_msg(MSGT_VO, MSGL_ERR, MSGTR_EwmhFullscreenStateFailed); | |
158 } | |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
159 } |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
160 } |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
161 |
12582 | 162 void vo_hidecursor(Display * disp, Window win) |
384 | 163 { |
12582 | 164 Cursor no_ptr; |
165 Pixmap bm_no; | |
166 XColor black, dummy; | |
167 Colormap colormap; | |
13828
b4ad5f0b550d
Fix erroneus extern declarations, fix wrong signedness of some vars
atmos4
parents:
13787
diff
changeset
|
168 static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
3954 | 169 |
12582 | 170 if (WinID == 0) |
21938 | 171 return; // do not hide if playing on the root window |
12582 | 172 |
173 colormap = DefaultColormap(disp, DefaultScreen(disp)); | |
14743
465c8617cbe5
We should not crash, only because we couldn't hide the cursor.
al
parents:
14742
diff
changeset
|
174 if ( !XAllocNamedColor(disp, colormap, "black", &black, &dummy) ) |
465c8617cbe5
We should not crash, only because we couldn't hide the cursor.
al
parents:
14742
diff
changeset
|
175 { |
465c8617cbe5
We should not crash, only because we couldn't hide the cursor.
al
parents:
14742
diff
changeset
|
176 return; // color alloc failed, give up |
465c8617cbe5
We should not crash, only because we couldn't hide the cursor.
al
parents:
14742
diff
changeset
|
177 } |
12582 | 178 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8); |
179 no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0); | |
180 XDefineCursor(disp, win, no_ptr); | |
181 XFreeCursor(disp, no_ptr); | |
182 if (bm_no != None) | |
183 XFreePixmap(disp, bm_no); | |
13953 | 184 XFreeColors(disp,colormap,&black.pixel,1,0); |
384 | 185 } |
186 | |
12582 | 187 void vo_showcursor(Display * disp, Window win) |
188 { | |
189 if (WinID == 0) | |
190 return; | |
191 XDefineCursor(disp, win, 0); | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
192 } |
384 | 193 |
12582 | 194 static int x11_errorhandler(Display * display, XErrorEvent * event) |
4742 | 195 { |
196 #define MSGLEN 60 | |
197 char msg[MSGLEN]; | |
12582 | 198 |
199 XGetErrorText(display, event->error_code, (char *) &msg, MSGLEN); | |
200 | |
201 mp_msg(MSGT_VO, MSGL_ERR, "X11 error: %s\n", msg); | |
202 | |
203 mp_msg(MSGT_VO, MSGL_V, | |
17366 | 204 "Type: %x, display: %p, resourceid: %lx, serial: %lx\n", |
12582 | 205 event->type, event->display, event->resourceid, event->serial); |
206 mp_msg(MSGT_VO, MSGL_V, | |
207 "Error code: %x, request code: %x, minor code: %x\n", | |
208 event->error_code, event->request_code, event->minor_code); | |
209 | |
21808
eaf6ed9cb5ab
Do not abort on X11 errors, most are not at all fatal.
reimar
parents:
21623
diff
changeset
|
210 // abort(); |
6095 | 211 //exit_player("X11 error"); |
23615 | 212 return 0; |
4742 | 213 #undef MSGLEN |
214 } | |
1732 | 215 |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
216 void fstype_help(void) |
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
217 { |
12582 | 218 mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18160
diff
changeset
|
219 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FULL_SCREEN_TYPES\n"); |
12582 | 220 |
221 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none", | |
222 "don't set fullscreen window layer"); | |
223 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer", | |
224 "use _WIN_LAYER hint with default layer"); | |
225 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer=<0..15>", | |
226 "use _WIN_LAYER hint with a given layer number"); | |
227 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "netwm", | |
228 "force NETWM style"); | |
229 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "above", | |
230 "use _NETWM_STATE_ABOVE hint if available"); | |
231 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "below", | |
232 "use _NETWM_STATE_BELOW hint if available"); | |
233 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "fullscreen", | |
234 "use _NETWM_STATE_FULLSCREEN hint if availale"); | |
235 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "stays_on_top", | |
236 "use _NETWM_STATE_STAYS_ON_TOP hint if available"); | |
237 mp_msg(MSGT_VO, MSGL_INFO, | |
238 "You can also negate the settings with simply putting '-' in the beginning"); | |
17727
096cb1dfb591
Make -xy help output consistent, output an empty line before and after.
diego
parents:
17566
diff
changeset
|
239 mp_msg(MSGT_VO, MSGL_INFO, "\n"); |
10695
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
240 } |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
241 |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
242 static void fstype_dump(int fstype) |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
243 { |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
244 if (fstype) |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
245 { |
12582 | 246 mp_msg(MSGT_VO, MSGL_V, "[x11] Current fstype setting honours"); |
247 if (fstype & vo_wm_LAYER) | |
248 mp_msg(MSGT_VO, MSGL_V, " LAYER"); | |
249 if (fstype & vo_wm_FULLSCREEN) | |
250 mp_msg(MSGT_VO, MSGL_V, " FULLSCREEN"); | |
251 if (fstype & vo_wm_STAYS_ON_TOP) | |
252 mp_msg(MSGT_VO, MSGL_V, " STAYS_ON_TOP"); | |
253 if (fstype & vo_wm_ABOVE) | |
254 mp_msg(MSGT_VO, MSGL_V, " ABOVE"); | |
255 if (fstype & vo_wm_BELOW) | |
256 mp_msg(MSGT_VO, MSGL_V, " BELOW"); | |
257 mp_msg(MSGT_VO, MSGL_V, " X atoms\n"); | |
258 } else | |
259 mp_msg(MSGT_VO, MSGL_V, | |
260 "[x11] Current fstype setting doesn't honour any X atoms\n"); | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
261 } |
12582 | 262 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
263 static int net_wm_support_state_test(Atom atom) |
8653 | 264 { |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
265 #define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } } |
12582 | 266 |
267 NET_WM_STATE_TEST(FULLSCREEN); | |
268 NET_WM_STATE_TEST(ABOVE); | |
269 NET_WM_STATE_TEST(STAYS_ON_TOP); | |
270 NET_WM_STATE_TEST(BELOW); | |
271 return 0; | |
8653 | 272 } |
273 | |
12582 | 274 static int x11_get_property(Atom type, Atom ** args, unsigned long *nitems) |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
275 { |
12582 | 276 int format; |
277 unsigned long bytesafter; | |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
278 |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26436
diff
changeset
|
279 return Success == |
12582 | 280 XGetWindowProperty(mDisplay, mRootWin, type, 0, 16384, False, |
281 AnyPropertyType, &type, &format, nitems, | |
282 &bytesafter, (unsigned char **) args) | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26436
diff
changeset
|
283 && *nitems > 0; |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
284 } |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
285 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
286 static int vo_wm_detect(void) |
6009 | 287 { |
12582 | 288 int i; |
289 int wm = 0; | |
290 unsigned long nitems; | |
291 Atom *args = NULL; | |
292 | |
293 if (WinID >= 0) | |
294 return 0; | |
295 | |
8669
fd398a0b4b3b
This time the patch is fixing much more that breaking :-)
arpi
parents:
8663
diff
changeset
|
296 // -- supports layers |
12582 | 297 if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems)) |
298 { | |
299 mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n"); | |
300 for (i = 0; i < nitems; i++) | |
301 { | |
302 if (args[i] == XA_WIN_LAYER) | |
303 { | |
304 wm |= vo_wm_LAYER; | |
305 metacity_hack |= 1; | |
306 } else | |
21938 | 307 /* metacity is the only window manager I know which reports |
308 * supporting only the _WIN_LAYER hint in _WIN_PROTOCOLS. | |
309 * (what's more support for it is broken) */ | |
12582 | 310 metacity_hack |= 2; |
311 } | |
312 XFree(args); | |
313 if (wm && (metacity_hack == 1)) | |
314 { | |
21938 | 315 // metacity claims to support layers, but it is not the truth :-) |
12582 | 316 wm ^= vo_wm_LAYER; |
317 mp_msg(MSGT_VO, MSGL_V, | |
318 "[x11] Using workaround for Metacity bugs.\n"); | |
319 } | |
320 } | |
6009 | 321 // --- netwm |
12582 | 322 if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems)) |
323 { | |
324 mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n"); | |
325 for (i = 0; i < nitems; i++) | |
326 wm |= net_wm_support_state_test(args[i]); | |
327 XFree(args); | |
328 } | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
329 |
12582 | 330 if (wm == 0) |
331 mp_msg(MSGT_VO, MSGL_V, "[x11] Unknown wm type...\n"); | |
332 return wm; | |
333 } | |
6009 | 334 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
335 static void init_atoms(void) |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
336 { |
12582 | 337 XA_INIT(_NET_SUPPORTED); |
338 XA_INIT(_NET_WM_STATE); | |
339 XA_INIT(_NET_WM_STATE_FULLSCREEN); | |
340 XA_INIT(_NET_WM_STATE_ABOVE); | |
341 XA_INIT(_NET_WM_STATE_STAYS_ON_TOP); | |
342 XA_INIT(_NET_WM_STATE_BELOW); | |
343 XA_INIT(_NET_WM_PID); | |
344 XA_INIT(_WIN_PROTOCOLS); | |
345 XA_INIT(_WIN_LAYER); | |
346 XA_INIT(_WIN_HINTS); | |
18149
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
347 XA_INIT(WM_PROTOCOLS); |
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
348 XA_INIT(WM_DELETE_WINDOW); |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
349 } |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
350 |
18116 | 351 void update_xinerama_info(void) { |
26436 | 352 int screen = xinerama_screen; |
353 xinerama_x = xinerama_y = 0; | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
354 #ifdef CONFIG_XINERAMA |
18116 | 355 if (screen >= -1 && XineramaIsActive(mDisplay)) |
356 { | |
357 XineramaScreenInfo *screens; | |
358 int num_screens; | |
359 | |
360 screens = XineramaQueryScreens(mDisplay, &num_screens); | |
26436 | 361 if (screen >= num_screens) |
362 screen = num_screens - 1; | |
363 if (screen == -1) { | |
364 int x = vo_dx + vo_dwidth / 2; | |
365 int y = vo_dy + vo_dheight / 2; | |
366 for (screen = num_screens - 1; screen > 0; screen--) { | |
367 int left = screens[screen].x_org; | |
368 int right = left + screens[screen].width; | |
369 int top = screens[screen].y_org; | |
370 int bottom = top + screens[screen].height; | |
371 if (left <= x && x <= right && top <= y && y <= bottom) | |
372 break; | |
373 } | |
26407 | 374 } |
18116 | 375 if (screen < 0) |
376 screen = 0; | |
377 vo_screenwidth = screens[screen].width; | |
378 vo_screenheight = screens[screen].height; | |
379 xinerama_x = screens[screen].x_org; | |
380 xinerama_y = screens[screen].y_org; | |
381 | |
382 XFree(screens); | |
383 } | |
18160
03bc3385a845
10l, aspect_save_screenres must be always called in update_xinerama_info.
reimar
parents:
18149
diff
changeset
|
384 #endif |
18116 | 385 aspect_save_screenres(vo_screenwidth, vo_screenheight); |
386 } | |
387 | |
12582 | 388 int vo_init(void) |
32 | 389 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
390 // int mScreen; |
12582 | 391 int depth, bpp; |
392 unsigned int mask; | |
393 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
394 // char * DisplayName = ":0.0"; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
395 // Display * mDisplay; |
12582 | 396 XImage *mXImage = NULL; |
397 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
398 // Window mRootWin; |
12582 | 399 XWindowAttributes attribs; |
400 char *dispName; | |
12972
c8900eba2cc7
now use vo_rootwin var to check for -rootwin switch
nplourde
parents:
12798
diff
changeset
|
401 |
c8900eba2cc7
now use vo_rootwin var to check for -rootwin switch
nplourde
parents:
12798
diff
changeset
|
402 if (vo_rootwin) |
21938 | 403 WinID = 0; // use root window |
32 | 404 |
12582 | 405 if (vo_depthonscreen) |
13935 | 406 { |
407 saver_off(mDisplay); | |
12582 | 408 return 1; // already called |
13935 | 409 } |
32 | 410 |
12582 | 411 XSetErrorHandler(x11_errorhandler); |
4812 | 412 |
413 #if 0 | |
12582 | 414 if (!mDisplayName) |
415 if (!(mDisplayName = getenv("DISPLAY"))) | |
416 mDisplayName = strdup(":0.0"); | |
4812 | 417 #else |
12582 | 418 dispName = XDisplayName(mDisplayName); |
4812 | 419 #endif |
420 | |
12582 | 421 mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName); |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
422 |
12582 | 423 mDisplay = XOpenDisplay(dispName); |
424 if (!mDisplay) | |
425 { | |
426 mp_msg(MSGT_VO, MSGL_ERR, | |
427 "vo: couldn't open the X11 display (%s)!\n", dispName); | |
428 return 0; | |
429 } | |
21938 | 430 mScreen = DefaultScreen(mDisplay); // screen ID |
431 mRootWin = RootWindow(mDisplay, mScreen); // root window ID | |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
432 |
12582 | 433 init_atoms(); |
434 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
435 #ifdef CONFIG_XF86VM |
12582 | 436 { |
437 int clock; | |
438 | |
439 XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline); | |
440 if (!vo_screenwidth) | |
441 vo_screenwidth = modeline.hdisplay; | |
442 if (!vo_screenheight) | |
443 vo_screenheight = modeline.vdisplay; | |
444 } | |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
445 #endif |
12582 | 446 { |
447 if (!vo_screenwidth) | |
448 vo_screenwidth = DisplayWidth(mDisplay, mScreen); | |
449 if (!vo_screenheight) | |
450 vo_screenheight = DisplayHeight(mDisplay, mScreen); | |
451 } | |
452 // get color depth (from root window, or the best visual): | |
453 XGetWindowAttributes(mDisplay, mRootWin, &attribs); | |
454 depth = attribs.depth; | |
1732 | 455 |
12582 | 456 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) |
457 { | |
458 Visual *visual; | |
459 | |
460 depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual); | |
461 if (depth != -1) | |
462 mXImage = XCreateImage(mDisplay, visual, depth, ZPixmap, | |
463 0, NULL, 1, 1, 8, 1); | |
464 } else | |
465 mXImage = | |
466 XGetImage(mDisplay, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap); | |
1732 | 467 |
12582 | 468 vo_depthonscreen = depth; // display depth on screen |
1732 | 469 |
12582 | 470 // get bits/pixel from XImage structure: |
471 if (mXImage == NULL) | |
472 { | |
473 mask = 0; | |
474 } else | |
475 { | |
476 /* | |
477 * for the depth==24 case, the XImage structures might use | |
478 * 24 or 32 bits of data per pixel. The global variable | |
479 * vo_depthonscreen stores the amount of data per pixel in the | |
480 * XImage structure! | |
481 * | |
482 * Maybe we should rename vo_depthonscreen to (or add) vo_bpp? | |
483 */ | |
484 bpp = mXImage->bits_per_pixel; | |
485 if ((vo_depthonscreen + 7) / 8 != (bpp + 7) / 8) | |
486 vo_depthonscreen = bpp; // by A'rpi | |
487 mask = | |
488 mXImage->red_mask | mXImage->green_mask | mXImage->blue_mask; | |
489 mp_msg(MSGT_VO, MSGL_V, | |
490 "vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", mask, | |
491 mXImage->red_mask, mXImage->green_mask, mXImage->blue_mask); | |
492 XDestroyImage(mXImage); | |
493 } | |
494 if (((vo_depthonscreen + 7) / 8) == 2) | |
495 { | |
496 if (mask == 0x7FFF) | |
497 vo_depthonscreen = 15; | |
498 else if (mask == 0xFFFF) | |
499 vo_depthonscreen = 16; | |
500 } | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
501 // XCloseDisplay( mDisplay ); |
1447
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
502 /* slightly improved local display detection AST */ |
12582 | 503 if (strncmp(dispName, "unix:", 5) == 0) |
504 dispName += 4; | |
505 else if (strncmp(dispName, "localhost:", 10) == 0) | |
506 dispName += 9; | |
507 if (*dispName == ':' && atoi(dispName + 1) < 10) | |
508 mLocalDisplay = 1; | |
509 else | |
510 mLocalDisplay = 0; | |
16301 | 511 mp_msg(MSGT_VO, MSGL_V, |
12582 | 512 "vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n", |
513 vo_screenwidth, vo_screenheight, depth, vo_depthonscreen, | |
514 dispName, mLocalDisplay ? "local" : "remote"); | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
515 |
12582 | 516 vo_wm_type = vo_wm_detect(); |
517 | |
518 vo_fs_type = vo_x11_get_fs_type(vo_wm_type); | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
519 |
12582 | 520 fstype_dump(vo_fs_type); |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
521 |
12582 | 522 saver_off(mDisplay); |
523 return 1; | |
32 | 524 } |
525 | |
12582 | 526 void vo_uninit(void) |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
527 { |
12582 | 528 if (!mDisplay) |
529 { | |
530 mp_msg(MSGT_VO, MSGL_V, | |
25962 | 531 "vo: x11 uninit called but X11 not initialized..\n"); |
12582 | 532 return; |
533 } | |
6077 | 534 // if( !vo_depthonscreen ) return; |
12582 | 535 mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n"); |
536 XSetErrorHandler(NULL); | |
537 XCloseDisplay(mDisplay); | |
538 vo_depthonscreen = 0; | |
539 mDisplay = NULL; | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
540 } |
4436 | 541 |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
542 #include "osdep/keycodes.h" |
32 | 543 #include "wskeys.h" |
544 | |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
545 #ifdef XF86XK_AudioPause |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
546 static const struct keymap keysym_map[] = { |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
547 {XF86XK_MenuKB, KEY_MENU}, |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
548 {XF86XK_AudioPlay, KEY_PLAY}, {XF86XK_AudioPause, KEY_PAUSE}, {XF86XK_AudioStop, KEY_STOP}, |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
549 {XF86XK_AudioPrev, KEY_PREV}, {XF86XK_AudioNext, KEY_NEXT}, |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
550 {XF86XK_AudioMute, KEY_MUTE}, {XF86XK_AudioLowerVolume, KEY_VOLUME_DOWN}, {XF86XK_AudioRaiseVolume, KEY_VOLUME_UP}, |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
551 {0, 0} |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
552 }; |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
553 |
18950 | 554 static void vo_x11_putkey_ext(int keysym) |
12582 | 555 { |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
556 int mpkey = lookup_keymap_table(keysym_map, keysym); |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
557 if (mpkey) |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
558 mplayer_put_key(mpkey); |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
559 } |
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
560 #endif |
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
561 |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
562 static const struct keymap keymap[] = { |
28135 | 563 // special keys |
564 {wsEscape, KEY_ESC}, {wsBackSpace, KEY_BS}, {wsTab, KEY_TAB}, {wsEnter, KEY_ENTER}, | |
565 | |
566 // cursor keys | |
567 {wsLeft, KEY_LEFT}, {wsRight, KEY_RIGHT}, {wsUp, KEY_UP}, {wsDown, KEY_DOWN}, | |
568 | |
569 // navigation block | |
570 {wsInsert, KEY_INSERT}, {wsDelete, KEY_DELETE}, {wsHome, KEY_HOME}, {wsEnd, KEY_END}, | |
571 {wsPageUp, KEY_PAGE_UP}, {wsPageDown, KEY_PAGE_DOWN}, | |
572 | |
573 // F-keys | |
574 {wsF1, KEY_F+1}, {wsF2, KEY_F+2}, {wsF3, KEY_F+3}, {wsF4, KEY_F+4}, | |
575 {wsF5, KEY_F+5}, {wsF6, KEY_F+6}, {wsF7, KEY_F+7}, {wsF8, KEY_F+8}, | |
576 {wsF9, KEY_F+9}, {wsF10, KEY_F+10}, {wsF11, KEY_F+11}, {wsF12, KEY_F+12}, | |
577 | |
578 // numpad independent of numlock | |
579 {wsGrayMinus, '-'}, {wsGrayPlus, '+'}, {wsGrayMul, '*'}, {wsGrayDiv, '/'}, | |
580 {wsGrayEnter, KEY_KPENTER}, | |
581 | |
582 // numpad with numlock | |
583 {wsGray0, KEY_KP0}, {wsGray1, KEY_KP1}, {wsGray2, KEY_KP2}, | |
584 {wsGray3, KEY_KP3}, {wsGray4, KEY_KP4}, {wsGray5, KEY_KP5}, | |
585 {wsGray6, KEY_KP6}, {wsGray7, KEY_KP7}, {wsGray8, KEY_KP8}, | |
586 {wsGray9, KEY_KP9}, {wsGrayDecimal, KEY_KPDEC}, | |
587 | |
588 // numpad without numlock | |
589 {wsGrayInsert, KEY_KPINS}, {wsGrayEnd, KEY_KP1}, {wsGrayDown, KEY_KP2}, | |
590 {wsGrayPgDn, KEY_KP3}, {wsGrayLeft, KEY_KP4}, {wsGray5Dup, KEY_KP5}, | |
591 {wsGrayRight, KEY_KP6}, {wsGrayHome, KEY_KP7}, {wsGrayUp, KEY_KP8}, | |
592 {wsGrayPgUp, KEY_KP9}, {wsGrayDelete, KEY_KPDEL}, | |
593 | |
594 {0, 0} | |
595 }; | |
596 | |
12582 | 597 void vo_x11_putkey(int key) |
598 { | |
28133
272238675b78
Simplify handling of X11 key events that are just passed through.
reimar
parents:
28063
diff
changeset
|
599 static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]"; |
28135 | 600 int mpkey = 0; |
28133
272238675b78
Simplify handling of X11 key events that are just passed through.
reimar
parents:
28063
diff
changeset
|
601 if ((key >= 'a' && key <= 'z') || |
272238675b78
Simplify handling of X11 key events that are just passed through.
reimar
parents:
28063
diff
changeset
|
602 (key >= 'A' && key <= 'Z') || |
272238675b78
Simplify handling of X11 key events that are just passed through.
reimar
parents:
28063
diff
changeset
|
603 (key >= '0' && key <= '9') || |
272238675b78
Simplify handling of X11 key events that are just passed through.
reimar
parents:
28063
diff
changeset
|
604 (key > 0 && key < 256 && strchr(passthrough_keys, key))) |
28135 | 605 mpkey = key; |
28133
272238675b78
Simplify handling of X11 key events that are just passed through.
reimar
parents:
28063
diff
changeset
|
606 |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28135
diff
changeset
|
607 if (!mpkey) |
28140
49dadf7bd73a
100l, forgot an assignment, broke special keys handling for X11-based vos.
reimar
parents:
28137
diff
changeset
|
608 mpkey = lookup_keymap_table(keymap, key); |
369 | 609 |
28135 | 610 if (mpkey) |
611 mplayer_put_key(mpkey); | |
32 | 612 } |
613 | |
614 | |
615 // ----- Motif header: ------- | |
616 | |
1236 | 617 #define MWM_HINTS_FUNCTIONS (1L << 0) |
618 #define MWM_HINTS_DECORATIONS (1L << 1) | |
619 #define MWM_HINTS_INPUT_MODE (1L << 2) | |
620 #define MWM_HINTS_STATUS (1L << 3) | |
621 | |
622 #define MWM_FUNC_ALL (1L << 0) | |
623 #define MWM_FUNC_RESIZE (1L << 1) | |
624 #define MWM_FUNC_MOVE (1L << 2) | |
625 #define MWM_FUNC_MINIMIZE (1L << 3) | |
626 #define MWM_FUNC_MAXIMIZE (1L << 4) | |
627 #define MWM_FUNC_CLOSE (1L << 5) | |
628 | |
629 #define MWM_DECOR_ALL (1L << 0) | |
630 #define MWM_DECOR_BORDER (1L << 1) | |
631 #define MWM_DECOR_RESIZEH (1L << 2) | |
632 #define MWM_DECOR_TITLE (1L << 3) | |
633 #define MWM_DECOR_MENU (1L << 4) | |
634 #define MWM_DECOR_MINIMIZE (1L << 5) | |
635 #define MWM_DECOR_MAXIMIZE (1L << 6) | |
636 | |
637 #define MWM_INPUT_MODELESS 0 | |
638 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 | |
639 #define MWM_INPUT_SYSTEM_MODAL 2 | |
640 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 | |
641 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL | |
642 | |
643 #define MWM_TEAROFF_WINDOW (1L<<0) | |
32 | 644 |
645 typedef struct | |
646 { | |
12582 | 647 long flags; |
648 long functions; | |
649 long decorations; | |
650 long input_mode; | |
651 long state; | |
32 | 652 } MotifWmHints; |
653 | |
12582 | 654 static MotifWmHints vo_MotifWmHints; |
655 static Atom vo_MotifHints = None; | |
32 | 656 |
12582 | 657 void vo_x11_decoration(Display * vo_Display, Window w, int d) |
32 | 658 { |
12582 | 659 static unsigned int olddecor = MWM_DECOR_ALL; |
660 static unsigned int oldfuncs = | |
661 MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | | |
662 MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; | |
663 Atom mtype; | |
664 int mformat; | |
665 unsigned long mn, mb; | |
666 | |
667 if (!WinID) | |
668 return; | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
669 |
12582 | 670 if (vo_fsmode & 8) |
671 { | |
672 XSetTransientForHint(vo_Display, w, | |
673 RootWindow(vo_Display, mScreen)); | |
674 } | |
675 | |
676 vo_MotifHints = XInternAtom(vo_Display, "_MOTIF_WM_HINTS", 0); | |
677 if (vo_MotifHints != None) | |
678 { | |
679 if (!d) | |
680 { | |
681 MotifWmHints *mhints = NULL; | |
1415 | 682 |
12582 | 683 XGetWindowProperty(vo_Display, w, vo_MotifHints, 0, 20, False, |
684 vo_MotifHints, &mtype, &mformat, &mn, | |
685 &mb, (unsigned char **) &mhints); | |
686 if (mhints) | |
687 { | |
688 if (mhints->flags & MWM_HINTS_DECORATIONS) | |
689 olddecor = mhints->decorations; | |
690 if (mhints->flags & MWM_HINTS_FUNCTIONS) | |
691 oldfuncs = mhints->functions; | |
692 XFree(mhints); | |
693 } | |
694 } | |
12096 | 695 |
12582 | 696 memset(&vo_MotifWmHints, 0, sizeof(MotifWmHints)); |
697 vo_MotifWmHints.flags = | |
698 MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; | |
699 if (d) | |
700 { | |
701 vo_MotifWmHints.functions = oldfuncs; | |
702 d = olddecor; | |
703 } | |
4993 | 704 #if 0 |
12582 | 705 vo_MotifWmHints.decorations = |
706 d | ((vo_fsmode & 2) ? 0 : MWM_DECOR_MENU); | |
4993 | 707 #else |
12582 | 708 vo_MotifWmHints.decorations = |
709 d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0); | |
4993 | 710 #endif |
12582 | 711 XChangeProperty(vo_Display, w, vo_MotifHints, vo_MotifHints, 32, |
712 PropModeReplace, | |
713 (unsigned char *) &vo_MotifWmHints, | |
714 (vo_fsmode & 4) ? 4 : 5); | |
715 } | |
32 | 716 } |
717 | |
12582 | 718 void vo_x11_classhint(Display * display, Window window, char *name) |
719 { | |
720 XClassHint wmClass; | |
721 pid_t pid = getpid(); | |
722 | |
723 wmClass.res_name = name; | |
724 wmClass.res_class = "MPlayer"; | |
725 XSetClassHint(display, window, &wmClass); | |
726 XChangeProperty(display, window, XA_NET_WM_PID, XA_CARDINAL, 32, | |
727 PropModeReplace, (unsigned char *) &pid, 1); | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
728 } |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
729 |
12582 | 730 Window vo_window = None; |
731 GC vo_gc = NULL; | |
732 GC f_gc = NULL; | |
4993 | 733 XSizeHints vo_hint; |
4795 | 734 |
27343 | 735 #ifdef CONFIG_GUI |
12582 | 736 void vo_setwindow(Window w, GC g) |
737 { | |
738 vo_window = w; | |
739 vo_gc = g; | |
740 } | |
723 | 741 #endif |
742 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17366
diff
changeset
|
743 void vo_x11_uninit(void) |
4437 | 744 { |
7111 | 745 saver_on(mDisplay); |
12582 | 746 if (vo_window != None) |
747 vo_showcursor(mDisplay, vo_window); | |
4742 | 748 |
12582 | 749 if (f_gc) |
750 { | |
751 XFreeGC(mDisplay, f_gc); | |
752 f_gc = NULL; | |
753 } | |
27343 | 754 #ifdef CONFIG_GUI |
21938 | 755 /* destroy window only if it's not controlled by the GUI */ |
12582 | 756 if (!use_gui) |
4437 | 757 #endif |
758 { | |
12582 | 759 if (vo_gc) |
760 { | |
761 XSetBackground(mDisplay, vo_gc, 0); | |
762 XFreeGC(mDisplay, vo_gc); | |
763 vo_gc = NULL; | |
764 } | |
765 if (vo_window != None) | |
766 { | |
767 XClearWindow(mDisplay, vo_window); | |
768 if (WinID < 0) | |
769 { | |
770 XEvent xev; | |
771 | |
772 XUnmapWindow(mDisplay, vo_window); | |
773 XDestroyWindow(mDisplay, vo_window); | |
774 do | |
775 { | |
776 XNextEvent(mDisplay, &xev); | |
777 } | |
778 while (xev.type != DestroyNotify | |
779 || xev.xdestroywindow.event != vo_window); | |
780 } | |
781 vo_window = None; | |
782 } | |
783 vo_fs = 0; | |
784 vo_old_width = vo_old_height = 0; | |
4437 | 785 } |
786 } | |
787 | |
18287
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
788 static unsigned int mouse_timer; |
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
789 static int mouse_waiting_hide; |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5538
diff
changeset
|
790 |
12582 | 791 int vo_x11_check_events(Display * mydisplay) |
792 { | |
793 int ret = 0; | |
794 XEvent Event; | |
795 char buf[100]; | |
796 KeySym keySym; | |
797 static XComposeStatus stat; | |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5538
diff
changeset
|
798 |
32 | 799 // unsigned long vo_KeyTable[512]; |
800 | |
18287
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
801 if ((vo_mouse_autohide) && mouse_waiting_hide && |
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
802 (GetTimerMS() - mouse_timer >= 1000)) { |
12582 | 803 vo_hidecursor(mydisplay, vo_window); |
18287
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
804 mouse_waiting_hide = 0; |
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
805 } |
6095 | 806 |
12582 | 807 while (XPending(mydisplay)) |
808 { | |
809 XNextEvent(mydisplay, &Event); | |
27343 | 810 #ifdef CONFIG_GUI |
12582 | 811 if (use_gui) |
812 { | |
813 guiGetEvent(0, (char *) &Event); | |
814 if (vo_window != Event.xany.window) | |
815 continue; | |
816 } | |
817 #endif | |
6095 | 818 // printf("\rEvent.type=%X \n",Event.type); |
12582 | 819 switch (Event.type) |
820 { | |
821 case Expose: | |
822 ret |= VO_EVENT_EXPOSE; | |
823 break; | |
824 case ConfigureNotify: | |
825 // if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break; | |
826 // if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break; | |
827 if (vo_window == None) | |
828 break; | |
27885
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
829 vo_x11_update_geometry(); |
12582 | 830 ret |= VO_EVENT_RESIZE; |
831 break; | |
832 case KeyPress: | |
833 { | |
834 int key; | |
835 | |
27343 | 836 #ifdef CONFIG_GUI |
14001 | 837 if ( use_gui ) { break; } |
838 #endif | |
839 | |
12582 | 840 XLookupString(&Event.xkey, buf, sizeof(buf), &keySym, |
841 &stat); | |
842 #ifdef XF86XK_AudioPause | |
843 vo_x11_putkey_ext(keySym); | |
844 #endif | |
845 key = | |
846 ((keySym & 0xff00) != | |
847 0 ? ((keySym & 0x00ff) + 256) : (keySym)); | |
848 vo_x11_putkey(key); | |
849 ret |= VO_EVENT_KEYPRESS; | |
850 } | |
851 break; | |
852 case MotionNotify: | |
19850
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
853 if(enable_mouse_movements) |
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
854 { |
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
855 char cmd_str[40]; |
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
856 sprintf(cmd_str,"set_mouse_pos %i %i",Event.xmotion.x, Event.xmotion.y); |
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
857 mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); |
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
858 } |
4919b3ce8d5e
report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me
nicodvb
parents:
18950
diff
changeset
|
859 |
12582 | 860 if (vo_mouse_autohide) |
861 { | |
862 vo_showcursor(mydisplay, vo_window); | |
18287
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
863 mouse_waiting_hide = 1; |
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
864 mouse_timer = GetTimerMS(); |
12582 | 865 } |
866 break; | |
867 case ButtonPress: | |
868 if (vo_mouse_autohide) | |
869 { | |
870 vo_showcursor(mydisplay, vo_window); | |
18287
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
871 mouse_waiting_hide = 1; |
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
872 mouse_timer = GetTimerMS(); |
12582 | 873 } |
27343 | 874 #ifdef CONFIG_GUI |
21938 | 875 // Ignore mouse button 1-3 under GUI. |
12582 | 876 if (use_gui && (Event.xbutton.button >= 1) |
877 && (Event.xbutton.button <= 3)) | |
878 break; | |
879 #endif | |
880 mplayer_put_key((MOUSE_BTN0 + Event.xbutton.button - | |
881 1) | MP_KEY_DOWN); | |
882 break; | |
883 case ButtonRelease: | |
884 if (vo_mouse_autohide) | |
885 { | |
886 vo_showcursor(mydisplay, vo_window); | |
18287
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
887 mouse_waiting_hide = 1; |
292337d09af2
Remove updating of vo_mouse_timer_const from the main loop and also
uau
parents:
18237
diff
changeset
|
888 mouse_timer = GetTimerMS(); |
12582 | 889 } |
27343 | 890 #ifdef CONFIG_GUI |
21938 | 891 // Ignore mouse button 1-3 under GUI. |
12582 | 892 if (use_gui && (Event.xbutton.button >= 1) |
893 && (Event.xbutton.button <= 3)) | |
894 break; | |
895 #endif | |
896 mplayer_put_key(MOUSE_BTN0 + Event.xbutton.button - 1); | |
897 break; | |
898 case PropertyNotify: | |
899 { | |
900 char *name = | |
901 XGetAtomName(mydisplay, Event.xproperty.atom); | |
902 | |
903 if (!name) | |
904 break; | |
905 | |
6046 | 906 // fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",vo_window,name,Event.xproperty.atom ); |
12582 | 907 |
908 XFree(name); | |
909 } | |
910 break; | |
911 case MapNotify: | |
912 vo_hint.win_gravity = old_gravity; | |
913 XSetWMNormalHints(mDisplay, vo_window, &vo_hint); | |
914 vo_fs_flip = 0; | |
915 break; | |
18149
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
916 case ClientMessage: |
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
917 if (Event.xclient.message_type == XAWM_PROTOCOLS && |
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
918 Event.xclient.data.l[0] == XAWM_DELETE_WINDOW) |
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
919 mplayer_put_key(KEY_CLOSE_WIN); |
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
920 break; |
12582 | 921 } |
922 } | |
923 return ret; | |
32 | 924 } |
925 | |
13843 | 926 /** |
927 * \brief sets the size and position of the non-fullscreen window. | |
928 */ | |
929 void vo_x11_nofs_sizepos(int x, int y, int width, int height) | |
930 { | |
24312
716b7751e7ad
Make sure aspect hint is adjusted on aspect change
reimar
parents:
24311
diff
changeset
|
931 vo_x11_sizehint(x, y, width, height, 0); |
13843 | 932 if (vo_fs) { |
933 vo_old_x = x; | |
934 vo_old_y = y; | |
935 vo_old_width = width; | |
936 vo_old_height = height; | |
937 } | |
938 else | |
13871 | 939 { |
940 vo_dwidth = width; | |
941 vo_dheight = height; | |
13843 | 942 XMoveResizeWindow(mDisplay, vo_window, x, y, width, height); |
13871 | 943 } |
13843 | 944 } |
945 | |
12582 | 946 void vo_x11_sizehint(int x, int y, int width, int height, int max) |
4993 | 947 { |
24311
0ff0253c8e00
Cosmetics: set vo_hint.flags at more consistent places (directly before
reimar
parents:
23875
diff
changeset
|
948 vo_hint.flags = 0; |
12582 | 949 if (vo_keepaspect) |
950 { | |
951 vo_hint.flags |= PAspect; | |
952 vo_hint.min_aspect.x = width; | |
953 vo_hint.min_aspect.y = height; | |
954 vo_hint.max_aspect.x = width; | |
955 vo_hint.max_aspect.y = height; | |
956 } | |
8692
604f0cde816c
X11 window aspect patch by Arnaud Boulan <boulan@iie.cnam.fr>
attila
parents:
8676
diff
changeset
|
957 |
24311
0ff0253c8e00
Cosmetics: set vo_hint.flags at more consistent places (directly before
reimar
parents:
23875
diff
changeset
|
958 vo_hint.flags |= PPosition | PSize; |
12582 | 959 vo_hint.x = x; |
960 vo_hint.y = y; | |
961 vo_hint.width = width; | |
962 vo_hint.height = height; | |
963 if (max) | |
964 { | |
24311
0ff0253c8e00
Cosmetics: set vo_hint.flags at more consistent places (directly before
reimar
parents:
23875
diff
changeset
|
965 vo_hint.flags |= PMaxSize; |
12582 | 966 vo_hint.max_width = width; |
967 vo_hint.max_height = height; | |
968 } else | |
969 { | |
970 vo_hint.max_width = 0; | |
971 vo_hint.max_height = 0; | |
972 } | |
11995 | 973 |
21938 | 974 // Set minimum height/width to 4 to avoid off-by-one errors |
975 // and because mga_vid requires a minimal size of 4 pixels. | |
24311
0ff0253c8e00
Cosmetics: set vo_hint.flags at more consistent places (directly before
reimar
parents:
23875
diff
changeset
|
976 vo_hint.flags |= PMinSize; |
12582 | 977 vo_hint.min_width = vo_hint.min_height = 4; |
11995 | 978 |
28063
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
979 // Set the base size. A window manager might display the window |
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
980 // size to the user relative to this. |
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
981 // Setting these to width/height might be nice, but e.g. fluxbox can't handle it. |
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
982 vo_hint.flags |= PBaseSize; |
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
983 vo_hint.base_width = 0 /*width*/; |
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
984 vo_hint.base_height = 0 /*height*/; |
a318969a4f45
Set the base size window manager hint, otherwise some subtract the minimum
reimar
parents:
27927
diff
changeset
|
985 |
24311
0ff0253c8e00
Cosmetics: set vo_hint.flags at more consistent places (directly before
reimar
parents:
23875
diff
changeset
|
986 vo_hint.flags |= PWinGravity; |
12582 | 987 vo_hint.win_gravity = StaticGravity; |
988 XSetWMNormalHints(mDisplay, vo_window, &vo_hint); | |
4993 | 989 } |
990 | |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
991 static int vo_x11_get_gnome_layer(Display * mDisplay, Window win) |
8866 | 992 { |
12582 | 993 Atom type; |
994 int format; | |
995 unsigned long nitems; | |
996 unsigned long bytesafter; | |
997 unsigned short *args = NULL; | |
8866 | 998 |
12582 | 999 if (XGetWindowProperty(mDisplay, win, XA_WIN_LAYER, 0, 16384, |
1000 False, AnyPropertyType, &type, &format, &nitems, | |
1001 &bytesafter, | |
1002 (unsigned char **) &args) == Success | |
1003 && nitems > 0 && args) | |
1004 { | |
1005 mp_msg(MSGT_VO, MSGL_V, "[x11] original window layer is %d.\n", | |
1006 *args); | |
1007 return *args; | |
1008 } | |
1009 return WIN_LAYER_NORMAL; | |
8866 | 1010 } |
1011 | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1012 // |
12582 | 1013 Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot, |
1014 Visual * vis, int x, int y, | |
1015 unsigned int width, unsigned int height, | |
1016 int depth, Colormap col_map) | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1017 { |
27815
f92271dc5f17
Remove X11 backing store: this is now a useless flag.
ben
parents:
27713
diff
changeset
|
1018 unsigned long xswamask = CWBorderPixel; |
12582 | 1019 XSetWindowAttributes xswa; |
1020 Window ret_win; | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1021 |
12582 | 1022 if (col_map != CopyFromParent) |
1023 { | |
1024 xswa.colormap = col_map; | |
1025 xswamask |= CWColormap; | |
1026 } | |
1027 xswa.background_pixel = 0; | |
1028 xswa.border_pixel = 0; | |
27815
f92271dc5f17
Remove X11 backing store: this is now a useless flag.
ben
parents:
27713
diff
changeset
|
1029 xswa.backing_store = NotUseful; |
12582 | 1030 xswa.bit_gravity = StaticGravity; |
1031 | |
1032 ret_win = | |
1033 XCreateWindow(mDisplay, mRootWin, x, y, width, height, 0, depth, | |
1034 CopyFromParent, vis, xswamask, &xswa); | |
18149
163fe5c2577d
Register for window-manager delete window events and quit MPlayer.
reimar
parents:
18116
diff
changeset
|
1035 XSetWMProtocols(mDisplay, ret_win, &XAWM_DELETE_WINDOW, 1); |
12582 | 1036 if (!f_gc) |
1037 f_gc = XCreateGC(mDisplay, ret_win, 0, 0); | |
1038 XSetForeground(mDisplay, f_gc, 0); | |
1039 | |
1040 return ret_win; | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1041 } |
12582 | 1042 |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1043 /** |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1044 * \brief create and setup a window suitable for display |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1045 * \param vis Visual to use for creating the window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1046 * \param x x position of window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1047 * \param y y position of window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1048 * \param width width of window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1049 * \param height height of window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1050 * \param flags flags for window creation. |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1051 * Only VOFLAG_FULLSCREEN is supported so far. |
23823
513293585949
document "default" behaviour if CopyFromParent is passed as colormap
attila
parents:
23660
diff
changeset
|
1052 * \param col_map Colourmap for window or CopyFromParent if a specific colormap isn't needed |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1053 * \param classname name to use for the classhint |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1054 * \param title title for the window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1055 * |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1056 * This also does the grunt-work like setting Window Manager hints etc. |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1057 * If vo_window is already set it just moves and resizes it. |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1058 */ |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1059 void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y, |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1060 unsigned int width, unsigned int height, int flags, |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1061 Colormap col_map, |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1062 const char *classname, const char *title) |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1063 { |
27927
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1064 XGCValues xgcv; |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1065 if (WinID >= 0) { |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1066 vo_window = WinID ? (Window)WinID : mRootWin; |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1067 if (col_map != CopyFromParent) { |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1068 unsigned long xswamask = CWColormap; |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1069 XSetWindowAttributes xswa; |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1070 xswa.colormap = col_map; |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1071 XUnmapWindow(mDisplay, vo_window); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1072 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1073 XMapWindow(mDisplay, vo_window); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1074 } |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1075 if (WinID) vo_x11_update_geometry(); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1076 vo_x11_selectinput_witherr(mDisplay, vo_window, |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1077 StructureNotifyMask | KeyPressMask | PointerMotionMask | |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1078 ButtonPressMask | ButtonReleaseMask | ExposureMask); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1079 goto final; |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1080 } |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1081 if (vo_window == None) { |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1082 XSizeHints hint; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1083 XEvent xev; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1084 vo_fs = 0; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1085 vo_dwidth = width; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1086 vo_dheight = height; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1087 vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vis->visual, |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1088 x, y, width, height, vis->depth, col_map); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1089 vo_x11_classhint(mDisplay, vo_window, classname); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1090 XStoreName(mDisplay, vo_window, title); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1091 vo_hidecursor(mDisplay, vo_window); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1092 XSelectInput(mDisplay, vo_window, StructureNotifyMask); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1093 hint.x = x; hint.y = y; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1094 hint.width = width; hint.height = height; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1095 hint.flags = PPosition | PSize; |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1096 XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1097 vo_x11_sizehint(x, y, width, height, 0); |
27304 | 1098 if (!vo_border) vo_x11_decoration(mDisplay, vo_window, 0); |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1099 // map window |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1100 XMapWindow(mDisplay, vo_window); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1101 XClearWindow(mDisplay, vo_window); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1102 // wait for map |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1103 do { |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1104 XNextEvent(mDisplay, &xev); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1105 } while (xev.type != MapNotify || xev.xmap.event != vo_window); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1106 XSelectInput(mDisplay, vo_window, NoEventMask); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1107 XSync(mDisplay, False); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1108 vo_x11_selectinput_witherr(mDisplay, vo_window, |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1109 StructureNotifyMask | KeyPressMask | PointerMotionMask | |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1110 ButtonPressMask | ButtonReleaseMask | ExposureMask); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1111 } |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1112 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1113 vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1114 if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN)) |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1115 vo_x11_fullscreen(); |
27927
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1116 final: |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1117 if (vo_gc != None) |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1118 XFreeGC(mDisplay, vo_gc); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1119 vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1120 XSync(mDisplay, False); |
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27893
diff
changeset
|
1121 vo_mouse_autohide = 1; |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23615
diff
changeset
|
1122 } |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1123 |
12582 | 1124 void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window, |
1125 int img_width, int img_height, int use_fs) | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1126 { |
12582 | 1127 int u_dheight, u_dwidth, left_ov, left_ov2; |
10765
c8fb7e2690a3
10000l. Never ever use such foolish GCC 3.x extensionscvs diff -u x11_common.c x11_common.h |more
alex
parents:
10757
diff
changeset
|
1128 |
12582 | 1129 if (!f_gc) |
1130 return; | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1131 |
12582 | 1132 u_dheight = use_fs ? vo_screenheight : vo_dheight; |
1133 u_dwidth = use_fs ? vo_screenwidth : vo_dwidth; | |
1134 if ((u_dheight <= img_height) && (u_dwidth <= img_width)) | |
1135 return; | |
10765
c8fb7e2690a3
10000l. Never ever use such foolish GCC 3.x extensionscvs diff -u x11_common.c x11_common.h |more
alex
parents:
10757
diff
changeset
|
1136 |
12582 | 1137 left_ov = (u_dheight - img_height) / 2; |
1138 left_ov2 = (u_dwidth - img_width) / 2; | |
1139 | |
1140 XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, u_dwidth, left_ov); | |
1141 XFillRectangle(mDisplay, vo_window, f_gc, 0, u_dheight - left_ov - 1, | |
1142 u_dwidth, left_ov + 1); | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1143 |
12582 | 1144 if (u_dwidth > img_width) |
1145 { | |
1146 XFillRectangle(mDisplay, vo_window, f_gc, 0, left_ov, left_ov2, | |
1147 img_height); | |
1148 XFillRectangle(mDisplay, vo_window, f_gc, u_dwidth - left_ov2 - 1, | |
23660
3ab096c77b9e
Fix vo_x11_clearwindow_part: x position is one less to avoid not clearing
reimar
parents:
23655
diff
changeset
|
1149 left_ov, left_ov2 + 1, img_height); |
12582 | 1150 } |
1151 | |
1152 XFlush(mDisplay); | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1153 } |
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1154 |
12582 | 1155 void vo_x11_clearwindow(Display * mDisplay, Window vo_window) |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1156 { |
12582 | 1157 if (!f_gc) |
1158 return; | |
1159 XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, vo_screenwidth, | |
1160 vo_screenheight); | |
1161 // | |
1162 XFlush(mDisplay); | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1163 } |
12582 | 1164 |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1165 |
12582 | 1166 void vo_x11_setlayer(Display * mDisplay, Window vo_window, int layer) |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
1167 { |
12582 | 1168 if (WinID >= 0) |
1169 return; | |
8864 | 1170 |
12582 | 1171 if (vo_fs_type & vo_wm_LAYER) |
1172 { | |
1173 XClientMessageEvent xev; | |
1174 | |
1175 if (!orig_layer) | |
1176 orig_layer = vo_x11_get_gnome_layer(mDisplay, vo_window); | |
8866 | 1177 |
12582 | 1178 memset(&xev, 0, sizeof(xev)); |
1179 xev.type = ClientMessage; | |
1180 xev.display = mDisplay; | |
1181 xev.window = vo_window; | |
1182 xev.message_type = XA_WIN_LAYER; | |
1183 xev.format = 32; | |
1184 xev.data.l[0] = layer ? fs_layer : orig_layer; // if not fullscreen, stay on default layer | |
1185 xev.data.l[1] = CurrentTime; | |
1186 mp_msg(MSGT_VO, MSGL_V, | |
17366 | 1187 "[x11] Layered style stay on top (layer %ld).\n", |
12582 | 1188 xev.data.l[0]); |
1189 XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask, | |
1190 (XEvent *) & xev); | |
1191 } else if (vo_fs_type & vo_wm_NETWM) | |
1192 { | |
1193 XClientMessageEvent xev; | |
1194 char *state; | |
8645 | 1195 |
12582 | 1196 memset(&xev, 0, sizeof(xev)); |
1197 xev.type = ClientMessage; | |
1198 xev.message_type = XA_NET_WM_STATE; | |
1199 xev.display = mDisplay; | |
1200 xev.window = vo_window; | |
1201 xev.format = 32; | |
1202 xev.data.l[0] = layer; | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1203 |
12582 | 1204 if (vo_fs_type & vo_wm_STAYS_ON_TOP) |
1205 xev.data.l[1] = XA_NET_WM_STATE_STAYS_ON_TOP; | |
1206 else if (vo_fs_type & vo_wm_ABOVE) | |
1207 xev.data.l[1] = XA_NET_WM_STATE_ABOVE; | |
1208 else if (vo_fs_type & vo_wm_FULLSCREEN) | |
1209 xev.data.l[1] = XA_NET_WM_STATE_FULLSCREEN; | |
1210 else if (vo_fs_type & vo_wm_BELOW) | |
21938 | 1211 // This is not fallback. We can safely assume that the situation |
1212 // where only NETWM_STATE_BELOW is supported doesn't exist. | |
12582 | 1213 xev.data.l[1] = XA_NET_WM_STATE_BELOW; |
1214 | |
1215 XSendEvent(mDisplay, mRootWin, False, SubstructureRedirectMask, | |
1216 (XEvent *) & xev); | |
1217 state = XGetAtomName(mDisplay, xev.data.l[1]); | |
1218 mp_msg(MSGT_VO, MSGL_V, | |
1219 "[x11] NET style stay on top (layer %d). Using state %s.\n", | |
1220 layer, state); | |
1221 XFree(state); | |
1222 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
1223 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
1224 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
1225 static int vo_x11_get_fs_type(int supported) |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1226 { |
12582 | 1227 int i; |
1228 int type = supported; | |
1229 | |
1230 if (vo_fstype_list) | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1231 { |
12582 | 1232 i = 0; |
1233 for (i = 0; vo_fstype_list[i]; i++) | |
1234 { | |
1235 int neg = 0; | |
1236 char *arg = vo_fstype_list[i]; | |
1237 | |
1238 if (vo_fstype_list[i][0] == '-') | |
1239 { | |
1240 neg = 1; | |
1241 arg = vo_fstype_list[i] + 1; | |
1242 } | |
1243 | |
1244 if (!strncmp(arg, "layer", 5)) | |
1245 { | |
1246 if (!neg && (arg[5] == '=')) | |
1247 { | |
1248 char *endptr = NULL; | |
1249 int layer = strtol(vo_fstype_list[i] + 6, &endptr, 10); | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1250 |
12582 | 1251 if (endptr && *endptr == '\0' && layer >= 0 |
1252 && layer <= 15) | |
1253 fs_layer = layer; | |
1254 } | |
1255 if (neg) | |
1256 type &= ~vo_wm_LAYER; | |
1257 else | |
1258 type |= vo_wm_LAYER; | |
1259 } else if (!strcmp(arg, "above")) | |
1260 { | |
1261 if (neg) | |
1262 type &= ~vo_wm_ABOVE; | |
1263 else | |
1264 type |= vo_wm_ABOVE; | |
1265 } else if (!strcmp(arg, "fullscreen")) | |
1266 { | |
1267 if (neg) | |
1268 type &= ~vo_wm_FULLSCREEN; | |
1269 else | |
1270 type |= vo_wm_FULLSCREEN; | |
1271 } else if (!strcmp(arg, "stays_on_top")) | |
1272 { | |
1273 if (neg) | |
1274 type &= ~vo_wm_STAYS_ON_TOP; | |
1275 else | |
1276 type |= vo_wm_STAYS_ON_TOP; | |
1277 } else if (!strcmp(arg, "below")) | |
1278 { | |
1279 if (neg) | |
1280 type &= ~vo_wm_BELOW; | |
1281 else | |
1282 type |= vo_wm_BELOW; | |
1283 } else if (!strcmp(arg, "netwm")) | |
1284 { | |
1285 if (neg) | |
1286 type &= ~vo_wm_NETWM; | |
1287 else | |
1288 type |= vo_wm_NETWM; | |
1289 } else if (!strcmp(arg, "none")) | |
1290 return 0; | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1291 } |
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1292 } |
5919 | 1293 |
12582 | 1294 return type; |
4981 | 1295 } |
1296 | |
27885
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1297 /** |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1298 * \brief update vo_dx, vo_dy, vo_dwidth and vo_dheight with current values of vo_window |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1299 * \return returns current color depth of vo_window |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1300 */ |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1301 int vo_x11_update_geometry(void) { |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1302 unsigned depth, w, h; |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1303 int dummy_int; |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1304 Window dummy_win; |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1305 XGetGeometry(mDisplay, vo_window, &dummy_win, &dummy_int, &dummy_int, |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1306 &w, &h, &dummy_int, &depth); |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1307 if (w <= INT_MAX && h <= INT_MAX) { vo_dwidth = w; vo_dheight = h; } |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1308 XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy, |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1309 &dummy_win); |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1310 return depth <= INT_MAX ? depth : 0; |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1311 } |
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27815
diff
changeset
|
1312 |
12582 | 1313 void vo_x11_fullscreen(void) |
11542 | 1314 { |
12582 | 1315 int x, y, w, h; |
1316 | |
1317 if (WinID >= 0 || vo_fs_flip) | |
1318 return; | |
1319 | |
1320 if (vo_fs) | |
1321 { | |
1322 // fs->win | |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1323 if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs |
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1324 { |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1325 x = vo_old_x; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1326 y = vo_old_y; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1327 w = vo_old_width; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1328 h = vo_old_height; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1329 } |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1330 |
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1331 vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH |
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1332 vo_fs = VO_FALSE; |
12582 | 1333 } else |
1334 { | |
1335 // win->fs | |
1336 vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH | |
1337 | |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1338 vo_fs = VO_TRUE; |
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1339 if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs |
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1340 { |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1341 vo_old_x = vo_dx; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1342 vo_old_y = vo_dy; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1343 vo_old_width = vo_dwidth; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1344 vo_old_height = vo_dheight; |
23875
df05ff41590e
make sure update_xinerama_info is always called even when using the
reimar
parents:
23823
diff
changeset
|
1345 } |
18116 | 1346 update_xinerama_info(); |
1347 x = xinerama_x; | |
1348 y = xinerama_y; | |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1349 w = vo_screenwidth; |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1350 h = vo_screenheight; |
12582 | 1351 } |
1352 { | |
1353 long dummy; | |
1354 | |
1355 XGetWMNormalHints(mDisplay, vo_window, &vo_hint, &dummy); | |
1356 if (!(vo_hint.flags & PWinGravity)) | |
1357 old_gravity = NorthWestGravity; | |
1358 else | |
1359 old_gravity = vo_hint.win_gravity; | |
1360 } | |
1361 if (vo_wm_type == 0 && !(vo_fsmode & 16)) | |
1362 { | |
1363 XUnmapWindow(mDisplay, vo_window); // required for MWM | |
1364 XWithdrawWindow(mDisplay, vo_window, mScreen); | |
1365 vo_fs_flip = 1; | |
1366 } | |
1367 | |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1368 if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs |
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1369 { |
27303
690ba711bda8
Make vo_x11_fullscreen not break vo_border (proper support still needs vo changes)
reimar
parents:
27029
diff
changeset
|
1370 vo_x11_decoration(mDisplay, vo_window, vo_border && !vo_fs); |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1371 vo_x11_sizehint(x, y, w, h, 0); |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1372 vo_x11_setlayer(mDisplay, vo_window, vo_fs); |
12582 | 1373 |
1374 | |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1375 XMoveResizeWindow(mDisplay, vo_window, x, y, w, h); |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1376 } |
21938 | 1377 /* some WMs lose ontop after fullscreen */ |
14244
9b03ad0254ae
Fix ontop for some WMs that lose ontop state after fullscreen event.
al
parents:
14207
diff
changeset
|
1378 if ((!(vo_fs)) & vo_ontop) |
9b03ad0254ae
Fix ontop for some WMs that lose ontop state after fullscreen event.
al
parents:
14207
diff
changeset
|
1379 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
9b03ad0254ae
Fix ontop for some WMs that lose ontop state after fullscreen event.
al
parents:
14207
diff
changeset
|
1380 |
12582 | 1381 XMapRaised(mDisplay, vo_window); |
18715
30d7ddf08889
Fix window position when changing videos while in fullscreen and for
reimar
parents:
18508
diff
changeset
|
1382 if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map |
30d7ddf08889
Fix window position when changing videos while in fullscreen and for
reimar
parents:
18508
diff
changeset
|
1383 XMoveResizeWindow(mDisplay, vo_window, x, y, w, h); |
12582 | 1384 XRaiseWindow(mDisplay, vo_window); |
1385 XFlush(mDisplay); | |
1386 } | |
1387 | |
1388 void vo_x11_ontop(void) | |
1389 { | |
1390 vo_ontop = (!(vo_ontop)); | |
1391 | |
1392 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 1393 } |
1394 | |
27306
7a650839fc10
Enable runtime border/window decorations-toggling for Linux gl and gl2 vos.
reimar
parents:
27304
diff
changeset
|
1395 void vo_x11_border(void) |
7a650839fc10
Enable runtime border/window decorations-toggling for Linux gl and gl2 vos.
reimar
parents:
27304
diff
changeset
|
1396 { |
7a650839fc10
Enable runtime border/window decorations-toggling for Linux gl and gl2 vos.
reimar
parents:
27304
diff
changeset
|
1397 vo_border = !vo_border; |
7a650839fc10
Enable runtime border/window decorations-toggling for Linux gl and gl2 vos.
reimar
parents:
27304
diff
changeset
|
1398 vo_x11_decoration(mDisplay, vo_window, vo_border && !vo_fs); |
7a650839fc10
Enable runtime border/window decorations-toggling for Linux gl and gl2 vos.
reimar
parents:
27304
diff
changeset
|
1399 } |
7a650839fc10
Enable runtime border/window decorations-toggling for Linux gl and gl2 vos.
reimar
parents:
27304
diff
changeset
|
1400 |
9695 | 1401 /* |
1402 * XScreensaver stuff | |
1403 */ | |
1404 | |
25608
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1405 static int screensaver_off; |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1406 static unsigned int time_last; |
9695 | 1407 |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1408 void xscreensaver_heartbeat(void) |
9695 | 1409 { |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1410 unsigned int time = GetTimerMS(); |
9695 | 1411 |
25609
dc64735e7391
Remove most of the messy screensaver code in favour of only XResetScreenSaver
reimar
parents:
25608
diff
changeset
|
1412 if (mDisplay && screensaver_off && (time - time_last) > 30000) |
12582 | 1413 { |
1414 time_last = time; | |
9695 | 1415 |
25609
dc64735e7391
Remove most of the messy screensaver code in favour of only XResetScreenSaver
reimar
parents:
25608
diff
changeset
|
1416 XResetScreenSaver(mDisplay); |
9695 | 1417 } |
1418 } | |
1419 | |
25466 | 1420 static int xss_suspend(Bool suspend) |
1421 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
1422 #ifndef CONFIG_XSS |
25466 | 1423 return 0; |
1424 #else | |
1425 int event, error, major, minor; | |
1426 if (XScreenSaverQueryExtension(mDisplay, &event, &error) != True || | |
1427 XScreenSaverQueryVersion(mDisplay, &major, &minor) != True) | |
1428 return 0; | |
27029
e8c49e69f46f
Add parentheses to expression to avoid the warning:
diego
parents:
26755
diff
changeset
|
1429 if (major < 1 || (major == 1 && minor < 1)) |
25466 | 1430 return 0; |
1431 XScreenSaverSuspend(mDisplay, suspend); | |
1432 return 1; | |
1433 #endif | |
1434 } | |
1435 | |
9695 | 1436 /* |
1437 * End of XScreensaver stuff | |
1438 */ | |
1439 | |
12582 | 1440 void saver_on(Display * mDisplay) |
1441 { | |
324 | 1442 |
25608
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1443 if (!screensaver_off) |
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1444 return; |
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1445 screensaver_off = 0; |
25466 | 1446 if (xss_suspend(False)) |
1447 return; | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
1448 #ifdef CONFIG_XDPMS |
324 | 1449 if (dpms_disabled) |
1450 { | |
25447 | 1451 int nothing; |
12582 | 1452 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) |
1453 { | |
1454 if (!DPMSEnable(mDisplay)) | |
1455 { // restoring power saving settings | |
1456 mp_msg(MSGT_VO, MSGL_WARN, "DPMS not available?\n"); | |
1457 } else | |
1458 { | |
741 | 1459 // DPMS does not seem to be enabled unless we call DPMSInfo |
12582 | 1460 BOOL onoff; |
1461 CARD16 state; | |
1462 | |
1463 DPMSForceLevel(mDisplay, DPMSModeOn); | |
1464 DPMSInfo(mDisplay, &state, &onoff); | |
1465 if (onoff) | |
1466 { | |
13946 | 1467 mp_msg(MSGT_VO, MSGL_V, |
12582 | 1468 "Successfully enabled DPMS\n"); |
1469 } else | |
1470 { | |
1471 mp_msg(MSGT_VO, MSGL_WARN, "Could not enable DPMS\n"); | |
741 | 1472 } |
1473 } | |
12582 | 1474 } |
1475 dpms_disabled = 0; | |
324 | 1476 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1477 #endif |
324 | 1478 } |
1479 | |
12582 | 1480 void saver_off(Display * mDisplay) |
1481 { | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1482 int nothing; |
324 | 1483 |
25608
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1484 if (screensaver_off) |
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1485 return; |
3ada48a71450
Use a screensaver_off variable to save current state and avoid
reimar
parents:
25482
diff
changeset
|
1486 screensaver_off = 1; |
25466 | 1487 if (xss_suspend(True)) |
1488 return; | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
1489 #ifdef CONFIG_XDPMS |
324 | 1490 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) |
1491 { | |
12582 | 1492 BOOL onoff; |
1493 CARD16 state; | |
1494 | |
1495 DPMSInfo(mDisplay, &state, &onoff); | |
1496 if (onoff) | |
1497 { | |
1498 Status stat; | |
1499 | |
13946 | 1500 mp_msg(MSGT_VO, MSGL_V, "Disabling DPMS\n"); |
12582 | 1501 dpms_disabled = 1; |
1502 stat = DPMSDisable(mDisplay); // monitor powersave off | |
1503 mp_msg(MSGT_VO, MSGL_V, "DPMSDisable stat: %d\n", stat); | |
1504 } | |
324 | 1505 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1506 #endif |
326 | 1507 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1508 |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1509 static XErrorHandler old_handler = NULL; |
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1510 static int selectinput_err = 0; |
12582 | 1511 static int x11_selectinput_errorhandler(Display * display, |
1512 XErrorEvent * event) | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1513 { |
12582 | 1514 if (event->error_code == BadAccess) |
1515 { | |
1516 selectinput_err = 1; | |
1517 mp_msg(MSGT_VO, MSGL_ERR, | |
1518 "X11 error: BadAccess during XSelectInput Call\n"); | |
1519 mp_msg(MSGT_VO, MSGL_ERR, | |
1520 "X11 error: The 'ButtonPressMask' mask of specified window has probably already used by another appication (see man XSelectInput)\n"); | |
21938 | 1521 /* If you think MPlayer should shutdown with this error, |
1522 * comment out the following line */ | |
12582 | 1523 return 0; |
1524 } | |
1525 if (old_handler != NULL) | |
1526 old_handler(display, event); | |
1527 else | |
1528 x11_errorhandler(display, event); | |
1529 return 0; | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1530 } |
3990 | 1531 |
12582 | 1532 void vo_x11_selectinput_witherr(Display * display, Window w, |
1533 long event_mask) | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1534 { |
12582 | 1535 XSync(display, False); |
1536 old_handler = XSetErrorHandler(x11_selectinput_errorhandler); | |
1537 selectinput_err = 0; | |
1538 if (vo_nomouse_input) | |
1539 { | |
1540 XSelectInput(display, w, | |
1541 event_mask & | |
1542 (~(ButtonPressMask | ButtonReleaseMask))); | |
1543 } else | |
1544 { | |
1545 XSelectInput(display, w, event_mask); | |
1546 } | |
1547 XSync(display, False); | |
1548 XSetErrorHandler(old_handler); | |
1549 if (selectinput_err) | |
1550 { | |
1551 mp_msg(MSGT_VO, MSGL_ERR, | |
1552 "X11 error: MPlayer discards mouse control (reconfiguring)\n"); | |
1553 XSelectInput(display, w, | |
1554 event_mask & | |
1555 (~ | |
1556 (ButtonPressMask | ButtonReleaseMask | | |
1557 PointerMotionMask))); | |
1558 } | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1559 } |
3990 | 1560 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
1561 #ifdef CONFIG_XF86VM |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1562 void vo_vm_switch(void) |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1563 { |
13828
b4ad5f0b550d
Fix erroneus extern declarations, fix wrong signedness of some vars
atmos4
parents:
13787
diff
changeset
|
1564 int vm_event, vm_error; |
b4ad5f0b550d
Fix erroneus extern declarations, fix wrong signedness of some vars
atmos4
parents:
13787
diff
changeset
|
1565 int vm_ver, vm_rev; |
12582 | 1566 int i, j, have_vm = 0; |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1567 int X = vo_dwidth, Y = vo_dheight; |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1568 int modeline_width, modeline_height; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1569 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1570 int modecount; |
12582 | 1571 |
1572 if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) | |
1573 { | |
1574 XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); | |
18508 | 1575 mp_msg(MSGT_VO, MSGL_V, "XF86VidMode extension v%i.%i\n", vm_ver, |
12582 | 1576 vm_rev); |
1577 have_vm = 1; | |
27887
47385b5c0613
Set modeline_width/height to sane values in vo_vm_switch even when
reimar
parents:
27885
diff
changeset
|
1578 } else { |
12582 | 1579 mp_msg(MSGT_VO, MSGL_WARN, |
18508 | 1580 "XF86VidMode extension not available.\n"); |
27887
47385b5c0613
Set modeline_width/height to sane values in vo_vm_switch even when
reimar
parents:
27885
diff
changeset
|
1581 } |
12582 | 1582 |
1583 if (have_vm) | |
1584 { | |
1585 if (vidmodes == NULL) | |
1586 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
1587 &vidmodes); | |
1588 j = 0; | |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1589 modeline_width = vidmodes[0]->hdisplay; |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1590 modeline_height = vidmodes[0]->vdisplay; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1591 |
12582 | 1592 for (i = 1; i < modecount; i++) |
1593 if ((vidmodes[i]->hdisplay >= X) | |
1594 && (vidmodes[i]->vdisplay >= Y)) | |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1595 if ((vidmodes[i]->hdisplay <= modeline_width) |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1596 && (vidmodes[i]->vdisplay <= modeline_height)) |
12582 | 1597 { |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1598 modeline_width = vidmodes[i]->hdisplay; |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1599 modeline_height = vidmodes[i]->vdisplay; |
12582 | 1600 j = i; |
1601 } | |
1602 | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16301
diff
changeset
|
1603 mp_msg(MSGT_VO, MSGL_INFO, MSGTR_SelectedVideoMode, |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1604 modeline_width, modeline_height, X, Y); |
12582 | 1605 XF86VidModeLockModeSwitch(mDisplay, mScreen, 0); |
1606 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]); | |
1607 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]); | |
27889
08a5ccceb21a
Set modified window position and monitor aspect in vo_vm_switch instead of in
reimar
parents:
27887
diff
changeset
|
1608 |
08a5ccceb21a
Set modified window position and monitor aspect in vo_vm_switch instead of in
reimar
parents:
27887
diff
changeset
|
1609 // FIXME: all this is more of a hack than proper solution |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1610 X = (vo_screenwidth - modeline_width) / 2; |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1611 Y = (vo_screenheight - modeline_height) / 2; |
12582 | 1612 XF86VidModeSetViewPort(mDisplay, mScreen, X, Y); |
27889
08a5ccceb21a
Set modified window position and monitor aspect in vo_vm_switch instead of in
reimar
parents:
27887
diff
changeset
|
1613 vo_dx = X; |
08a5ccceb21a
Set modified window position and monitor aspect in vo_vm_switch instead of in
reimar
parents:
27887
diff
changeset
|
1614 vo_dy = Y; |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1615 vo_dwidth = modeline_width; |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1616 vo_dheight = modeline_height; |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1617 aspect_save_screenres(modeline_width, modeline_height); |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1618 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1619 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1620 |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1621 void vo_vm_close(void) |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1622 { |
27343 | 1623 #ifdef CONFIG_GUI |
12582 | 1624 if (vidmodes != NULL && vo_window != None) |
1625 #else | |
1626 if (vidmodes != NULL) | |
1627 #endif | |
1628 { | |
1629 int i, modecount; | |
5019 | 1630 |
12582 | 1631 free(vidmodes); |
1632 vidmodes = NULL; | |
1633 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
1634 &vidmodes); | |
1635 for (i = 0; i < modecount; i++) | |
1636 if ((vidmodes[i]->hdisplay == vo_screenwidth) | |
1637 && (vidmodes[i]->vdisplay == vo_screenheight)) | |
1638 { | |
1639 mp_msg(MSGT_VO, MSGL_INFO, | |
1640 "Returning to original mode %dx%d\n", | |
1641 vo_screenwidth, vo_screenheight); | |
1642 break; | |
1643 } | |
5019 | 1644 |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1645 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]); |
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
1646 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]); |
12582 | 1647 free(vidmodes); |
1648 vidmodes = NULL; | |
1649 } | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1650 } |
3990 | 1651 #endif |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1652 |
12582 | 1653 #endif /* X11_FULLSCREEN */ |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1654 |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1655 |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1656 /* |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1657 * Scan the available visuals on this Display/Screen. Try to find |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1658 * the 'best' available TrueColor visual that has a decent color |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1659 * depth (at least 15bit). If there are multiple visuals with depth |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1660 * >= 15bit, we prefer visuals with a smaller color depth. |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1661 */ |
12582 | 1662 int vo_find_depth_from_visuals(Display * dpy, int screen, |
1663 Visual ** visual_return) | |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1664 { |
12582 | 1665 XVisualInfo visual_tmpl; |
1666 XVisualInfo *visuals; | |
1667 int nvisuals, i; | |
1668 int bestvisual = -1; | |
1669 int bestvisual_depth = -1; | |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1670 |
12582 | 1671 visual_tmpl.screen = screen; |
1672 visual_tmpl.class = TrueColor; | |
1673 visuals = XGetVisualInfo(dpy, | |
1674 VisualScreenMask | VisualClassMask, | |
1675 &visual_tmpl, &nvisuals); | |
1676 if (visuals != NULL) | |
1677 { | |
1678 for (i = 0; i < nvisuals; i++) | |
1679 { | |
1680 mp_msg(MSGT_VO, MSGL_V, | |
17366 | 1681 "vo: X11 truecolor visual %#lx, depth %d, R:%lX G:%lX B:%lX\n", |
12582 | 1682 visuals[i].visualid, visuals[i].depth, |
1683 visuals[i].red_mask, visuals[i].green_mask, | |
1684 visuals[i].blue_mask); | |
1685 /* | |
21938 | 1686 * Save the visual index and its depth, if this is the first |
12582 | 1687 * truecolor visul, or a visual that is 'preferred' over the |
21938 | 1688 * previous 'best' visual. |
12582 | 1689 */ |
1690 if (bestvisual_depth == -1 | |
1691 || (visuals[i].depth >= 15 | |
1692 && (visuals[i].depth < bestvisual_depth | |
1693 || bestvisual_depth < 15))) | |
1694 { | |
1695 bestvisual = i; | |
1696 bestvisual_depth = visuals[i].depth; | |
1697 } | |
1698 } | |
1699 | |
1700 if (bestvisual != -1 && visual_return != NULL) | |
1701 *visual_return = visuals[bestvisual].visual; | |
1702 | |
1703 XFree(visuals); | |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1704 } |
12582 | 1705 return bestvisual_depth; |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1706 } |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1707 |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1708 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1709 static Colormap cmap = None; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1710 static XColor cols[256]; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1711 static int cm_size, red_mask, green_mask, blue_mask; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1712 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1713 |
12582 | 1714 Colormap vo_x11_create_colormap(XVisualInfo * vinfo) |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1715 { |
12582 | 1716 unsigned k, r, g, b, ru, gu, bu, m, rv, gv, bv, rvu, gvu, bvu; |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1717 |
12582 | 1718 if (vinfo->class != DirectColor) |
1719 return XCreateColormap(mDisplay, mRootWin, vinfo->visual, | |
1720 AllocNone); | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1721 |
12582 | 1722 /* can this function get called twice or more? */ |
1723 if (cmap) | |
1724 return cmap; | |
1725 cm_size = vinfo->colormap_size; | |
1726 red_mask = vinfo->red_mask; | |
1727 green_mask = vinfo->green_mask; | |
1728 blue_mask = vinfo->blue_mask; | |
1729 ru = (red_mask & (red_mask - 1)) ^ red_mask; | |
1730 gu = (green_mask & (green_mask - 1)) ^ green_mask; | |
1731 bu = (blue_mask & (blue_mask - 1)) ^ blue_mask; | |
1732 rvu = 65536ull * ru / (red_mask + ru); | |
1733 gvu = 65536ull * gu / (green_mask + gu); | |
1734 bvu = 65536ull * bu / (blue_mask + bu); | |
1735 r = g = b = 0; | |
1736 rv = gv = bv = 0; | |
1737 m = DoRed | DoGreen | DoBlue; | |
1738 for (k = 0; k < cm_size; k++) | |
1739 { | |
1740 int t; | |
1741 | |
1742 cols[k].pixel = r | g | b; | |
1743 cols[k].red = rv; | |
1744 cols[k].green = gv; | |
1745 cols[k].blue = bv; | |
1746 cols[k].flags = m; | |
1747 t = (r + ru) & red_mask; | |
1748 if (t < r) | |
1749 m &= ~DoRed; | |
1750 r = t; | |
1751 t = (g + gu) & green_mask; | |
1752 if (t < g) | |
1753 m &= ~DoGreen; | |
1754 g = t; | |
1755 t = (b + bu) & blue_mask; | |
1756 if (t < b) | |
1757 m &= ~DoBlue; | |
1758 b = t; | |
1759 rv += rvu; | |
1760 gv += gvu; | |
1761 bv += bvu; | |
1762 } | |
1763 cmap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocAll); | |
1764 XStoreColors(mDisplay, cmap, cols, cm_size); | |
1765 return cmap; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1766 } |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1767 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1768 /* |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1769 * Via colormaps/gamma ramps we can do gamma, brightness, contrast, |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1770 * hue and red/green/blue intensity, but we cannot do saturation. |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1771 * Currently only gamma, brightness and contrast are implemented. |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1772 * Is there sufficient interest for hue and/or red/green/blue intensity? |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1773 */ |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1774 /* these values have range [-100,100] and are initially 0 */ |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1775 static int vo_gamma = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1776 static int vo_brightness = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1777 static int vo_contrast = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1778 |
25674
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1779 static int transform_color(float val, |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1780 float brightness, float contrast, float gamma) { |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1781 float s = pow(val, gamma); |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1782 s = (s - 0.5) * contrast + 0.5; |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1783 s += brightness; |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1784 if (s < 0) |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1785 s = 0; |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1786 if (s > 1) |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1787 s = 1; |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1788 return (unsigned short) (s * 65535); |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1789 } |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1790 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1791 uint32_t vo_x11_set_equalizer(char *name, int value) |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1792 { |
12582 | 1793 float gamma, brightness, contrast; |
1794 float rf, gf, bf; | |
1795 int k; | |
1796 | |
1797 /* | |
1798 * IMPLEMENTME: consider using XF86VidModeSetGammaRamp in the case | |
1799 * of TrueColor-ed window but be careful: | |
21938 | 1800 * Unlike the colormaps, which are private for the X client |
12582 | 1801 * who created them and thus automatically destroyed on client |
1802 * disconnect, this gamma ramp is a system-wide (X-server-wide) | |
21938 | 1803 * setting and _must_ be restored before the process exits. |
1804 * Unforunately when the process crashes (or gets killed | |
12582 | 1805 * for some reason) it is impossible to restore the setting, |
1806 * and such behaviour could be rather annoying for the users. | |
1807 */ | |
1808 if (cmap == None) | |
1809 return VO_NOTAVAIL; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1810 |
12582 | 1811 if (!strcasecmp(name, "brightness")) |
1812 vo_brightness = value; | |
1813 else if (!strcasecmp(name, "contrast")) | |
1814 vo_contrast = value; | |
1815 else if (!strcasecmp(name, "gamma")) | |
1816 vo_gamma = value; | |
1817 else | |
1818 return VO_NOTIMPL; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1819 |
12582 | 1820 brightness = 0.01 * vo_brightness; |
1821 contrast = tan(0.0095 * (vo_contrast + 100) * M_PI / 4); | |
1822 gamma = pow(2, -0.02 * vo_gamma); | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1823 |
12582 | 1824 rf = (float) ((red_mask & (red_mask - 1)) ^ red_mask) / red_mask; |
1825 gf = (float) ((green_mask & (green_mask - 1)) ^ green_mask) / | |
1826 green_mask; | |
1827 bf = (float) ((blue_mask & (blue_mask - 1)) ^ blue_mask) / blue_mask; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1828 |
12582 | 1829 /* now recalculate the colormap using the newly set value */ |
1830 for (k = 0; k < cm_size; k++) | |
1831 { | |
25674
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1832 cols[k].red = transform_color(rf * k, brightness, contrast, gamma); |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1833 cols[k].green = transform_color(gf * k, brightness, contrast, gamma); |
b13f792efe7b
Use a transform_color function to reduce code duplication
reimar
parents:
25626
diff
changeset
|
1834 cols[k].blue = transform_color(bf * k, brightness, contrast, gamma); |
12582 | 1835 } |
1836 | |
1837 XStoreColors(mDisplay, cmap, cols, cm_size); | |
1838 XFlush(mDisplay); | |
1839 return VO_TRUE; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1840 } |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1841 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1842 uint32_t vo_x11_get_equalizer(char *name, int *value) |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1843 { |
12582 | 1844 if (cmap == None) |
1845 return VO_NOTAVAIL; | |
1846 if (!strcasecmp(name, "brightness")) | |
1847 *value = vo_brightness; | |
1848 else if (!strcasecmp(name, "contrast")) | |
1849 *value = vo_contrast; | |
1850 else if (!strcasecmp(name, "gamma")) | |
1851 *value = vo_gamma; | |
1852 else | |
1853 return VO_NOTIMPL; | |
1854 return VO_TRUE; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1855 } |
12582 | 1856 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
1857 #ifdef CONFIG_XV |
10359 | 1858 int vo_xv_set_eq(uint32_t xv_port, char *name, int value) |
1859 { | |
1860 XvAttribute *attributes; | |
12582 | 1861 int i, howmany, xv_atom; |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1862 |
10359 | 1863 mp_dbg(MSGT_VO, MSGL_V, "xv_set_eq called! (%s, %d)\n", name, value); |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1864 |
10359 | 1865 /* get available attributes */ |
1866 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); | |
1867 for (i = 0; i < howmany && attributes; i++) | |
12582 | 1868 if (attributes[i].flags & XvSettable) |
1869 { | |
1870 xv_atom = XInternAtom(mDisplay, attributes[i].name, True); | |
10359 | 1871 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
1872 then trigger it if it's ok so that the other values are at default upon query */ | |
12582 | 1873 if (xv_atom != None) |
1874 { | |
1875 int hue = 0, port_value, port_min, port_max; | |
10359 | 1876 |
12582 | 1877 if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && |
1878 (!strcasecmp(name, "brightness"))) | |
1879 port_value = value; | |
1880 else if (!strcmp(attributes[i].name, "XV_CONTRAST") && | |
1881 (!strcasecmp(name, "contrast"))) | |
1882 port_value = value; | |
1883 else if (!strcmp(attributes[i].name, "XV_SATURATION") && | |
1884 (!strcasecmp(name, "saturation"))) | |
1885 port_value = value; | |
1886 else if (!strcmp(attributes[i].name, "XV_HUE") && | |
1887 (!strcasecmp(name, "hue"))) | |
1888 { | |
1889 port_value = value; | |
1890 hue = 1; | |
1891 } else | |
10359 | 1892 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
12582 | 1893 if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && |
1894 (!strcasecmp(name, "red_intensity"))) | |
1895 port_value = value; | |
1896 else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") | |
1897 && (!strcasecmp(name, "green_intensity"))) | |
1898 port_value = value; | |
1899 else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") | |
1900 && (!strcasecmp(name, "blue_intensity"))) | |
1901 port_value = value; | |
1902 else | |
1903 continue; | |
1904 | |
1905 port_min = attributes[i].min_value; | |
1906 port_max = attributes[i].max_value; | |
10359 | 1907 |
12582 | 1908 /* nvidia hue workaround */ |
1909 if (hue && port_min == 0 && port_max == 360) | |
1910 { | |
1911 port_value = | |
1912 (port_value >= | |
1913 0) ? (port_value - 100) : (port_value + 100); | |
10359 | 1914 } |
12582 | 1915 // -100 -> min |
1916 // 0 -> (max+min)/2 | |
1917 // +100 -> max | |
1918 port_value = | |
1919 (port_value + 100) * (port_max - port_min) / 200 + | |
1920 port_min; | |
1921 XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value); | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26436
diff
changeset
|
1922 return VO_TRUE; |
12582 | 1923 } |
1924 } | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26436
diff
changeset
|
1925 return VO_FALSE; |
10359 | 1926 } |
1927 | |
1928 int vo_xv_get_eq(uint32_t xv_port, char *name, int *value) | |
1929 { | |
12582 | 1930 |
10359 | 1931 XvAttribute *attributes; |
12582 | 1932 int i, howmany, xv_atom; |
10359 | 1933 |
1934 /* get available attributes */ | |
1935 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); | |
1936 for (i = 0; i < howmany && attributes; i++) | |
12582 | 1937 if (attributes[i].flags & XvGettable) |
1938 { | |
1939 xv_atom = XInternAtom(mDisplay, attributes[i].name, True); | |
10359 | 1940 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
1941 then trigger it if it's ok so that the other values are at default upon query */ | |
12582 | 1942 if (xv_atom != None) |
1943 { | |
1944 int val, port_value = 0, port_min, port_max; | |
10359 | 1945 |
12582 | 1946 XvGetPortAttribute(mDisplay, xv_port, xv_atom, |
1947 &port_value); | |
1948 | |
1949 port_min = attributes[i].min_value; | |
1950 port_max = attributes[i].max_value; | |
1951 val = | |
1952 (port_value - port_min) * 200 / (port_max - port_min) - | |
1953 100; | |
10359 | 1954 |
12582 | 1955 if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && |
1956 (!strcasecmp(name, "brightness"))) | |
1957 *value = val; | |
1958 else if (!strcmp(attributes[i].name, "XV_CONTRAST") && | |
1959 (!strcasecmp(name, "contrast"))) | |
1960 *value = val; | |
1961 else if (!strcmp(attributes[i].name, "XV_SATURATION") && | |
1962 (!strcasecmp(name, "saturation"))) | |
1963 *value = val; | |
1964 else if (!strcmp(attributes[i].name, "XV_HUE") && | |
1965 (!strcasecmp(name, "hue"))) | |
1966 { | |
1967 /* nasty nvidia detect */ | |
1968 if (port_min == 0 && port_max == 360) | |
1969 *value = (val >= 0) ? (val - 100) : (val + 100); | |
1970 else | |
1971 *value = val; | |
1972 } else | |
10359 | 1973 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
12582 | 1974 if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && |
1975 (!strcasecmp(name, "red_intensity"))) | |
1976 *value = val; | |
1977 else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") | |
1978 && (!strcasecmp(name, "green_intensity"))) | |
1979 *value = val; | |
1980 else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") | |
1981 && (!strcasecmp(name, "blue_intensity"))) | |
1982 *value = val; | |
1983 else | |
1984 continue; | |
10359 | 1985 |
12582 | 1986 mp_dbg(MSGT_VO, MSGL_V, "xv_get_eq called! (%s, %d)\n", |
1987 name, *value); | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26436
diff
changeset
|
1988 return VO_TRUE; |
12582 | 1989 } |
1990 } | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26436
diff
changeset
|
1991 return VO_FALSE; |
10359 | 1992 } |
1993 | |
14742 | 1994 /** \brief contains flags changing the execution of the colorkeying code */ |
1995 xv_ck_info_t xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR }; | |
1996 unsigned long xv_colorkey; ///< The color used for manual colorkeying. | |
1997 unsigned int xv_port; ///< The selected Xv port. | |
1998 | |
1999 /** | |
2000 * \brief Interns the requested atom if it is available. | |
2001 * | |
2002 * \param atom_name String containing the name of the requested atom. | |
2003 * | |
2004 * \return Returns the atom if available, else None is returned. | |
2005 * | |
2006 */ | |
2007 static Atom xv_intern_atom_if_exists( char const * atom_name ) | |
2008 { | |
2009 XvAttribute * attributes; | |
2010 int attrib_count,i; | |
2011 Atom xv_atom = None; | |
2012 | |
2013 attributes = XvQueryPortAttributes( mDisplay, xv_port, &attrib_count ); | |
2014 if( attributes!=NULL ) | |
2015 { | |
2016 for ( i = 0; i < attrib_count; ++i ) | |
2017 { | |
2018 if ( strcmp(attributes[i].name, atom_name ) == 0 ) | |
2019 { | |
2020 xv_atom = XInternAtom( mDisplay, atom_name, False ); | |
2021 break; // found what we want, break out | |
2022 } | |
2023 } | |
2024 XFree( attributes ); | |
2025 } | |
2026 | |
2027 return xv_atom; | |
2028 } | |
15826
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2029 |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2030 /** |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2031 * \brief Try to enable vsync for xv. |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2032 * \return Returns -1 if not available, 0 on failure and 1 on success. |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2033 */ |
22886 | 2034 int vo_xv_enable_vsync(void) |
15826
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2035 { |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2036 Atom xv_atom = xv_intern_atom_if_exists("XV_SYNC_TO_VBLANK"); |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2037 if (xv_atom == None) |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2038 return -1; |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2039 return XvSetPortAttribute(mDisplay, xv_port, xv_atom, 1) == Success; |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2040 } |
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15789
diff
changeset
|
2041 |
14742 | 2042 /** |
16958 | 2043 * \brief Get maximum supported source image dimensions. |
2044 * | |
2045 * This function does not set the variables pointed to by | |
21938 | 2046 * width and height if the information could not be retrieved, |
2047 * so the caller is reponsible for properly initializing them. | |
16958 | 2048 * |
2049 * \param width [out] The maximum width gets stored here. | |
2050 * \param height [out] The maximum height gets stored here. | |
2051 * | |
2052 */ | |
2053 void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height ) | |
2054 { | |
2055 XvEncodingInfo * encodings; | |
2056 //unsigned long num_encodings, idx; to int or too long?! | |
2057 unsigned int num_encodings, idx; | |
2058 | |
2059 XvQueryEncodings( mDisplay, xv_port, &num_encodings, &encodings); | |
2060 | |
2061 if ( encodings ) | |
2062 { | |
2063 for ( idx = 0; idx < num_encodings; ++idx ) | |
2064 { | |
2065 if ( strcmp( encodings[idx].name, "XV_IMAGE" ) == 0 ) | |
2066 { | |
2067 *width = encodings[idx].width; | |
2068 *height = encodings[idx].height; | |
2069 break; | |
2070 } | |
2071 } | |
2072 } | |
2073 | |
2074 mp_msg( MSGT_VO, MSGL_V, | |
2075 "[xv common] Maximum source image dimensions: %ux%u\n", | |
2076 *width, *height ); | |
2077 | |
2078 XvFreeEncodingInfo( encodings ); | |
2079 } | |
2080 | |
2081 /** | |
14742 | 2082 * \brief Print information about the colorkey method and source. |
2083 * | |
2084 * \param ck_handling Integer value containing the information about | |
2085 * colorkey handling (see x11_common.h). | |
2086 * | |
2087 * Outputs the content of |ck_handling| as a readable message. | |
2088 * | |
2089 */ | |
22886 | 2090 void vo_xv_print_ck_info(void) |
14742 | 2091 { |
2092 mp_msg( MSGT_VO, MSGL_V, "[xv common] " ); | |
2093 | |
2094 switch ( xv_ck_info.method ) | |
2095 { | |
2096 case CK_METHOD_NONE: | |
2097 mp_msg( MSGT_VO, MSGL_V, "Drawing no colorkey.\n" ); return; | |
2098 case CK_METHOD_AUTOPAINT: | |
2099 mp_msg( MSGT_VO, MSGL_V, "Colorkey is drawn by Xv." ); break; | |
2100 case CK_METHOD_MANUALFILL: | |
2101 mp_msg( MSGT_VO, MSGL_V, "Drawing colorkey manually." ); break; | |
2102 case CK_METHOD_BACKGROUND: | |
2103 mp_msg( MSGT_VO, MSGL_V, "Colorkey is drawn as window background." ); break; | |
2104 } | |
2105 | |
2106 mp_msg( MSGT_VO, MSGL_V, "\n[xv common] " ); | |
2107 | |
2108 switch ( xv_ck_info.source ) | |
2109 { | |
2110 case CK_SRC_CUR: | |
17366 | 2111 mp_msg( MSGT_VO, MSGL_V, "Using colorkey from Xv (0x%06lx).\n", |
14742 | 2112 xv_colorkey ); |
2113 break; | |
2114 case CK_SRC_USE: | |
2115 if ( xv_ck_info.method == CK_METHOD_AUTOPAINT ) | |
2116 { | |
2117 mp_msg( MSGT_VO, MSGL_V, | |
17366 | 2118 "Ignoring colorkey from MPlayer (0x%06lx).\n", |
14742 | 2119 xv_colorkey ); |
2120 } | |
2121 else | |
2122 { | |
2123 mp_msg( MSGT_VO, MSGL_V, | |
17366 | 2124 "Using colorkey from MPlayer (0x%06lx)." |
14742 | 2125 " Use -colorkey to change.\n", |
2126 xv_colorkey ); | |
2127 } | |
2128 break; | |
2129 case CK_SRC_SET: | |
2130 mp_msg( MSGT_VO, MSGL_V, | |
17366 | 2131 "Setting and using colorkey from MPlayer (0x%06lx)." |
14742 | 2132 " Use -colorkey to change.\n", |
2133 xv_colorkey ); | |
2134 break; | |
2135 } | |
2136 } | |
2137 /** | |
2138 * \brief Init colorkey depending on the settings in xv_ck_info. | |
2139 * | |
2140 * \return Returns 0 on failure and 1 on success. | |
2141 * | |
2142 * Sets the colorkey variable according to the CK_SRC_* and CK_METHOD_* | |
2143 * flags in xv_ck_info. | |
2144 * | |
2145 * Possiblilities: | |
2146 * * Methods | |
2147 * - manual colorkey drawing ( CK_METHOD_MANUALFILL ) | |
2148 * - set colorkey as window background ( CK_METHOD_BACKGROUND ) | |
2149 * - let Xv paint the colorkey ( CK_METHOD_AUTOPAINT ) | |
2150 * * Sources | |
2151 * - use currently set colorkey ( CK_SRC_CUR ) | |
2152 * - use colorkey in vo_colorkey ( CK_SRC_USE ) | |
2153 * - use and set colorkey in vo_colorkey ( CK_SRC_SET ) | |
2154 * | |
2155 * NOTE: If vo_colorkey has bits set after the first 3 low order bytes | |
2156 * we don't draw anything as this means it was forced to off. | |
2157 */ | |
22886 | 2158 int vo_xv_init_colorkey(void) |
14742 | 2159 { |
2160 Atom xv_atom; | |
2161 int rez; | |
2162 | |
2163 /* check if colorkeying is needed */ | |
2164 xv_atom = xv_intern_atom_if_exists( "XV_COLORKEY" ); | |
2165 | |
2166 /* if we have to deal with colorkeying ... */ | |
2167 if( xv_atom != None && !(vo_colorkey & 0xFF000000) ) | |
2168 { | |
2169 /* check if we should use the colorkey specified in vo_colorkey */ | |
2170 if ( xv_ck_info.source != CK_SRC_CUR ) | |
2171 { | |
2172 xv_colorkey = vo_colorkey; | |
2173 | |
2174 /* check if we have to set the colorkey too */ | |
2175 if ( xv_ck_info.source == CK_SRC_SET ) | |
2176 { | |
2177 xv_atom = XInternAtom(mDisplay, "XV_COLORKEY",False); | |
2178 | |
2179 rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, vo_colorkey ); | |
2180 if ( rez != Success ) | |
2181 { | |
2182 mp_msg( MSGT_VO, MSGL_FATAL, | |
2183 "[xv common] Couldn't set colorkey!\n" ); | |
2184 return 0; // error setting colorkey | |
2185 } | |
2186 } | |
2187 } | |
2188 else | |
2189 { | |
2190 int colorkey_ret; | |
2191 | |
2192 rez=XvGetPortAttribute(mDisplay,xv_port, xv_atom, &colorkey_ret); | |
2193 if ( rez == Success ) | |
2194 { | |
2195 xv_colorkey = colorkey_ret; | |
2196 } | |
2197 else | |
2198 { | |
2199 mp_msg( MSGT_VO, MSGL_FATAL, | |
2200 "[xv common] Couldn't get colorkey!" | |
2201 "Maybe the selected Xv port has no overlay.\n" ); | |
2202 return 0; // error getting colorkey | |
2203 } | |
2204 } | |
2205 | |
15186 | 2206 xv_atom = xv_intern_atom_if_exists( "XV_AUTOPAINT_COLORKEY" ); |
2207 | |
14742 | 2208 /* should we draw the colorkey ourselves or activate autopainting? */ |
2209 if ( xv_ck_info.method == CK_METHOD_AUTOPAINT ) | |
2210 { | |
2211 rez = !Success; // reset rez to something different than Success | |
2212 | |
2213 if ( xv_atom != None ) // autopaint is supported | |
2214 { | |
2215 rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, 1 ); | |
2216 } | |
2217 | |
2218 if ( rez != Success ) | |
2219 { | |
2220 // fallback to manual colorkey drawing | |
2221 xv_ck_info.method = CK_METHOD_MANUALFILL; | |
2222 } | |
2223 } | |
15186 | 2224 else // disable colorkey autopainting if supported |
2225 { | |
2226 if ( xv_atom != None ) // we have autopaint attribute | |
2227 { | |
2228 XvSetPortAttribute( mDisplay, xv_port, xv_atom, 0 ); | |
2229 } | |
2230 } | |
14742 | 2231 } |
2232 else // do no colorkey drawing at all | |
2233 { | |
2234 xv_ck_info.method = CK_METHOD_NONE; | |
2235 } /* end: should we draw colorkey */ | |
2236 | |
21938 | 2237 /* output information about the current colorkey settings */ |
14742 | 2238 vo_xv_print_ck_info(); |
2239 | |
2240 return 1; // success | |
2241 } | |
2242 | |
2243 /** | |
2244 * \brief Draw the colorkey on the video window. | |
2245 * | |
2246 * Draws the colorkey depending on the set method ( colorkey_handling ). | |
2247 * | |
21938 | 2248 * Also draws the black bars ( when the video doesn't fit the display in |
2249 * fullscreen ) separately, so they don't overlap with the video area. | |
2250 * It doesn't call XFlush. | |
14742 | 2251 * |
2252 */ | |
24890 | 2253 void vo_xv_draw_colorkey( int32_t x, int32_t y, |
15100 | 2254 int32_t w, int32_t h ) |
14742 | 2255 { |
15100 | 2256 if( xv_ck_info.method == CK_METHOD_MANUALFILL || |
2257 xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow() | |
14742 | 2258 { |
2259 XSetForeground( mDisplay, vo_gc, xv_colorkey ); | |
2260 XFillRectangle( mDisplay, vo_window, vo_gc, | |
2261 x, y, | |
2262 w, h ); | |
2263 } | |
2264 | |
2265 /* draw black bars if needed */ | |
15100 | 2266 /* TODO! move this to vo_x11_clearwindow_part() */ |
14742 | 2267 if ( vo_fs ) |
2268 { | |
2269 XSetForeground( mDisplay, vo_gc, 0 ); | |
21938 | 2270 /* making non-overlap fills, requires 8 checks instead of 4 */ |
14742 | 2271 if ( y > 0 ) |
2272 XFillRectangle( mDisplay, vo_window, vo_gc, | |
2273 0, 0, | |
2274 vo_screenwidth, y); | |
2275 if (x > 0) | |
2276 XFillRectangle( mDisplay, vo_window, vo_gc, | |
15100 | 2277 0, 0, |
2278 x, vo_screenheight); | |
14742 | 2279 if (x + w < vo_screenwidth) |
2280 XFillRectangle( mDisplay, vo_window, vo_gc, | |
15100 | 2281 x + w, 0, |
2282 vo_screenwidth, vo_screenheight); | |
14742 | 2283 if (y + h < vo_screenheight) |
2284 XFillRectangle( mDisplay, vo_window, vo_gc, | |
2285 0, y + h, | |
15100 | 2286 vo_screenwidth, vo_screenheight); |
14742 | 2287 } |
2288 } | |
2289 | |
21938 | 2290 /** \brief Tests if a valid argument for the ck suboption was given. */ |
14742 | 2291 int xv_test_ck( void * arg ) |
2292 { | |
2293 strarg_t * strarg = (strarg_t *)arg; | |
2294 | |
15734
7e4fa8fc255c
helper functions for comparing strarg_t "strings".
reimar
parents:
15186
diff
changeset
|
2295 if ( strargcmp( strarg, "use" ) == 0 || |
7e4fa8fc255c
helper functions for comparing strarg_t "strings".
reimar
parents:
15186
diff
changeset
|
2296 strargcmp( strarg, "set" ) == 0 || |
7e4fa8fc255c
helper functions for comparing strarg_t "strings".
reimar
parents:
15186
diff
changeset
|
2297 strargcmp( strarg, "cur" ) == 0 ) |
14742 | 2298 { |
2299 return 1; | |
2300 } | |
2301 | |
2302 return 0; | |
2303 } | |
21938 | 2304 /** \brief Tests if a valid arguments for the ck-method suboption was given. */ |
14742 | 2305 int xv_test_ckm( void * arg ) |
2306 { | |
2307 strarg_t * strarg = (strarg_t *)arg; | |
2308 | |
15734
7e4fa8fc255c
helper functions for comparing strarg_t "strings".
reimar
parents:
15186
diff
changeset
|
2309 if ( strargcmp( strarg, "bg" ) == 0 || |
7e4fa8fc255c
helper functions for comparing strarg_t "strings".
reimar
parents:
15186
diff
changeset
|
2310 strargcmp( strarg, "man" ) == 0 || |
7e4fa8fc255c
helper functions for comparing strarg_t "strings".
reimar
parents:
15186
diff
changeset
|
2311 strargcmp( strarg, "auto" ) == 0 ) |
14742 | 2312 { |
2313 return 1; | |
2314 } | |
2315 | |
2316 return 0; | |
2317 } | |
2318 | |
2319 /** | |
2320 * \brief Modify the colorkey_handling var according to str | |
2321 * | |
2322 * Checks if a valid pointer ( not NULL ) to the string | |
2323 * was given. And in that case modifies the colorkey_handling | |
2324 * var to reflect the requested behaviour. | |
2325 * If nothing happens the content of colorkey_handling stays | |
2326 * the same. | |
2327 * | |
2328 * \param str Pointer to the string or NULL | |
2329 * | |
2330 */ | |
2331 void xv_setup_colorkeyhandling( char const * ck_method_str, | |
2332 char const * ck_str ) | |
2333 { | |
2334 /* check if a valid pointer to the string was passed */ | |
2335 if ( ck_str ) | |
2336 { | |
2337 if ( strncmp( ck_str, "use", 3 ) == 0 ) | |
2338 { | |
2339 xv_ck_info.source = CK_SRC_USE; | |
2340 } | |
2341 else if ( strncmp( ck_str, "set", 3 ) == 0 ) | |
2342 { | |
2343 xv_ck_info.source = CK_SRC_SET; | |
2344 } | |
2345 } | |
2346 /* check if a valid pointer to the string was passed */ | |
2347 if ( ck_method_str ) | |
2348 { | |
2349 if ( strncmp( ck_method_str, "bg", 2 ) == 0 ) | |
2350 { | |
2351 xv_ck_info.method = CK_METHOD_BACKGROUND; | |
2352 } | |
2353 else if ( strncmp( ck_method_str, "man", 3 ) == 0 ) | |
2354 { | |
2355 xv_ck_info.method = CK_METHOD_MANUALFILL; | |
2356 } | |
2357 else if ( strncmp( ck_method_str, "auto", 4 ) == 0 ) | |
2358 { | |
2359 xv_ck_info.method = CK_METHOD_AUTOPAINT; | |
2360 } | |
2361 } | |
2362 } | |
2363 | |
10359 | 2364 #endif |