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