Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 12754:5a2eb96bb809
Point at new XML documentation translation.
author | diego |
---|---|
date | Sat, 03 Jul 2004 02:19:14 +0000 |
parents | 162c80b2d432 |
children | 24075685789b |
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> |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
6 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
7 #include "config.h" |
5998 | 8 #include "mp_msg.h" |
6401 | 9 #include "x11_common.h" |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
10 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
11 #ifdef X11_FULLSCREEN |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
12 |
440
d19a3da6ac13
Pontscho's mixer, select, and hell-a-lot-of-stuff patch ;)
gabucino
parents:
416
diff
changeset
|
13 #include <string.h> |
32 | 14 #include <unistd.h> |
15 #include <sys/mman.h> | |
9695 | 16 #include <signal.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" |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
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 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
30 #ifdef HAVE_XDPMS |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
31 #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
|
32 #endif |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
33 |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
34 #ifdef HAVE_XINERAMA |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
35 #include <X11/extensions/Xinerama.h> |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
36 #endif |
1732 | 37 |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
38 #ifdef HAVE_XF86VM |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
39 #include <X11/extensions/xf86vmode.h> |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
40 #include <X11/XF86keysym.h> |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
41 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
42 |
10359 | 43 #ifdef HAVE_XV |
44 #include <X11/extensions/Xv.h> | |
45 #include <X11/extensions/Xvlib.h> | |
46 #endif | |
47 | |
4658 | 48 #include "../input/input.h" |
49 #include "../input/mouse.h" | |
50 | |
4798 | 51 #ifdef HAVE_NEW_GUI |
52 #include "../Gui/interface.h" | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
53 #include "../mplayer.h" |
4798 | 54 #endif |
55 | |
8660
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
56 #define WIN_LAYER_ONBOTTOM 2 |
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
57 #define WIN_LAYER_NORMAL 4 |
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
58 #define WIN_LAYER_ONTOP 6 |
8669
fd398a0b4b3b
This time the patch is fixing much more that breaking :-)
arpi
parents:
8663
diff
changeset
|
59 #define WIN_LAYER_ABOVE_DOCK 10 |
12582 | 60 |
61 int fs_layer = WIN_LAYER_ABOVE_DOCK; | |
62 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
|
63 static int old_gravity = NorthWestGravity; |
8866 | 64 |
12582 | 65 int stop_xscreensaver = 0; |
6202 | 66 |
12582 | 67 static int dpms_disabled = 0; |
68 static int timeout_save = 0; | |
69 static int kdescreensaver_was_running = 0; | |
324 | 70 |
12582 | 71 char *mDisplayName = NULL; |
72 Display *mDisplay = NULL; | |
73 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
|
74 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
|
75 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
|
76 |
3830 | 77 /* output window id */ |
12582 | 78 int WinID = -1; |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
79 int vo_mouse_autohide = 0; |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
80 int vo_wm_type = 0; |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
81 static int vo_fs_type = 0; |
12125
f4fc74a88e65
full screen flipping synchronization corrections (by Adam Tla/lka)
rathann
parents:
12123
diff
changeset
|
82 static int vo_fs_flip = 0; |
12582 | 83 char **vo_fstype_list; |
384 | 84 |
8835
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
85 /* if equal to 1 means that WM is a metacity (broken as hell) */ |
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
86 int metacity_hack = 0; |
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
87 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
88 static Atom XA_NET_SUPPORTED; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 static Atom XA_WIN_PROTOCOLS; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
96 static Atom XA_WIN_LAYER; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
97 static Atom XA_WIN_HINTS; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
98 static Atom XA_BLACKBOX_PID; |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
99 |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
100 #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
|
101 |
7435 | 102 static int vo_old_x = 0; |
103 static int vo_old_y = 0; | |
104 static int vo_old_width = 0; | |
105 static int vo_old_height = 0; | |
106 | |
4017 | 107 #ifdef HAVE_XINERAMA |
108 int xinerama_screen = 0; | |
109 int xinerama_x = 0; | |
110 int xinerama_y = 0; | |
111 #endif | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
112 #ifdef HAVE_XF86VM |
12582 | 113 XF86VidModeModeInfo **vidmodes = NULL; |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
114 XF86VidModeModeLine modeline; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
115 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
116 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
117 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
|
118 |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
119 |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
120 /* |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
121 * Sends the EWMH fullscreen state event. |
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 * action: could be on of _NET_WM_STATE_REMOVE -- remove state |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
124 * _NET_WM_STATE_ADD -- add state |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
125 * _NET_WM_STATE_TOGGLE -- toggle |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
126 */ |
12582 | 127 void vo_x11_ewmh_fullscreen(int action) |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
128 { |
12582 | 129 assert(action == _NET_WM_STATE_REMOVE || |
130 action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE); | |
131 | |
132 if (vo_fs_type & vo_wm_FULLSCREEN) | |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
133 { |
12582 | 134 XEvent xev; |
135 | |
136 /* init X event structure for _NET_WM_FULLSCREEN client msg */ | |
137 xev.xclient.type = ClientMessage; | |
138 xev.xclient.serial = 0; | |
139 xev.xclient.send_event = True; | |
140 xev.xclient.message_type = XInternAtom(mDisplay, | |
141 "_NET_WM_STATE", False); | |
142 xev.xclient.window = vo_window; | |
143 xev.xclient.format = 32; | |
144 xev.xclient.data.l[0] = action; | |
145 xev.xclient.data.l[1] = XInternAtom(mDisplay, | |
146 "_NET_WM_STATE_FULLSCREEN", | |
147 False); | |
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; | |
168 static unsigned char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |
3954 | 169 |
12582 | 170 if (WinID == 0) |
171 return; // do not hide, if we're playing at rootwin | |
172 | |
173 colormap = DefaultColormap(disp, DefaultScreen(disp)); | |
174 XAllocNamedColor(disp, colormap, "black", &black, &dummy); | |
175 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8); | |
176 no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0); | |
177 XDefineCursor(disp, win, no_ptr); | |
178 XFreeCursor(disp, no_ptr); | |
179 if (bm_no != None) | |
180 XFreePixmap(disp, bm_no); | |
384 | 181 } |
182 | |
12582 | 183 void vo_showcursor(Display * disp, Window win) |
184 { | |
185 if (WinID == 0) | |
186 return; | |
187 XDefineCursor(disp, win, 0); | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
188 } |
384 | 189 |
12582 | 190 static int x11_errorhandler(Display * display, XErrorEvent * event) |
4742 | 191 { |
192 #define MSGLEN 60 | |
193 char msg[MSGLEN]; | |
12582 | 194 |
195 XGetErrorText(display, event->error_code, (char *) &msg, MSGLEN); | |
196 | |
197 mp_msg(MSGT_VO, MSGL_ERR, "X11 error: %s\n", msg); | |
198 | |
199 mp_msg(MSGT_VO, MSGL_V, | |
200 "Type: %x, display: %x, resourceid: %x, serial: %x\n", | |
201 event->type, event->display, event->resourceid, event->serial); | |
202 mp_msg(MSGT_VO, MSGL_V, | |
203 "Error code: %x, request code: %x, minor code: %x\n", | |
204 event->error_code, event->request_code, event->minor_code); | |
205 | |
6095 | 206 abort(); |
207 //exit_player("X11 error"); | |
4742 | 208 #undef MSGLEN |
209 } | |
1732 | 210 |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
211 void fstype_help(void) |
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
212 { |
12582 | 213 mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType); |
214 | |
215 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none", | |
216 "don't set fullscreen window layer"); | |
217 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer", | |
218 "use _WIN_LAYER hint with default layer"); | |
219 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer=<0..15>", | |
220 "use _WIN_LAYER hint with a given layer number"); | |
221 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "netwm", | |
222 "force NETWM style"); | |
223 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "above", | |
224 "use _NETWM_STATE_ABOVE hint if available"); | |
225 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "below", | |
226 "use _NETWM_STATE_BELOW hint if available"); | |
227 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "fullscreen", | |
228 "use _NETWM_STATE_FULLSCREEN hint if availale"); | |
229 mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "stays_on_top", | |
230 "use _NETWM_STATE_STAYS_ON_TOP hint if available"); | |
231 mp_msg(MSGT_VO, MSGL_INFO, | |
232 "You can also negate the settings with simply putting '-' in the beginning"); | |
10695
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
233 } |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
234 |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
235 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
|
236 { |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
237 if (fstype) |
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
238 { |
12582 | 239 mp_msg(MSGT_VO, MSGL_V, "[x11] Current fstype setting honours"); |
240 if (fstype & vo_wm_LAYER) | |
241 mp_msg(MSGT_VO, MSGL_V, " LAYER"); | |
242 if (fstype & vo_wm_FULLSCREEN) | |
243 mp_msg(MSGT_VO, MSGL_V, " FULLSCREEN"); | |
244 if (fstype & vo_wm_STAYS_ON_TOP) | |
245 mp_msg(MSGT_VO, MSGL_V, " STAYS_ON_TOP"); | |
246 if (fstype & vo_wm_ABOVE) | |
247 mp_msg(MSGT_VO, MSGL_V, " ABOVE"); | |
248 if (fstype & vo_wm_BELOW) | |
249 mp_msg(MSGT_VO, MSGL_V, " BELOW"); | |
250 mp_msg(MSGT_VO, MSGL_V, " X atoms\n"); | |
251 } else | |
252 mp_msg(MSGT_VO, MSGL_V, | |
253 "[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
|
254 } |
12582 | 255 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
256 static int net_wm_support_state_test(Atom atom) |
8653 | 257 { |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
258 #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 | 259 |
260 NET_WM_STATE_TEST(FULLSCREEN); | |
261 NET_WM_STATE_TEST(ABOVE); | |
262 NET_WM_STATE_TEST(STAYS_ON_TOP); | |
263 NET_WM_STATE_TEST(BELOW); | |
264 return 0; | |
8653 | 265 } |
266 | |
12582 | 267 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
|
268 { |
12582 | 269 int format; |
270 unsigned long bytesafter; | |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
271 |
12582 | 272 return (Success == |
273 XGetWindowProperty(mDisplay, mRootWin, type, 0, 16384, False, | |
274 AnyPropertyType, &type, &format, nitems, | |
275 &bytesafter, (unsigned char **) args) | |
276 && *nitems > 0); | |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
277 } |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
278 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
279 static int vo_wm_detect(void) |
6009 | 280 { |
12582 | 281 int i; |
282 int wm = 0; | |
283 unsigned long nitems; | |
284 Atom *args = NULL; | |
285 | |
286 if (WinID >= 0) | |
287 return 0; | |
288 | |
8669
fd398a0b4b3b
This time the patch is fixing much more that breaking :-)
arpi
parents:
8663
diff
changeset
|
289 // -- supports layers |
12582 | 290 if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems)) |
291 { | |
292 mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n"); | |
293 for (i = 0; i < nitems; i++) | |
294 { | |
295 if (args[i] == XA_WIN_LAYER) | |
296 { | |
297 wm |= vo_wm_LAYER; | |
298 metacity_hack |= 1; | |
299 } else | |
300 // metacity is the only manager I know which reports support only for _WIN_LAYER | |
301 // hint in _WIN_PROTOCOLS (what's more support for it is broken) | |
302 metacity_hack |= 2; | |
303 } | |
304 XFree(args); | |
305 if (wm && (metacity_hack == 1)) | |
306 { | |
307 // metacity reports that it supports layers, but it is not really truth :-) | |
308 wm ^= vo_wm_LAYER; | |
309 mp_msg(MSGT_VO, MSGL_V, | |
310 "[x11] Using workaround for Metacity bugs.\n"); | |
311 } | |
312 } | |
6009 | 313 // --- netwm |
12582 | 314 if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems)) |
315 { | |
316 mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n"); | |
317 for (i = 0; i < nitems; i++) | |
318 wm |= net_wm_support_state_test(args[i]); | |
319 XFree(args); | |
10695
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
320 #if 0 |
12582 | 321 // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support |
322 // (in their implementation it only changes internal state of window, nothing more!!!) | |
323 if (wm & vo_wm_FULLSCREEN) | |
324 { | |
325 if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems)) | |
326 { | |
327 mp_msg(MSGT_VO, MSGL_V, | |
328 "[x11] Detected wm is a broken OpenBox.\n"); | |
329 wm ^= vo_wm_FULLSCREEN; | |
330 } | |
331 XFree(args); | |
332 } | |
10695
879ce4016b34
Commit alex's fstype patch x11_common.c3.diff with additional manpage extension.
attila
parents:
10587
diff
changeset
|
333 #endif |
12582 | 334 } |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
335 |
12582 | 336 if (wm == 0) |
337 mp_msg(MSGT_VO, MSGL_V, "[x11] Unknown wm type...\n"); | |
338 return wm; | |
339 } | |
6009 | 340 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
341 static void init_atoms(void) |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
342 { |
12582 | 343 XA_INIT(_NET_SUPPORTED); |
344 XA_INIT(_NET_WM_STATE); | |
345 XA_INIT(_NET_WM_STATE_FULLSCREEN); | |
346 XA_INIT(_NET_WM_STATE_ABOVE); | |
347 XA_INIT(_NET_WM_STATE_STAYS_ON_TOP); | |
348 XA_INIT(_NET_WM_STATE_BELOW); | |
349 XA_INIT(_NET_WM_PID); | |
350 XA_INIT(_WIN_PROTOCOLS); | |
351 XA_INIT(_WIN_LAYER); | |
352 XA_INIT(_WIN_HINTS); | |
353 XA_INIT(_BLACKBOX_PID); | |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
354 } |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
355 |
12582 | 356 int vo_init(void) |
32 | 357 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
358 // int mScreen; |
12582 | 359 int depth, bpp; |
360 unsigned int mask; | |
361 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
362 // 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
|
363 // Display * mDisplay; |
12582 | 364 XImage *mXImage = NULL; |
365 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
366 // Window mRootWin; |
12582 | 367 XWindowAttributes attribs; |
368 char *dispName; | |
32 | 369 |
12582 | 370 if (vo_depthonscreen) |
371 return 1; // already called | |
32 | 372 |
12582 | 373 XSetErrorHandler(x11_errorhandler); |
4812 | 374 |
375 #if 0 | |
12582 | 376 if (!mDisplayName) |
377 if (!(mDisplayName = getenv("DISPLAY"))) | |
378 mDisplayName = strdup(":0.0"); | |
4812 | 379 #else |
12582 | 380 dispName = XDisplayName(mDisplayName); |
4812 | 381 #endif |
382 | |
12582 | 383 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
|
384 |
12582 | 385 mDisplay = XOpenDisplay(dispName); |
386 if (!mDisplay) | |
387 { | |
388 mp_msg(MSGT_VO, MSGL_ERR, | |
389 "vo: couldn't open the X11 display (%s)!\n", dispName); | |
390 return 0; | |
391 } | |
392 mScreen = DefaultScreen(mDisplay); // Screen ID. | |
393 mRootWin = RootWindow(mDisplay, mScreen); // Root window ID. | |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
394 |
12582 | 395 init_atoms(); |
396 | |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
397 #ifdef HAVE_XINERAMA |
12582 | 398 if (XineramaIsActive(mDisplay)) |
399 { | |
400 XineramaScreenInfo *screens; | |
401 int num_screens; | |
3990 | 402 |
12582 | 403 screens = XineramaQueryScreens(mDisplay, &num_screens); |
404 if (xinerama_screen >= num_screens) | |
405 xinerama_screen = 0; | |
406 if (!vo_screenwidth) | |
407 vo_screenwidth = screens[xinerama_screen].width; | |
408 if (!vo_screenheight) | |
409 vo_screenheight = screens[xinerama_screen].height; | |
410 xinerama_x = screens[xinerama_screen].x_org; | |
411 xinerama_y = screens[xinerama_screen].y_org; | |
4017 | 412 |
12582 | 413 XFree(screens); |
414 } else | |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
415 #endif |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
416 #ifdef HAVE_XF86VM |
12582 | 417 { |
418 int clock; | |
419 | |
420 XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline); | |
421 if (!vo_screenwidth) | |
422 vo_screenwidth = modeline.hdisplay; | |
423 if (!vo_screenheight) | |
424 vo_screenheight = modeline.vdisplay; | |
425 } | |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
426 #endif |
12582 | 427 { |
428 if (!vo_screenwidth) | |
429 vo_screenwidth = DisplayWidth(mDisplay, mScreen); | |
430 if (!vo_screenheight) | |
431 vo_screenheight = DisplayHeight(mDisplay, mScreen); | |
432 } | |
433 // get color depth (from root window, or the best visual): | |
434 XGetWindowAttributes(mDisplay, mRootWin, &attribs); | |
435 depth = attribs.depth; | |
1732 | 436 |
12582 | 437 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) |
438 { | |
439 Visual *visual; | |
440 | |
441 depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual); | |
442 if (depth != -1) | |
443 mXImage = XCreateImage(mDisplay, visual, depth, ZPixmap, | |
444 0, NULL, 1, 1, 8, 1); | |
445 } else | |
446 mXImage = | |
447 XGetImage(mDisplay, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap); | |
1732 | 448 |
12582 | 449 vo_depthonscreen = depth; // display depth on screen |
1732 | 450 |
12582 | 451 // get bits/pixel from XImage structure: |
452 if (mXImage == NULL) | |
453 { | |
454 mask = 0; | |
455 } else | |
456 { | |
457 /* | |
458 * for the depth==24 case, the XImage structures might use | |
459 * 24 or 32 bits of data per pixel. The global variable | |
460 * vo_depthonscreen stores the amount of data per pixel in the | |
461 * XImage structure! | |
462 * | |
463 * Maybe we should rename vo_depthonscreen to (or add) vo_bpp? | |
464 */ | |
465 bpp = mXImage->bits_per_pixel; | |
466 if ((vo_depthonscreen + 7) / 8 != (bpp + 7) / 8) | |
467 vo_depthonscreen = bpp; // by A'rpi | |
468 mask = | |
469 mXImage->red_mask | mXImage->green_mask | mXImage->blue_mask; | |
470 mp_msg(MSGT_VO, MSGL_V, | |
471 "vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", mask, | |
472 mXImage->red_mask, mXImage->green_mask, mXImage->blue_mask); | |
473 XDestroyImage(mXImage); | |
474 } | |
475 if (((vo_depthonscreen + 7) / 8) == 2) | |
476 { | |
477 if (mask == 0x7FFF) | |
478 vo_depthonscreen = 15; | |
479 else if (mask == 0xFFFF) | |
480 vo_depthonscreen = 16; | |
481 } | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
482 // XCloseDisplay( mDisplay ); |
1447
e82fbd67ae60
better local display connection patch by Adam Tla/lka atlka@pg.gda.pl
arpi
parents:
1415
diff
changeset
|
483 /* slightly improved local display detection AST */ |
12582 | 484 if (strncmp(dispName, "unix:", 5) == 0) |
485 dispName += 4; | |
486 else if (strncmp(dispName, "localhost:", 10) == 0) | |
487 dispName += 9; | |
488 if (*dispName == ':' && atoi(dispName + 1) < 10) | |
489 mLocalDisplay = 1; | |
490 else | |
491 mLocalDisplay = 0; | |
492 mp_msg(MSGT_VO, MSGL_INFO, | |
493 "vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n", | |
494 vo_screenwidth, vo_screenheight, depth, vo_depthonscreen, | |
495 dispName, mLocalDisplay ? "local" : "remote"); | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
496 |
12582 | 497 vo_wm_type = vo_wm_detect(); |
498 | |
499 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
|
500 |
12582 | 501 fstype_dump(vo_fs_type); |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
502 |
12582 | 503 saver_off(mDisplay); |
504 return 1; | |
32 | 505 } |
506 | |
12582 | 507 void vo_uninit(void) |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
508 { |
12582 | 509 if (!mDisplay) |
510 { | |
511 mp_msg(MSGT_VO, MSGL_V, | |
512 "vo: x11 uninit called but X11 not inited..\n"); | |
513 return; | |
514 } | |
6077 | 515 // if( !vo_depthonscreen ) return; |
12582 | 516 mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n"); |
517 XSetErrorHandler(NULL); | |
518 XCloseDisplay(mDisplay); | |
519 vo_depthonscreen = 0; | |
520 mDisplay = NULL; | |
6013
7f6e02a16ac4
some bugfix, x[11|mga|v] ( fullscreen with more files )
pontscho
parents:
6009
diff
changeset
|
521 } |
4436 | 522 |
9380 | 523 #include "../osdep/keycodes.h" |
32 | 524 #include "wskeys.h" |
525 | |
526 extern void mplayer_put_key(int code); | |
527 | |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
528 #ifdef XF86XK_AudioPause |
12582 | 529 void vo_x11_putkey_ext(int keysym) |
530 { | |
531 switch (keysym) | |
532 { | |
533 case XF86XK_AudioPause: | |
534 mplayer_put_key(KEY_XF86_PAUSE); | |
535 break; | |
536 case XF86XK_AudioStop: | |
537 mplayer_put_key(KEY_XF86_STOP); | |
538 break; | |
539 case XF86XK_AudioPrev: | |
540 mplayer_put_key(KEY_XF86_PREV); | |
541 break; | |
542 case XF86XK_AudioNext: | |
543 mplayer_put_key(KEY_XF86_NEXT); | |
544 break; | |
545 default: | |
546 break; | |
547 } | |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
548 } |
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
549 #endif |
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
550 |
12582 | 551 void vo_x11_putkey(int key) |
552 { | |
553 switch (key) | |
554 { | |
555 case wsLeft: | |
556 mplayer_put_key(KEY_LEFT); | |
557 break; | |
558 case wsRight: | |
559 mplayer_put_key(KEY_RIGHT); | |
560 break; | |
561 case wsUp: | |
562 mplayer_put_key(KEY_UP); | |
563 break; | |
564 case wsDown: | |
565 mplayer_put_key(KEY_DOWN); | |
566 break; | |
567 case wsSpace: | |
568 mplayer_put_key(' '); | |
569 break; | |
570 case wsEscape: | |
571 mplayer_put_key(KEY_ESC); | |
572 break; | |
573 case wsEnter: | |
574 mplayer_put_key(KEY_ENTER); | |
575 break; | |
576 case wsBackSpace: | |
577 mplayer_put_key(KEY_BS); | |
578 break; | |
579 case wsDelete: | |
580 mplayer_put_key(KEY_DELETE); | |
581 break; | |
582 case wsInsert: | |
583 mplayer_put_key(KEY_INSERT); | |
584 break; | |
585 case wsHome: | |
586 mplayer_put_key(KEY_HOME); | |
587 break; | |
588 case wsEnd: | |
589 mplayer_put_key(KEY_END); | |
590 break; | |
591 case wsPageUp: | |
592 mplayer_put_key(KEY_PAGE_UP); | |
593 break; | |
594 case wsPageDown: | |
595 mplayer_put_key(KEY_PAGE_DOWN); | |
596 break; | |
597 case wsF1: | |
598 mplayer_put_key(KEY_F + 1); | |
599 break; | |
600 case wsF2: | |
601 mplayer_put_key(KEY_F + 2); | |
602 break; | |
603 case wsF3: | |
604 mplayer_put_key(KEY_F + 3); | |
605 break; | |
606 case wsF4: | |
607 mplayer_put_key(KEY_F + 4); | |
608 break; | |
609 case wsF5: | |
610 mplayer_put_key(KEY_F + 5); | |
611 break; | |
612 case wsF6: | |
613 mplayer_put_key(KEY_F + 6); | |
614 break; | |
615 case wsF7: | |
616 mplayer_put_key(KEY_F + 7); | |
617 break; | |
618 case wsF8: | |
619 mplayer_put_key(KEY_F + 8); | |
620 break; | |
621 case wsF9: | |
622 mplayer_put_key(KEY_F + 9); | |
623 break; | |
624 case wsF10: | |
625 mplayer_put_key(KEY_F + 10); | |
626 break; | |
627 case wsF11: | |
628 mplayer_put_key(KEY_F + 11); | |
629 break; | |
630 case wsF12: | |
631 mplayer_put_key(KEY_F + 12); | |
632 break; | |
633 case wsq: | |
634 case wsQ: | |
635 mplayer_put_key('q'); | |
636 break; | |
637 case wsp: | |
638 case wsP: | |
639 mplayer_put_key('p'); | |
640 break; | |
641 case wsMinus: | |
642 case wsGrayMinus: | |
643 mplayer_put_key('-'); | |
644 break; | |
645 case wsPlus: | |
646 case wsGrayPlus: | |
647 mplayer_put_key('+'); | |
648 break; | |
649 case wsGrayMul: | |
650 case wsMul: | |
651 mplayer_put_key('*'); | |
652 break; | |
653 case wsGrayDiv: | |
654 case wsDiv: | |
655 mplayer_put_key('/'); | |
656 break; | |
657 case wsLess: | |
658 mplayer_put_key('<'); | |
659 break; | |
660 case wsMore: | |
661 mplayer_put_key('>'); | |
662 break; | |
663 case wsGray0: | |
664 mplayer_put_key(KEY_KP0); | |
665 break; | |
666 case wsGrayEnd: | |
667 case wsGray1: | |
668 mplayer_put_key(KEY_KP1); | |
669 break; | |
670 case wsGrayDown: | |
671 case wsGray2: | |
672 mplayer_put_key(KEY_KP2); | |
673 break; | |
674 case wsGrayPgDn: | |
675 case wsGray3: | |
676 mplayer_put_key(KEY_KP3); | |
677 break; | |
678 case wsGrayLeft: | |
679 case wsGray4: | |
680 mplayer_put_key(KEY_KP4); | |
681 break; | |
682 case wsGray5Dup: | |
683 case wsGray5: | |
684 mplayer_put_key(KEY_KP5); | |
685 break; | |
686 case wsGrayRight: | |
687 case wsGray6: | |
688 mplayer_put_key(KEY_KP6); | |
689 break; | |
690 case wsGrayHome: | |
691 case wsGray7: | |
692 mplayer_put_key(KEY_KP7); | |
693 break; | |
694 case wsGrayUp: | |
695 case wsGray8: | |
696 mplayer_put_key(KEY_KP8); | |
697 break; | |
698 case wsGrayPgUp: | |
699 case wsGray9: | |
700 mplayer_put_key(KEY_KP9); | |
701 break; | |
702 case wsGrayDecimal: | |
703 mplayer_put_key(KEY_KPDEC); | |
704 break; | |
705 case wsGrayInsert: | |
706 mplayer_put_key(KEY_KPINS); | |
707 break; | |
708 case wsGrayDelete: | |
709 mplayer_put_key(KEY_KPDEL); | |
710 break; | |
711 case wsGrayEnter: | |
712 mplayer_put_key(KEY_KPENTER); | |
713 break; | |
714 case wsm: | |
715 case wsM: | |
716 mplayer_put_key('m'); | |
717 break; | |
718 case wso: | |
719 case wsO: | |
720 mplayer_put_key('o'); | |
721 break; | |
10936
51bc09f2977c
Get more keys from X window (punctuation, etc.) Hopefully, all alnum keys
lumag
parents:
10920
diff
changeset
|
722 |
12582 | 723 case wsGrave: |
724 mplayer_put_key('`'); | |
725 break; | |
726 case wsTilde: | |
727 mplayer_put_key('~'); | |
728 break; | |
729 case wsExclSign: | |
730 mplayer_put_key('!'); | |
731 break; | |
732 case wsAt: | |
733 mplayer_put_key('@'); | |
734 break; | |
735 case wsHash: | |
736 mplayer_put_key('#'); | |
737 break; | |
738 case wsDollar: | |
739 mplayer_put_key('$'); | |
740 break; | |
741 case wsPercent: | |
742 mplayer_put_key('%'); | |
743 break; | |
744 case wsCircumflex: | |
745 mplayer_put_key('^'); | |
746 break; | |
747 case wsAmpersand: | |
748 mplayer_put_key('&'); | |
749 break; | |
750 case wsobracket: | |
751 mplayer_put_key('('); | |
752 break; | |
753 case wscbracket: | |
754 mplayer_put_key(')'); | |
755 break; | |
756 case wsUnder: | |
757 mplayer_put_key('_'); | |
758 break; | |
759 case wsocbracket: | |
760 mplayer_put_key('{'); | |
761 break; | |
762 case wsccbracket: | |
763 mplayer_put_key('}'); | |
764 break; | |
765 case wsColon: | |
766 mplayer_put_key(':'); | |
767 break; | |
768 case wsSemicolon: | |
769 mplayer_put_key(';'); | |
770 break; | |
771 case wsDblQuote: | |
772 mplayer_put_key('\"'); | |
773 break; | |
774 case wsAcute: | |
775 mplayer_put_key('\''); | |
776 break; | |
777 case wsComma: | |
778 mplayer_put_key(','); | |
779 break; | |
780 case wsPoint: | |
781 mplayer_put_key('.'); | |
782 break; | |
783 case wsQuestSign: | |
784 mplayer_put_key('?'); | |
785 break; | |
786 case wsBSlash: | |
787 mplayer_put_key('\\'); | |
788 break; | |
789 case wsPipe: | |
790 mplayer_put_key('|'); | |
791 break; | |
792 case wsEqual: | |
793 mplayer_put_key('='); | |
794 break; | |
795 case wsosbrackets: | |
796 mplayer_put_key('['); | |
797 break; | |
798 case wscsbrackets: | |
799 mplayer_put_key(']'); | |
800 break; | |
10936
51bc09f2977c
Get more keys from X window (punctuation, etc.) Hopefully, all alnum keys
lumag
parents:
10920
diff
changeset
|
801 |
51bc09f2977c
Get more keys from X window (punctuation, etc.) Hopefully, all alnum keys
lumag
parents:
10920
diff
changeset
|
802 |
12582 | 803 default: |
804 if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') || | |
805 (key >= '0' && key <= '9')) | |
806 mplayer_put_key(key); | |
807 } | |
369 | 808 |
32 | 809 } |
810 | |
811 | |
812 // ----- Motif header: ------- | |
813 | |
1236 | 814 #define MWM_HINTS_FUNCTIONS (1L << 0) |
815 #define MWM_HINTS_DECORATIONS (1L << 1) | |
816 #define MWM_HINTS_INPUT_MODE (1L << 2) | |
817 #define MWM_HINTS_STATUS (1L << 3) | |
818 | |
819 #define MWM_FUNC_ALL (1L << 0) | |
820 #define MWM_FUNC_RESIZE (1L << 1) | |
821 #define MWM_FUNC_MOVE (1L << 2) | |
822 #define MWM_FUNC_MINIMIZE (1L << 3) | |
823 #define MWM_FUNC_MAXIMIZE (1L << 4) | |
824 #define MWM_FUNC_CLOSE (1L << 5) | |
825 | |
826 #define MWM_DECOR_ALL (1L << 0) | |
827 #define MWM_DECOR_BORDER (1L << 1) | |
828 #define MWM_DECOR_RESIZEH (1L << 2) | |
829 #define MWM_DECOR_TITLE (1L << 3) | |
830 #define MWM_DECOR_MENU (1L << 4) | |
831 #define MWM_DECOR_MINIMIZE (1L << 5) | |
832 #define MWM_DECOR_MAXIMIZE (1L << 6) | |
833 | |
834 #define MWM_INPUT_MODELESS 0 | |
835 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 | |
836 #define MWM_INPUT_SYSTEM_MODAL 2 | |
837 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 | |
838 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL | |
839 | |
840 #define MWM_TEAROFF_WINDOW (1L<<0) | |
32 | 841 |
842 typedef struct | |
843 { | |
12582 | 844 long flags; |
845 long functions; | |
846 long decorations; | |
847 long input_mode; | |
848 long state; | |
32 | 849 } MotifWmHints; |
850 | |
851 extern MotifWmHints vo_MotifWmHints; | |
12582 | 852 extern Atom vo_MotifHints; |
853 extern int vo_depthonscreen; | |
854 extern int vo_screenwidth; | |
855 extern int vo_screenheight; | |
32 | 856 |
12582 | 857 static MotifWmHints vo_MotifWmHints; |
858 static Atom vo_MotifHints = None; | |
32 | 859 |
12582 | 860 void vo_x11_decoration(Display * vo_Display, Window w, int d) |
32 | 861 { |
12582 | 862 static unsigned int olddecor = MWM_DECOR_ALL; |
863 static unsigned int oldfuncs = | |
864 MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE | | |
865 MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; | |
866 Atom mtype; | |
867 int mformat; | |
868 unsigned long mn, mb; | |
869 | |
870 if (!WinID) | |
871 return; | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
872 |
12582 | 873 if (vo_fsmode & 8) |
874 { | |
875 XSetTransientForHint(vo_Display, w, | |
876 RootWindow(vo_Display, mScreen)); | |
877 } | |
878 | |
879 vo_MotifHints = XInternAtom(vo_Display, "_MOTIF_WM_HINTS", 0); | |
880 if (vo_MotifHints != None) | |
881 { | |
882 if (!d) | |
883 { | |
884 MotifWmHints *mhints = NULL; | |
1415 | 885 |
12582 | 886 XGetWindowProperty(vo_Display, w, vo_MotifHints, 0, 20, False, |
887 vo_MotifHints, &mtype, &mformat, &mn, | |
888 &mb, (unsigned char **) &mhints); | |
889 if (mhints) | |
890 { | |
891 if (mhints->flags & MWM_HINTS_DECORATIONS) | |
892 olddecor = mhints->decorations; | |
893 if (mhints->flags & MWM_HINTS_FUNCTIONS) | |
894 oldfuncs = mhints->functions; | |
895 XFree(mhints); | |
896 } | |
897 } | |
12096 | 898 |
12582 | 899 memset(&vo_MotifWmHints, 0, sizeof(MotifWmHints)); |
900 vo_MotifWmHints.flags = | |
901 MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; | |
902 if (d) | |
903 { | |
904 vo_MotifWmHints.functions = oldfuncs; | |
905 d = olddecor; | |
906 } | |
4993 | 907 #if 0 |
12582 | 908 vo_MotifWmHints.decorations = |
909 d | ((vo_fsmode & 2) ? 0 : MWM_DECOR_MENU); | |
4993 | 910 #else |
12582 | 911 vo_MotifWmHints.decorations = |
912 d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0); | |
4993 | 913 #endif |
12582 | 914 XChangeProperty(vo_Display, w, vo_MotifHints, vo_MotifHints, 32, |
915 PropModeReplace, | |
916 (unsigned char *) &vo_MotifWmHints, | |
917 (vo_fsmode & 4) ? 4 : 5); | |
918 } | |
32 | 919 } |
920 | |
12582 | 921 void vo_x11_classhint(Display * display, Window window, char *name) |
922 { | |
923 XClassHint wmClass; | |
924 pid_t pid = getpid(); | |
925 | |
926 wmClass.res_name = name; | |
927 wmClass.res_class = "MPlayer"; | |
928 XSetClassHint(display, window, &wmClass); | |
929 XChangeProperty(display, window, XA_NET_WM_PID, XA_CARDINAL, 32, | |
930 PropModeReplace, (unsigned char *) &pid, 1); | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
931 } |
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
932 |
12582 | 933 Window vo_window = None; |
934 GC vo_gc = NULL; | |
935 GC f_gc = NULL; | |
4993 | 936 XSizeHints vo_hint; |
4795 | 937 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1501
diff
changeset
|
938 #ifdef HAVE_NEW_GUI |
12582 | 939 void vo_setwindow(Window w, GC g) |
940 { | |
941 vo_window = w; | |
942 vo_gc = g; | |
943 } | |
723 | 944 #endif |
945 | |
6095 | 946 void vo_x11_uninit() |
4437 | 947 { |
7111 | 948 saver_on(mDisplay); |
12582 | 949 if (vo_window != None) |
950 vo_showcursor(mDisplay, vo_window); | |
4742 | 951 |
12582 | 952 if (f_gc) |
953 { | |
954 XFreeGC(mDisplay, f_gc); | |
955 f_gc = NULL; | |
956 } | |
4437 | 957 #ifdef HAVE_NEW_GUI |
958 /* destroy window only if it's not controlled by GUI */ | |
12582 | 959 if (!use_gui) |
4437 | 960 #endif |
961 { | |
12582 | 962 if (vo_gc) |
963 { | |
964 XSetBackground(mDisplay, vo_gc, 0); | |
965 XFreeGC(mDisplay, vo_gc); | |
966 vo_gc = NULL; | |
967 } | |
968 if (vo_window != None) | |
969 { | |
970 XClearWindow(mDisplay, vo_window); | |
971 if (WinID < 0) | |
972 { | |
973 XEvent xev; | |
974 | |
975 XUnmapWindow(mDisplay, vo_window); | |
976 XDestroyWindow(mDisplay, vo_window); | |
977 do | |
978 { | |
979 XNextEvent(mDisplay, &xev); | |
980 } | |
981 while (xev.type != DestroyNotify | |
982 || xev.xdestroywindow.event != vo_window); | |
983 } | |
984 vo_window = None; | |
985 } | |
986 vo_fs = 0; | |
987 vo_old_width = vo_old_height = 0; | |
4437 | 988 } |
989 } | |
990 | |
12582 | 991 int vo_mouse_timer_const = 30; |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5538
diff
changeset
|
992 static int vo_mouse_counter = 30; |
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5538
diff
changeset
|
993 |
12582 | 994 int vo_x11_check_events(Display * mydisplay) |
995 { | |
996 int ret = 0; | |
997 XEvent Event; | |
998 char buf[100]; | |
999 KeySym keySym; | |
1000 static XComposeStatus stat; | |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5538
diff
changeset
|
1001 |
32 | 1002 // unsigned long vo_KeyTable[512]; |
1003 | |
12582 | 1004 if ((vo_mouse_autohide) && (--vo_mouse_counter == 0)) |
1005 vo_hidecursor(mydisplay, vo_window); | |
6095 | 1006 |
12582 | 1007 while (XPending(mydisplay)) |
1008 { | |
1009 XNextEvent(mydisplay, &Event); | |
1010 #ifdef HAVE_NEW_GUI | |
1011 if (use_gui) | |
1012 { | |
1013 guiGetEvent(0, (char *) &Event); | |
1014 if (vo_window != Event.xany.window) | |
1015 continue; | |
1016 } | |
1017 #endif | |
6095 | 1018 // printf("\rEvent.type=%X \n",Event.type); |
12582 | 1019 switch (Event.type) |
1020 { | |
1021 case Expose: | |
1022 ret |= VO_EVENT_EXPOSE; | |
1023 break; | |
1024 case ConfigureNotify: | |
1025 // if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break; | |
1026 // if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break; | |
1027 if (vo_window == None) | |
1028 break; | |
1029 vo_dwidth = Event.xconfigure.width; | |
1030 vo_dheight = Event.xconfigure.height; | |
4812 | 1031 #if 0 |
12582 | 1032 /* when resizing, x and y are zero :( */ |
1033 vo_dx = Event.xconfigure.x; | |
1034 vo_dy = Event.xconfigure.y; | |
4812 | 1035 #else |
12582 | 1036 { |
1037 Window root; | |
1038 int foo; | |
1039 Window win; | |
1040 | |
1041 XGetGeometry(mydisplay, vo_window, &root, &foo, &foo, | |
1042 &foo /*width */ , &foo /*height */ , &foo, | |
1043 &foo); | |
1044 XTranslateCoordinates(mydisplay, vo_window, root, 0, 0, | |
1045 &vo_dx, &vo_dy, &win); | |
1046 } | |
1047 #endif | |
1048 ret |= VO_EVENT_RESIZE; | |
1049 break; | |
1050 case KeyPress: | |
1051 { | |
1052 int key; | |
1053 | |
1054 XLookupString(&Event.xkey, buf, sizeof(buf), &keySym, | |
1055 &stat); | |
1056 #ifdef XF86XK_AudioPause | |
1057 vo_x11_putkey_ext(keySym); | |
1058 #endif | |
1059 key = | |
1060 ((keySym & 0xff00) != | |
1061 0 ? ((keySym & 0x00ff) + 256) : (keySym)); | |
1062 #ifdef HAVE_NEW_GUI | |
1063 if ((use_gui) && (key == wsEnter)) | |
1064 break; | |
4812 | 1065 #endif |
12582 | 1066 vo_x11_putkey(key); |
1067 ret |= VO_EVENT_KEYPRESS; | |
1068 } | |
1069 break; | |
1070 case MotionNotify: | |
1071 if (vo_mouse_autohide) | |
1072 { | |
1073 vo_showcursor(mydisplay, vo_window); | |
1074 vo_mouse_counter = vo_mouse_timer_const; | |
1075 } | |
1076 break; | |
1077 case ButtonPress: | |
1078 if (vo_mouse_autohide) | |
1079 { | |
1080 vo_showcursor(mydisplay, vo_window); | |
1081 vo_mouse_counter = vo_mouse_timer_const; | |
1082 } | |
1083 // Ignore mouse whell press event | |
1084 if (Event.xbutton.button > 3) | |
1085 { | |
1086 mplayer_put_key(MOUSE_BTN0 + Event.xbutton.button - 1); | |
1087 break; | |
1088 } | |
1089 #ifdef HAVE_NEW_GUI | |
1090 // Ignor mouse button 1 - 3 under gui | |
1091 if (use_gui && (Event.xbutton.button >= 1) | |
1092 && (Event.xbutton.button <= 3)) | |
1093 break; | |
1094 #endif | |
1095 mplayer_put_key((MOUSE_BTN0 + Event.xbutton.button - | |
1096 1) | MP_KEY_DOWN); | |
1097 break; | |
1098 case ButtonRelease: | |
1099 if (vo_mouse_autohide) | |
1100 { | |
1101 vo_showcursor(mydisplay, vo_window); | |
1102 vo_mouse_counter = vo_mouse_timer_const; | |
1103 } | |
1104 #ifdef HAVE_NEW_GUI | |
1105 // Ignor mouse button 1 - 3 under gui | |
1106 if (use_gui && (Event.xbutton.button >= 1) | |
1107 && (Event.xbutton.button <= 3)) | |
1108 break; | |
1109 #endif | |
1110 mplayer_put_key(MOUSE_BTN0 + Event.xbutton.button - 1); | |
1111 break; | |
1112 case PropertyNotify: | |
1113 { | |
1114 char *name = | |
1115 XGetAtomName(mydisplay, Event.xproperty.atom); | |
1116 | |
1117 if (!name) | |
1118 break; | |
1119 | |
6046 | 1120 // fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",vo_window,name,Event.xproperty.atom ); |
12582 | 1121 |
1122 XFree(name); | |
1123 } | |
1124 break; | |
1125 case MapNotify: | |
1126 vo_hint.win_gravity = old_gravity; | |
1127 XSetWMNormalHints(mDisplay, vo_window, &vo_hint); | |
1128 vo_fs_flip = 0; | |
1129 break; | |
1130 } | |
1131 } | |
1132 return ret; | |
32 | 1133 } |
1134 | |
12582 | 1135 void vo_x11_sizehint(int x, int y, int width, int height, int max) |
4993 | 1136 { |
12582 | 1137 vo_hint.flags = PPosition | PSize | PWinGravity; |
1138 if (vo_keepaspect) | |
1139 { | |
1140 vo_hint.flags |= PAspect; | |
1141 vo_hint.min_aspect.x = width; | |
1142 vo_hint.min_aspect.y = height; | |
1143 vo_hint.max_aspect.x = width; | |
1144 vo_hint.max_aspect.y = height; | |
1145 } | |
8692
604f0cde816c
X11 window aspect patch by Arnaud Boulan <boulan@iie.cnam.fr>
attila
parents:
8676
diff
changeset
|
1146 |
12582 | 1147 vo_hint.x = x; |
1148 vo_hint.y = y; | |
1149 vo_hint.width = width; | |
1150 vo_hint.height = height; | |
1151 if (max) | |
1152 { | |
1153 vo_hint.max_width = width; | |
1154 vo_hint.max_height = height; | |
1155 vo_hint.flags |= PMaxSize; | |
1156 } else | |
1157 { | |
1158 vo_hint.max_width = 0; | |
1159 vo_hint.max_height = 0; | |
1160 } | |
11995 | 1161 |
12582 | 1162 // set min height/width to 4 to avoid off by one errors |
1163 // and because mga_vid requires a minial size of 4 pixel | |
1164 vo_hint.min_width = vo_hint.min_height = 4; | |
1165 vo_hint.flags |= PMinSize; | |
11995 | 1166 |
12582 | 1167 vo_hint.win_gravity = StaticGravity; |
1168 XSetWMNormalHints(mDisplay, vo_window, &vo_hint); | |
4993 | 1169 } |
1170 | |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
1171 static int vo_x11_get_gnome_layer(Display * mDisplay, Window win) |
8866 | 1172 { |
12582 | 1173 Atom type; |
1174 int format; | |
1175 unsigned long nitems; | |
1176 unsigned long bytesafter; | |
1177 unsigned short *args = NULL; | |
8866 | 1178 |
12582 | 1179 if (XGetWindowProperty(mDisplay, win, XA_WIN_LAYER, 0, 16384, |
1180 False, AnyPropertyType, &type, &format, &nitems, | |
1181 &bytesafter, | |
1182 (unsigned char **) &args) == Success | |
1183 && nitems > 0 && args) | |
1184 { | |
1185 mp_msg(MSGT_VO, MSGL_V, "[x11] original window layer is %d.\n", | |
1186 *args); | |
1187 return *args; | |
1188 } | |
1189 return WIN_LAYER_NORMAL; | |
8866 | 1190 } |
1191 | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1192 // |
12582 | 1193 Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot, |
1194 Visual * vis, int x, int y, | |
1195 unsigned int width, unsigned int height, | |
1196 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
|
1197 { |
12582 | 1198 unsigned long xswamask = CWBackingStore | CWBorderPixel; |
1199 XSetWindowAttributes xswa; | |
1200 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
|
1201 |
12582 | 1202 if (col_map != CopyFromParent) |
1203 { | |
1204 xswa.colormap = col_map; | |
1205 xswamask |= CWColormap; | |
1206 } | |
1207 xswa.background_pixel = 0; | |
1208 xswa.border_pixel = 0; | |
1209 xswa.backing_store = Always; | |
1210 xswa.bit_gravity = StaticGravity; | |
1211 | |
1212 ret_win = | |
1213 XCreateWindow(mDisplay, mRootWin, x, y, width, height, 0, depth, | |
1214 CopyFromParent, vis, xswamask, &xswa); | |
1215 if (!f_gc) | |
1216 f_gc = XCreateGC(mDisplay, ret_win, 0, 0); | |
1217 XSetForeground(mDisplay, f_gc, 0); | |
1218 | |
1219 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
|
1220 } |
12582 | 1221 |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1222 |
12582 | 1223 void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window, |
1224 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
|
1225 { |
12582 | 1226 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
|
1227 |
12582 | 1228 if (!f_gc) |
1229 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
|
1230 |
12582 | 1231 u_dheight = use_fs ? vo_screenheight : vo_dheight; |
1232 u_dwidth = use_fs ? vo_screenwidth : vo_dwidth; | |
1233 if ((u_dheight <= img_height) && (u_dwidth <= img_width)) | |
1234 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
|
1235 |
12582 | 1236 left_ov = (u_dheight - img_height) / 2; |
1237 left_ov2 = (u_dwidth - img_width) / 2; | |
1238 | |
1239 XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, u_dwidth, left_ov); | |
1240 XFillRectangle(mDisplay, vo_window, f_gc, 0, u_dheight - left_ov - 1, | |
1241 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
|
1242 |
12582 | 1243 if (u_dwidth > img_width) |
1244 { | |
1245 XFillRectangle(mDisplay, vo_window, f_gc, 0, left_ov, left_ov2, | |
1246 img_height); | |
1247 XFillRectangle(mDisplay, vo_window, f_gc, u_dwidth - left_ov2 - 1, | |
1248 left_ov, left_ov2, img_height); | |
1249 } | |
1250 | |
1251 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
|
1252 } |
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1253 |
12582 | 1254 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
|
1255 { |
12582 | 1256 if (!f_gc) |
1257 return; | |
1258 XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, vo_screenwidth, | |
1259 vo_screenheight); | |
1260 // | |
1261 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
|
1262 } |
12582 | 1263 |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10754
diff
changeset
|
1264 |
12582 | 1265 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
|
1266 { |
12582 | 1267 if (WinID >= 0) |
1268 return; | |
8864 | 1269 |
12582 | 1270 if (vo_fs_type & vo_wm_LAYER) |
1271 { | |
1272 XClientMessageEvent xev; | |
1273 | |
1274 if (!orig_layer) | |
1275 orig_layer = vo_x11_get_gnome_layer(mDisplay, vo_window); | |
8866 | 1276 |
12582 | 1277 memset(&xev, 0, sizeof(xev)); |
1278 xev.type = ClientMessage; | |
1279 xev.display = mDisplay; | |
1280 xev.window = vo_window; | |
1281 xev.message_type = XA_WIN_LAYER; | |
1282 xev.format = 32; | |
1283 xev.data.l[0] = layer ? fs_layer : orig_layer; // if not fullscreen, stay on default layer | |
1284 xev.data.l[1] = CurrentTime; | |
1285 mp_msg(MSGT_VO, MSGL_V, | |
1286 "[x11] Layered style stay on top (layer %d).\n", | |
1287 xev.data.l[0]); | |
1288 XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask, | |
1289 (XEvent *) & xev); | |
1290 } else if (vo_fs_type & vo_wm_NETWM) | |
1291 { | |
1292 XClientMessageEvent xev; | |
1293 char *state; | |
8645 | 1294 |
12582 | 1295 memset(&xev, 0, sizeof(xev)); |
1296 xev.type = ClientMessage; | |
1297 xev.message_type = XA_NET_WM_STATE; | |
1298 xev.display = mDisplay; | |
1299 xev.window = vo_window; | |
1300 xev.format = 32; | |
1301 xev.data.l[0] = layer; | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1302 |
12582 | 1303 if (vo_fs_type & vo_wm_STAYS_ON_TOP) |
1304 xev.data.l[1] = XA_NET_WM_STATE_STAYS_ON_TOP; | |
1305 else if (vo_fs_type & vo_wm_ABOVE) | |
1306 xev.data.l[1] = XA_NET_WM_STATE_ABOVE; | |
1307 else if (vo_fs_type & vo_wm_FULLSCREEN) | |
1308 xev.data.l[1] = XA_NET_WM_STATE_FULLSCREEN; | |
1309 else if (vo_fs_type & vo_wm_BELOW) | |
1310 // This is not fallback. We can safely assume that situation where | |
1311 // only NETWM_STATE_BELOW is supported and others not, doesn't exist. | |
1312 xev.data.l[1] = XA_NET_WM_STATE_BELOW; | |
1313 | |
1314 XSendEvent(mDisplay, mRootWin, False, SubstructureRedirectMask, | |
1315 (XEvent *) & xev); | |
1316 state = XGetAtomName(mDisplay, xev.data.l[1]); | |
1317 mp_msg(MSGT_VO, MSGL_V, | |
1318 "[x11] NET style stay on top (layer %d). Using state %s.\n", | |
1319 layer, state); | |
1320 XFree(state); | |
1321 } | |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
1322 } |
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5981
diff
changeset
|
1323 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
1324 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
|
1325 { |
12582 | 1326 int i; |
1327 int type = supported; | |
1328 | |
1329 if (vo_fstype_list) | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1330 { |
12582 | 1331 i = 0; |
1332 for (i = 0; vo_fstype_list[i]; i++) | |
1333 { | |
1334 int neg = 0; | |
1335 char *arg = vo_fstype_list[i]; | |
1336 | |
1337 if (vo_fstype_list[i][0] == '-') | |
1338 { | |
1339 neg = 1; | |
1340 arg = vo_fstype_list[i] + 1; | |
1341 } | |
1342 | |
1343 if (!strncmp(arg, "layer", 5)) | |
1344 { | |
1345 if (!neg && (arg[5] == '=')) | |
1346 { | |
1347 char *endptr = NULL; | |
1348 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
|
1349 |
12582 | 1350 if (endptr && *endptr == '\0' && layer >= 0 |
1351 && layer <= 15) | |
1352 fs_layer = layer; | |
1353 } | |
1354 if (neg) | |
1355 type &= ~vo_wm_LAYER; | |
1356 else | |
1357 type |= vo_wm_LAYER; | |
1358 } else if (!strcmp(arg, "above")) | |
1359 { | |
1360 if (neg) | |
1361 type &= ~vo_wm_ABOVE; | |
1362 else | |
1363 type |= vo_wm_ABOVE; | |
1364 } else if (!strcmp(arg, "fullscreen")) | |
1365 { | |
1366 if (neg) | |
1367 type &= ~vo_wm_FULLSCREEN; | |
1368 else | |
1369 type |= vo_wm_FULLSCREEN; | |
1370 } else if (!strcmp(arg, "stays_on_top")) | |
1371 { | |
1372 if (neg) | |
1373 type &= ~vo_wm_STAYS_ON_TOP; | |
1374 else | |
1375 type |= vo_wm_STAYS_ON_TOP; | |
1376 } else if (!strcmp(arg, "below")) | |
1377 { | |
1378 if (neg) | |
1379 type &= ~vo_wm_BELOW; | |
1380 else | |
1381 type |= vo_wm_BELOW; | |
1382 } else if (!strcmp(arg, "netwm")) | |
1383 { | |
1384 if (neg) | |
1385 type &= ~vo_wm_NETWM; | |
1386 else | |
1387 type |= vo_wm_NETWM; | |
1388 } else if (!strcmp(arg, "none")) | |
1389 return 0; | |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1390 } |
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
1391 } |
5919 | 1392 |
12582 | 1393 return type; |
4981 | 1394 } |
1395 | |
12582 | 1396 void vo_x11_fullscreen(void) |
11542 | 1397 { |
12582 | 1398 int x, y, w, h; |
1399 | |
1400 if (WinID >= 0 || vo_fs_flip) | |
1401 return; | |
1402 | |
1403 if (vo_fs) | |
1404 { | |
1405 // fs->win | |
1406 vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH | |
1407 | |
1408 if (vo_dwidth != vo_screenwidth && vo_dheight != vo_screenheight) | |
1409 return; | |
1410 vo_fs = VO_FALSE; | |
1411 x = vo_old_x; | |
1412 y = vo_old_y; | |
1413 w = vo_old_width; | |
1414 h = vo_old_height; | |
1415 } else | |
1416 { | |
1417 // win->fs | |
1418 vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH | |
1419 | |
1420 if (vo_old_width && | |
1421 (vo_dwidth == vo_screenwidth && vo_dwidth != vo_old_width) && | |
1422 (vo_dheight == vo_screenheight && vo_dheight != vo_old_height)) | |
1423 return; | |
1424 vo_fs = VO_TRUE; | |
1425 vo_old_x = vo_dx; | |
1426 vo_old_y = vo_dy; | |
1427 vo_old_width = vo_dwidth; | |
1428 vo_old_height = vo_dheight; | |
1429 x = 0; | |
1430 y = 0; | |
1431 w = vo_screenwidth; | |
1432 h = vo_screenheight; | |
11542 | 1433 |
12582 | 1434 } |
1435 { | |
1436 long dummy; | |
1437 | |
1438 XGetWMNormalHints(mDisplay, vo_window, &vo_hint, &dummy); | |
1439 if (!(vo_hint.flags & PWinGravity)) | |
1440 old_gravity = NorthWestGravity; | |
1441 else | |
1442 old_gravity = vo_hint.win_gravity; | |
1443 } | |
1444 if (vo_wm_type == 0 && !(vo_fsmode & 16)) | |
1445 { | |
1446 XUnmapWindow(mDisplay, vo_window); // required for MWM | |
1447 XWithdrawWindow(mDisplay, vo_window, mScreen); | |
1448 vo_fs_flip = 1; | |
1449 } | |
1450 | |
1451 vo_x11_decoration(mDisplay, vo_window, (vo_fs) ? 0 : 1); | |
1452 vo_x11_sizehint(x, y, w, h, 0); | |
1453 vo_x11_setlayer(mDisplay, vo_window, vo_fs); | |
1454 | |
1455 if ((!(vo_fs)) & vo_ontop) | |
1456 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
1457 | |
1458 XMoveResizeWindow(mDisplay, vo_window, x, y, w, h); | |
1459 #ifdef HAVE_XINERAMA | |
1460 vo_x11_xinerama_move(mDisplay, vo_window); | |
1461 #endif | |
1462 XMapRaised(mDisplay, vo_window); | |
1463 XRaiseWindow(mDisplay, vo_window); | |
1464 XFlush(mDisplay); | |
1465 } | |
1466 | |
1467 void vo_x11_ontop(void) | |
1468 { | |
1469 vo_ontop = (!(vo_ontop)); | |
1470 | |
1471 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 1472 } |
1473 | |
9695 | 1474 /* |
1475 * XScreensaver stuff | |
1476 */ | |
1477 | |
1478 static int got_badwindow; | |
1479 static XErrorHandler old_handler; | |
1480 | |
12582 | 1481 static int badwindow_handler(Display * dpy, XErrorEvent * error) |
9695 | 1482 { |
1483 if (error->error_code != BadWindow) | |
12582 | 1484 return (*old_handler) (dpy, error); |
9695 | 1485 |
1486 got_badwindow = True; | |
1487 return 0; | |
1488 } | |
1489 | |
12582 | 1490 static Window find_xscreensaver_window(Display * dpy) |
9695 | 1491 { |
1492 int i; | |
1493 Window root = RootWindowOfScreen(DefaultScreenOfDisplay(dpy)); | |
1494 Window root2, parent, *kids; | |
1495 Window retval = 0; | |
1496 Atom xs_version; | |
1497 unsigned int nkids = 0; | |
1498 | |
1499 xs_version = XInternAtom(dpy, "_SCREENSAVER_VERSION", True); | |
1500 | |
1501 if (!(xs_version != None && | |
1502 XQueryTree(dpy, root, &root2, &parent, &kids, &nkids) && | |
12582 | 1503 kids && nkids)) |
1504 return 0; | |
9695 | 1505 |
1506 old_handler = XSetErrorHandler(badwindow_handler); | |
1507 | |
12582 | 1508 for (i = 0; i < nkids; i++) |
1509 { | |
1510 Atom type; | |
1511 int format; | |
1512 unsigned long nitems, bytesafter; | |
1513 char *v; | |
1514 int status; | |
9695 | 1515 |
1516 got_badwindow = False; | |
12582 | 1517 status = |
1518 XGetWindowProperty(dpy, kids[i], xs_version, 0, 200, False, | |
1519 XA_STRING, &type, &format, &nitems, | |
1520 &bytesafter, (unsigned char **) &v); | |
1521 XSync(dpy, False); | |
1522 if (got_badwindow) | |
1523 status = BadWindow; | |
9695 | 1524 |
12582 | 1525 if (status == Success && type != None) |
1526 { | |
1527 retval = kids[i]; | |
1528 break; | |
1529 } | |
9695 | 1530 } |
1531 XFree(kids); | |
1532 XSetErrorHandler(old_handler); | |
1533 | |
1534 return retval; | |
1535 } | |
1536 | |
1537 static Window xs_windowid = 0; | |
1538 static Atom deactivate; | |
1539 static Atom screensaver; | |
1540 | |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1541 static unsigned int time_last; |
9695 | 1542 |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1543 void xscreensaver_heartbeat(void) |
9695 | 1544 { |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1545 unsigned int time = GetTimerMS(); |
9695 | 1546 XEvent ev; |
1547 | |
10920 | 1548 if (mDisplay && xs_windowid && |
12582 | 1549 ((time - time_last) > 30000 || (time - time_last) < 0)) |
1550 { | |
1551 time_last = time; | |
9695 | 1552 |
12582 | 1553 ev.xany.type = ClientMessage; |
1554 ev.xclient.display = mDisplay; | |
1555 ev.xclient.window = xs_windowid; | |
1556 ev.xclient.message_type = screensaver; | |
1557 ev.xclient.format = 32; | |
1558 memset(&ev.xclient.data, 0, sizeof(ev.xclient.data)); | |
1559 ev.xclient.data.l[0] = (long) deactivate; | |
9695 | 1560 |
12582 | 1561 mp_msg(MSGT_VO, MSGL_DBG2, "Pinging xscreensaver.\n"); |
1562 XSendEvent(mDisplay, xs_windowid, False, 0L, &ev); | |
1563 XSync(mDisplay, False); | |
9695 | 1564 } |
1565 } | |
1566 | |
12582 | 1567 static void xscreensaver_disable(Display * dpy) |
9695 | 1568 { |
12582 | 1569 mp_msg(MSGT_VO, MSGL_DBG2, "xscreensaver_disable()\n"); |
9695 | 1570 |
1571 xs_windowid = find_xscreensaver_window(dpy); | |
12582 | 1572 if (!xs_windowid) |
1573 { | |
1574 mp_msg(MSGT_VO, MSGL_INFO, | |
1575 "xscreensaver_disable: Could not find xscreensaver window.\n"); | |
1576 return; | |
9695 | 1577 } |
12582 | 1578 mp_msg(MSGT_VO, MSGL_INFO, |
9695 | 1579 "xscreensaver_disable: xscreensaver wid=%d.\n", xs_windowid); |
1580 | |
1581 deactivate = XInternAtom(dpy, "DEACTIVATE", False); | |
1582 screensaver = XInternAtom(dpy, "SCREENSAVER", False); | |
1583 } | |
1584 | |
1585 static void xscreensaver_enable(void) | |
1586 { | |
1587 xs_windowid = 0; | |
1588 } | |
1589 | |
1590 /* | |
1591 * End of XScreensaver stuff | |
1592 */ | |
1593 | |
12582 | 1594 void saver_on(Display * mDisplay) |
1595 { | |
324 | 1596 |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1597 #ifdef HAVE_XDPMS |
324 | 1598 int nothing; |
12582 | 1599 |
324 | 1600 if (dpms_disabled) |
1601 { | |
12582 | 1602 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) |
1603 { | |
1604 if (!DPMSEnable(mDisplay)) | |
1605 { // restoring power saving settings | |
1606 mp_msg(MSGT_VO, MSGL_WARN, "DPMS not available?\n"); | |
1607 } else | |
1608 { | |
741 | 1609 // DPMS does not seem to be enabled unless we call DPMSInfo |
12582 | 1610 BOOL onoff; |
1611 CARD16 state; | |
1612 | |
1613 DPMSForceLevel(mDisplay, DPMSModeOn); | |
1614 DPMSInfo(mDisplay, &state, &onoff); | |
1615 if (onoff) | |
1616 { | |
1617 mp_msg(MSGT_VO, MSGL_INFO, | |
1618 "Successfully enabled DPMS\n"); | |
1619 } else | |
1620 { | |
1621 mp_msg(MSGT_VO, MSGL_WARN, "Could not enable DPMS\n"); | |
741 | 1622 } |
1623 } | |
12582 | 1624 } |
1625 dpms_disabled = 0; | |
324 | 1626 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1627 #endif |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1628 |
324 | 1629 if (timeout_save) |
1630 { | |
12582 | 1631 int dummy, interval, prefer_blank, allow_exp; |
1632 | |
1633 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, | |
1634 &allow_exp); | |
1635 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, | |
1636 allow_exp); | |
1637 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, | |
1638 &allow_exp); | |
1639 timeout_save = 0; | |
324 | 1640 } |
1641 | |
12582 | 1642 if (stop_xscreensaver) |
1643 xscreensaver_enable(); | |
1644 if (kdescreensaver_was_running && stop_xscreensaver) | |
1645 { | |
1646 system | |
1647 ("dcop kdesktop KScreensaverIface enable true 2>/dev/null >/dev/null"); | |
1648 kdescreensaver_was_running = 0; | |
8354
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1649 } |
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1650 |
6303 | 1651 |
324 | 1652 } |
1653 | |
12582 | 1654 void saver_off(Display * mDisplay) |
1655 { | |
324 | 1656 |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1657 int interval, prefer_blank, allow_exp; |
12582 | 1658 |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1659 #ifdef HAVE_XDPMS |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1660 int nothing; |
324 | 1661 |
1662 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
1663 { | |
12582 | 1664 BOOL onoff; |
1665 CARD16 state; | |
1666 | |
1667 DPMSInfo(mDisplay, &state, &onoff); | |
1668 if (onoff) | |
1669 { | |
1670 Status stat; | |
1671 | |
1672 mp_msg(MSGT_VO, MSGL_INFO, "Disabling DPMS\n"); | |
1673 dpms_disabled = 1; | |
1674 stat = DPMSDisable(mDisplay); // monitor powersave off | |
1675 mp_msg(MSGT_VO, MSGL_V, "DPMSDisable stat: %d\n", stat); | |
1676 } | |
324 | 1677 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1678 #endif |
12582 | 1679 if (!timeout_save) |
1680 { | |
1681 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, | |
1682 &allow_exp); | |
1683 if (timeout_save) | |
1684 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, | |
1685 allow_exp); | |
8097 | 1686 } |
12582 | 1687 // turning off screensaver |
1688 if (stop_xscreensaver) | |
1689 xscreensaver_disable(mDisplay); | |
8354
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1690 if (stop_xscreensaver && !kdescreensaver_was_running) |
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1691 { |
12582 | 1692 kdescreensaver_was_running = |
1693 (system | |
1694 ("dcop kdesktop KScreensaverIface isEnabled 2>/dev/null | sed 's/1/true/g' | grep true 2>/dev/null >/dev/null") | |
1695 == 0); | |
1696 if (kdescreensaver_was_running) | |
1697 system | |
1698 ("dcop kdesktop KScreensaverIface enable false 2>/dev/null >/dev/null"); | |
8354
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1699 } |
326 | 1700 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1701 |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1702 static XErrorHandler old_handler = NULL; |
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1703 static int selectinput_err = 0; |
12582 | 1704 static int x11_selectinput_errorhandler(Display * display, |
1705 XErrorEvent * event) | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1706 { |
12582 | 1707 if (event->error_code == BadAccess) |
1708 { | |
1709 selectinput_err = 1; | |
1710 mp_msg(MSGT_VO, MSGL_ERR, | |
1711 "X11 error: BadAccess during XSelectInput Call\n"); | |
1712 mp_msg(MSGT_VO, MSGL_ERR, | |
1713 "X11 error: The 'ButtonPressMask' mask of specified window has probably already used by another appication (see man XSelectInput)\n"); | |
1714 /* If you think mplayer should shutdown with this error, comments out following line */ | |
1715 return 0; | |
1716 } | |
1717 if (old_handler != NULL) | |
1718 old_handler(display, event); | |
1719 else | |
1720 x11_errorhandler(display, event); | |
1721 return 0; | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1722 } |
3990 | 1723 |
12582 | 1724 void vo_x11_selectinput_witherr(Display * display, Window w, |
1725 long event_mask) | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1726 { |
12582 | 1727 XSync(display, False); |
1728 old_handler = XSetErrorHandler(x11_selectinput_errorhandler); | |
1729 selectinput_err = 0; | |
1730 if (vo_nomouse_input) | |
1731 { | |
1732 XSelectInput(display, w, | |
1733 event_mask & | |
1734 (~(ButtonPressMask | ButtonReleaseMask))); | |
1735 } else | |
1736 { | |
1737 XSelectInput(display, w, event_mask); | |
1738 } | |
1739 XSync(display, False); | |
1740 XSetErrorHandler(old_handler); | |
1741 if (selectinput_err) | |
1742 { | |
1743 mp_msg(MSGT_VO, MSGL_ERR, | |
1744 "X11 error: MPlayer discards mouse control (reconfiguring)\n"); | |
1745 XSelectInput(display, w, | |
1746 event_mask & | |
1747 (~ | |
1748 (ButtonPressMask | ButtonReleaseMask | | |
1749 PointerMotionMask))); | |
1750 } | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1751 } |
3990 | 1752 |
1753 #ifdef HAVE_XINERAMA | |
12582 | 1754 void vo_x11_xinerama_move(Display * dsp, Window w) |
3990 | 1755 { |
12582 | 1756 if (XineramaIsActive(dsp) && !geometry_xy_changed) |
1757 { | |
1758 /* printf("XXXX Xinerama screen: x: %hd y: %hd\n",xinerama_x,xinerama_y); */ | |
1759 XMoveWindow(dsp, w, xinerama_x, xinerama_y); | |
1760 } | |
3990 | 1761 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1762 #endif |
3990 | 1763 |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1764 #ifdef HAVE_XF86VM |
12582 | 1765 void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width, |
1766 int *modeline_height) | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1767 { |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1768 unsigned int vm_event, vm_error; |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1769 unsigned int vm_ver, vm_rev; |
12582 | 1770 int i, j, have_vm = 0; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1771 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1772 int modecount; |
12582 | 1773 |
1774 if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) | |
1775 { | |
1776 XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); | |
1777 mp_msg(MSGT_VO, MSGL_V, "XF86VidMode Extension v%i.%i\n", vm_ver, | |
1778 vm_rev); | |
1779 have_vm = 1; | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1780 } else |
12582 | 1781 mp_msg(MSGT_VO, MSGL_WARN, |
1782 "XF86VidMode Extenstion not available.\n"); | |
1783 | |
1784 if (have_vm) | |
1785 { | |
1786 if (vidmodes == NULL) | |
1787 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
1788 &vidmodes); | |
1789 j = 0; | |
1790 *modeline_width = vidmodes[0]->hdisplay; | |
1791 *modeline_height = vidmodes[0]->vdisplay; | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1792 |
12582 | 1793 for (i = 1; i < modecount; i++) |
1794 if ((vidmodes[i]->hdisplay >= X) | |
1795 && (vidmodes[i]->vdisplay >= Y)) | |
1796 if ((vidmodes[i]->hdisplay <= *modeline_width) | |
1797 && (vidmodes[i]->vdisplay <= *modeline_height)) | |
1798 { | |
1799 *modeline_width = vidmodes[i]->hdisplay; | |
1800 *modeline_height = vidmodes[i]->vdisplay; | |
1801 j = i; | |
1802 } | |
1803 | |
1804 mp_msg(MSGT_VO, MSGL_INFO, | |
1805 "XF86VM: Selected video mode %dx%d for image size %dx%d.\n", | |
1806 *modeline_width, *modeline_height, X, Y); | |
1807 XF86VidModeLockModeSwitch(mDisplay, mScreen, 0); | |
1808 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]); | |
1809 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]); | |
1810 X = (vo_screenwidth - *modeline_width) / 2; | |
1811 Y = (vo_screenheight - *modeline_height) / 2; | |
1812 XF86VidModeSetViewPort(mDisplay, mScreen, X, Y); | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1813 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1814 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1815 |
12582 | 1816 void vo_vm_close(Display * dpy) |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1817 { |
12582 | 1818 #ifdef HAVE_NEW_GUI |
1819 if (vidmodes != NULL && vo_window != None) | |
1820 #else | |
1821 if (vidmodes != NULL) | |
1822 #endif | |
1823 { | |
1824 int i, modecount; | |
1825 int screen; | |
1826 | |
1827 screen = DefaultScreen(dpy); | |
5019 | 1828 |
12582 | 1829 free(vidmodes); |
1830 vidmodes = NULL; | |
1831 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
1832 &vidmodes); | |
1833 for (i = 0; i < modecount; i++) | |
1834 if ((vidmodes[i]->hdisplay == vo_screenwidth) | |
1835 && (vidmodes[i]->vdisplay == vo_screenheight)) | |
1836 { | |
1837 mp_msg(MSGT_VO, MSGL_INFO, | |
1838 "Returning to original mode %dx%d\n", | |
1839 vo_screenwidth, vo_screenheight); | |
1840 break; | |
1841 } | |
5019 | 1842 |
12582 | 1843 XF86VidModeSwitchToMode(dpy, screen, vidmodes[i]); |
1844 XF86VidModeSwitchToMode(dpy, screen, vidmodes[i]); | |
1845 free(vidmodes); | |
1846 vidmodes = NULL; | |
1847 } | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1848 } |
3990 | 1849 #endif |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1850 |
12582 | 1851 #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
|
1852 |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1853 |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1854 /* |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1855 * 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
|
1856 * 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
|
1857 * 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
|
1858 * >= 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
|
1859 */ |
12582 | 1860 int vo_find_depth_from_visuals(Display * dpy, int screen, |
1861 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
|
1862 { |
12582 | 1863 XVisualInfo visual_tmpl; |
1864 XVisualInfo *visuals; | |
1865 int nvisuals, i; | |
1866 int bestvisual = -1; | |
1867 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
|
1868 |
12582 | 1869 visual_tmpl.screen = screen; |
1870 visual_tmpl.class = TrueColor; | |
1871 visuals = XGetVisualInfo(dpy, | |
1872 VisualScreenMask | VisualClassMask, | |
1873 &visual_tmpl, &nvisuals); | |
1874 if (visuals != NULL) | |
1875 { | |
1876 for (i = 0; i < nvisuals; i++) | |
1877 { | |
1878 mp_msg(MSGT_VO, MSGL_V, | |
1879 "vo: X11 truecolor visual %#x, depth %d, R:%lX G:%lX B:%lX\n", | |
1880 visuals[i].visualid, visuals[i].depth, | |
1881 visuals[i].red_mask, visuals[i].green_mask, | |
1882 visuals[i].blue_mask); | |
1883 /* | |
1884 * save the visual index and it's depth, if this is the first | |
1885 * truecolor visul, or a visual that is 'preferred' over the | |
1886 * previous 'best' visual | |
1887 */ | |
1888 if (bestvisual_depth == -1 | |
1889 || (visuals[i].depth >= 15 | |
1890 && (visuals[i].depth < bestvisual_depth | |
1891 || bestvisual_depth < 15))) | |
1892 { | |
1893 bestvisual = i; | |
1894 bestvisual_depth = visuals[i].depth; | |
1895 } | |
1896 } | |
1897 | |
1898 if (bestvisual != -1 && visual_return != NULL) | |
1899 *visual_return = visuals[bestvisual].visual; | |
1900 | |
1901 XFree(visuals); | |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1902 } |
12582 | 1903 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
|
1904 } |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1905 |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1906 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1907 static Colormap cmap = None; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1908 static XColor cols[256]; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1909 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
|
1910 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1911 |
12582 | 1912 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
|
1913 { |
12582 | 1914 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
|
1915 |
12582 | 1916 if (vinfo->class != DirectColor) |
1917 return XCreateColormap(mDisplay, mRootWin, vinfo->visual, | |
1918 AllocNone); | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1919 |
12582 | 1920 /* can this function get called twice or more? */ |
1921 if (cmap) | |
1922 return cmap; | |
1923 cm_size = vinfo->colormap_size; | |
1924 red_mask = vinfo->red_mask; | |
1925 green_mask = vinfo->green_mask; | |
1926 blue_mask = vinfo->blue_mask; | |
1927 ru = (red_mask & (red_mask - 1)) ^ red_mask; | |
1928 gu = (green_mask & (green_mask - 1)) ^ green_mask; | |
1929 bu = (blue_mask & (blue_mask - 1)) ^ blue_mask; | |
1930 rvu = 65536ull * ru / (red_mask + ru); | |
1931 gvu = 65536ull * gu / (green_mask + gu); | |
1932 bvu = 65536ull * bu / (blue_mask + bu); | |
1933 r = g = b = 0; | |
1934 rv = gv = bv = 0; | |
1935 m = DoRed | DoGreen | DoBlue; | |
1936 for (k = 0; k < cm_size; k++) | |
1937 { | |
1938 int t; | |
1939 | |
1940 cols[k].pixel = r | g | b; | |
1941 cols[k].red = rv; | |
1942 cols[k].green = gv; | |
1943 cols[k].blue = bv; | |
1944 cols[k].flags = m; | |
1945 t = (r + ru) & red_mask; | |
1946 if (t < r) | |
1947 m &= ~DoRed; | |
1948 r = t; | |
1949 t = (g + gu) & green_mask; | |
1950 if (t < g) | |
1951 m &= ~DoGreen; | |
1952 g = t; | |
1953 t = (b + bu) & blue_mask; | |
1954 if (t < b) | |
1955 m &= ~DoBlue; | |
1956 b = t; | |
1957 rv += rvu; | |
1958 gv += gvu; | |
1959 bv += bvu; | |
1960 } | |
1961 cmap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocAll); | |
1962 XStoreColors(mDisplay, cmap, cols, cm_size); | |
1963 return cmap; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1964 } |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1965 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1966 /* |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1967 * 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
|
1968 * 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
|
1969 * 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
|
1970 * 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
|
1971 */ |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1972 /* 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
|
1973 static int vo_gamma = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1974 static int vo_brightness = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1975 static int vo_contrast = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1976 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1977 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1978 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
|
1979 { |
12582 | 1980 float gamma, brightness, contrast; |
1981 float rf, gf, bf; | |
1982 int k; | |
1983 | |
1984 /* | |
1985 * IMPLEMENTME: consider using XF86VidModeSetGammaRamp in the case | |
1986 * of TrueColor-ed window but be careful: | |
1987 * unlike the colormaps, which are private for the X client | |
1988 * who created them and thus automatically destroyed on client | |
1989 * disconnect, this gamma ramp is a system-wide (X-server-wide) | |
1990 * setting and _must_ be restored before the process exit. | |
1991 * Unforunately when the process crashes (or get killed | |
1992 * for some reason) it is impossible to restore the setting, | |
1993 * and such behaviour could be rather annoying for the users. | |
1994 */ | |
1995 if (cmap == None) | |
1996 return VO_NOTAVAIL; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1997 |
12582 | 1998 if (!strcasecmp(name, "brightness")) |
1999 vo_brightness = value; | |
2000 else if (!strcasecmp(name, "contrast")) | |
2001 vo_contrast = value; | |
2002 else if (!strcasecmp(name, "gamma")) | |
2003 vo_gamma = value; | |
2004 else | |
2005 return VO_NOTIMPL; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2006 |
12582 | 2007 brightness = 0.01 * vo_brightness; |
2008 contrast = tan(0.0095 * (vo_contrast + 100) * M_PI / 4); | |
2009 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
|
2010 |
12582 | 2011 rf = (float) ((red_mask & (red_mask - 1)) ^ red_mask) / red_mask; |
2012 gf = (float) ((green_mask & (green_mask - 1)) ^ green_mask) / | |
2013 green_mask; | |
2014 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
|
2015 |
12582 | 2016 /* now recalculate the colormap using the newly set value */ |
2017 for (k = 0; k < cm_size; k++) | |
2018 { | |
2019 float s; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2020 |
12582 | 2021 s = pow(rf * k, gamma); |
2022 s = (s - 0.5) * contrast + 0.5; | |
2023 s += brightness; | |
2024 if (s < 0) | |
2025 s = 0; | |
2026 if (s > 1) | |
2027 s = 1; | |
2028 cols[k].red = (unsigned short) (s * 65535); | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2029 |
12582 | 2030 s = pow(gf * k, gamma); |
2031 s = (s - 0.5) * contrast + 0.5; | |
2032 s += brightness; | |
2033 if (s < 0) | |
2034 s = 0; | |
2035 if (s > 1) | |
2036 s = 1; | |
2037 cols[k].green = (unsigned short) (s * 65535); | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2038 |
12582 | 2039 s = pow(bf * k, gamma); |
2040 s = (s - 0.5) * contrast + 0.5; | |
2041 s += brightness; | |
2042 if (s < 0) | |
2043 s = 0; | |
2044 if (s > 1) | |
2045 s = 1; | |
2046 cols[k].blue = (unsigned short) (s * 65535); | |
2047 } | |
2048 | |
2049 XStoreColors(mDisplay, cmap, cols, cm_size); | |
2050 XFlush(mDisplay); | |
2051 return VO_TRUE; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2052 } |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2053 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2054 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
|
2055 { |
12582 | 2056 if (cmap == None) |
2057 return VO_NOTAVAIL; | |
2058 if (!strcasecmp(name, "brightness")) | |
2059 *value = vo_brightness; | |
2060 else if (!strcasecmp(name, "contrast")) | |
2061 *value = vo_contrast; | |
2062 else if (!strcasecmp(name, "gamma")) | |
2063 *value = vo_gamma; | |
2064 else | |
2065 return VO_NOTIMPL; | |
2066 return VO_TRUE; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2067 } |
12582 | 2068 |
10359 | 2069 #ifdef HAVE_XV |
2070 int vo_xv_set_eq(uint32_t xv_port, char *name, int value) | |
2071 { | |
2072 XvAttribute *attributes; | |
12582 | 2073 int i, howmany, xv_atom; |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2074 |
10359 | 2075 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
|
2076 |
10359 | 2077 /* get available attributes */ |
2078 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); | |
2079 for (i = 0; i < howmany && attributes; i++) | |
12582 | 2080 if (attributes[i].flags & XvSettable) |
2081 { | |
2082 xv_atom = XInternAtom(mDisplay, attributes[i].name, True); | |
10359 | 2083 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
2084 then trigger it if it's ok so that the other values are at default upon query */ | |
12582 | 2085 if (xv_atom != None) |
2086 { | |
2087 int hue = 0, port_value, port_min, port_max; | |
10359 | 2088 |
12582 | 2089 if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && |
2090 (!strcasecmp(name, "brightness"))) | |
2091 port_value = value; | |
2092 else if (!strcmp(attributes[i].name, "XV_CONTRAST") && | |
2093 (!strcasecmp(name, "contrast"))) | |
2094 port_value = value; | |
2095 else if (!strcmp(attributes[i].name, "XV_SATURATION") && | |
2096 (!strcasecmp(name, "saturation"))) | |
2097 port_value = value; | |
2098 else if (!strcmp(attributes[i].name, "XV_HUE") && | |
2099 (!strcasecmp(name, "hue"))) | |
2100 { | |
2101 port_value = value; | |
2102 hue = 1; | |
2103 } else | |
10359 | 2104 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
12582 | 2105 if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && |
2106 (!strcasecmp(name, "red_intensity"))) | |
2107 port_value = value; | |
2108 else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") | |
2109 && (!strcasecmp(name, "green_intensity"))) | |
2110 port_value = value; | |
2111 else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") | |
2112 && (!strcasecmp(name, "blue_intensity"))) | |
2113 port_value = value; | |
2114 else | |
2115 continue; | |
2116 | |
2117 port_min = attributes[i].min_value; | |
2118 port_max = attributes[i].max_value; | |
10359 | 2119 |
12582 | 2120 /* nvidia hue workaround */ |
2121 if (hue && port_min == 0 && port_max == 360) | |
2122 { | |
2123 port_value = | |
2124 (port_value >= | |
2125 0) ? (port_value - 100) : (port_value + 100); | |
10359 | 2126 } |
12582 | 2127 // -100 -> min |
2128 // 0 -> (max+min)/2 | |
2129 // +100 -> max | |
2130 port_value = | |
2131 (port_value + 100) * (port_max - port_min) / 200 + | |
2132 port_min; | |
2133 XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value); | |
2134 return (VO_TRUE); | |
2135 } | |
2136 } | |
2137 return (VO_FALSE); | |
10359 | 2138 } |
2139 | |
2140 int vo_xv_get_eq(uint32_t xv_port, char *name, int *value) | |
2141 { | |
12582 | 2142 |
10359 | 2143 XvAttribute *attributes; |
12582 | 2144 int i, howmany, xv_atom; |
10359 | 2145 |
2146 /* get available attributes */ | |
2147 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); | |
2148 for (i = 0; i < howmany && attributes; i++) | |
12582 | 2149 if (attributes[i].flags & XvGettable) |
2150 { | |
2151 xv_atom = XInternAtom(mDisplay, attributes[i].name, True); | |
10359 | 2152 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
2153 then trigger it if it's ok so that the other values are at default upon query */ | |
12582 | 2154 if (xv_atom != None) |
2155 { | |
2156 int val, port_value = 0, port_min, port_max; | |
10359 | 2157 |
12582 | 2158 XvGetPortAttribute(mDisplay, xv_port, xv_atom, |
2159 &port_value); | |
2160 | |
2161 port_min = attributes[i].min_value; | |
2162 port_max = attributes[i].max_value; | |
2163 val = | |
2164 (port_value - port_min) * 200 / (port_max - port_min) - | |
2165 100; | |
10359 | 2166 |
12582 | 2167 if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && |
2168 (!strcasecmp(name, "brightness"))) | |
2169 *value = val; | |
2170 else if (!strcmp(attributes[i].name, "XV_CONTRAST") && | |
2171 (!strcasecmp(name, "contrast"))) | |
2172 *value = val; | |
2173 else if (!strcmp(attributes[i].name, "XV_SATURATION") && | |
2174 (!strcasecmp(name, "saturation"))) | |
2175 *value = val; | |
2176 else if (!strcmp(attributes[i].name, "XV_HUE") && | |
2177 (!strcasecmp(name, "hue"))) | |
2178 { | |
2179 /* nasty nvidia detect */ | |
2180 if (port_min == 0 && port_max == 360) | |
2181 *value = (val >= 0) ? (val - 100) : (val + 100); | |
2182 else | |
2183 *value = val; | |
2184 } else | |
10359 | 2185 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
12582 | 2186 if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && |
2187 (!strcasecmp(name, "red_intensity"))) | |
2188 *value = val; | |
2189 else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") | |
2190 && (!strcasecmp(name, "green_intensity"))) | |
2191 *value = val; | |
2192 else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") | |
2193 && (!strcasecmp(name, "blue_intensity"))) | |
2194 *value = val; | |
2195 else | |
2196 continue; | |
10359 | 2197 |
12582 | 2198 mp_dbg(MSGT_VO, MSGL_V, "xv_get_eq called! (%s, %d)\n", |
2199 name, *value); | |
2200 return (VO_TRUE); | |
2201 } | |
2202 } | |
2203 return (VO_FALSE); | |
10359 | 2204 } |
2205 | |
2206 #endif |