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