Mercurial > mplayer.hg
annotate libvo/x11_common.c @ 14009:1c2b471136b3
*** empty log message ***
author | jheryan |
---|---|
date | Mon, 22 Nov 2004 08:43:48 +0000 |
parents | 7032d122c733 |
children | f8670fdf6ab1 |
rev | line source |
---|---|
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1 |
32 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
4 #include <math.h> |
6401 | 5 #include <inttypes.h> |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
6 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
7 #include "config.h" |
5998 | 8 #include "mp_msg.h" |
6401 | 9 #include "x11_common.h" |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
10 |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
11 #ifdef X11_FULLSCREEN |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
12 |
440
d19a3da6ac13
Pontscho's mixer, select, and hell-a-lot-of-stuff patch ;)
gabucino
parents:
416
diff
changeset
|
13 #include <string.h> |
32 | 14 #include <unistd.h> |
15 #include <sys/mman.h> | |
9695 | 16 #include <signal.h> |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
17 #include <assert.h> |
32 | 18 |
19 #include "video_out.h" | |
10889 | 20 #include "aspect.h" |
12032
8cc4d4344c0f
Don't mess with the window position in xinerama when -geometry changes it.
diego
parents:
12031
diff
changeset
|
21 #include "geometry.h" |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
22 #include "help_mp.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
23 #include "osdep/timer.h" |
32 | 24 |
324 | 25 #include <X11/Xmd.h> |
32 | 26 #include <X11/Xlib.h> |
27 #include <X11/Xutil.h> | |
28 #include <X11/Xatom.h> | |
29 | |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
30 #ifdef HAVE_XDPMS |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
31 #include <X11/extensions/dpms.h> |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
32 #endif |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
33 |
2149
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
34 #ifdef HAVE_XINERAMA |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
35 #include <X11/extensions/Xinerama.h> |
6358db6ad3d0
Xinerama screen size fix by Lev Babiev <harley@hosers.org>
arpi
parents:
1746
diff
changeset
|
36 #endif |
1732 | 37 |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
38 #ifdef HAVE_XF86VM |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
39 #include <X11/extensions/xf86vmode.h> |
9822
1e761763566c
Support for "internet" or "multimedia" keyboards in X11.
albeu
parents:
9695
diff
changeset
|
40 #include <X11/XF86keysym.h> |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
41 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
42 |
10359 | 43 #ifdef HAVE_XV |
44 #include <X11/extensions/Xv.h> | |
45 #include <X11/extensions/Xvlib.h> | |
46 #endif | |
47 | |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
48 #include "input/input.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
49 #include "input/mouse.h" |
4658 | 50 |
4798 | 51 #ifdef HAVE_NEW_GUI |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
52 #include "Gui/interface.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12972
diff
changeset
|
53 #include "mplayer.h" |
4798 | 54 #endif |
55 | |
8660
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
56 #define WIN_LAYER_ONBOTTOM 2 |
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
57 #define WIN_LAYER_NORMAL 4 |
39476cbd1673
I have looked at the fullscreen code and realized that there are
arpi
parents:
8653
diff
changeset
|
58 #define WIN_LAYER_ONTOP 6 |
8669
fd398a0b4b3b
This time the patch is fixing much more that breaking :-)
arpi
parents:
8663
diff
changeset
|
59 #define WIN_LAYER_ABOVE_DOCK 10 |
12582 | 60 |
61 int fs_layer = WIN_LAYER_ABOVE_DOCK; | |
62 static int orig_layer = 0; | |
12111
8e31aacc3e81
- win_gravity memorizing and restoring while switching fullscreen mode (by Adam Tla/lka)
rathann
parents:
12096
diff
changeset
|
63 static int old_gravity = NorthWestGravity; |
8866 | 64 |
12582 | 65 int stop_xscreensaver = 0; |
6202 | 66 |
12582 | 67 static int dpms_disabled = 0; |
68 static int timeout_save = 0; | |
69 static int kdescreensaver_was_running = 0; | |
324 | 70 |
12582 | 71 char *mDisplayName = NULL; |
72 Display *mDisplay = NULL; | |
73 Window mRootWin; | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
74 int mScreen; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
75 int mLocalDisplay; |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
741
diff
changeset
|
76 |
3830 | 77 /* output window id */ |
12582 | 78 int WinID = -1; |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5919
diff
changeset
|
79 int vo_mouse_autohide = 0; |
9317
c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
filon
parents:
9217
diff
changeset
|
80 int vo_wm_type = 0; |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
81 int vo_fs_type = 0; // needs to be accessible for GUI X11 code |
12125
f4fc74a88e65
full screen flipping synchronization corrections (by Adam Tla/lka)
rathann
parents:
12123
diff
changeset
|
82 static int vo_fs_flip = 0; |
12582 | 83 char **vo_fstype_list; |
384 | 84 |
8835
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
85 /* if equal to 1 means that WM is a metacity (broken as hell) */ |
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
86 int metacity_hack = 0; |
664b0612f950
Fixed metacity + xv behavior (something broke it lately).
filon
parents:
8783
diff
changeset
|
87 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
88 static Atom XA_NET_SUPPORTED; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
89 static Atom XA_NET_WM_STATE; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
90 static Atom XA_NET_WM_STATE_FULLSCREEN; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
91 static Atom XA_NET_WM_STATE_ABOVE; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
92 static Atom XA_NET_WM_STATE_STAYS_ON_TOP; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
93 static Atom XA_NET_WM_STATE_BELOW; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
94 static Atom XA_NET_WM_PID; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
95 static Atom XA_WIN_PROTOCOLS; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
96 static Atom XA_WIN_LAYER; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
97 static Atom XA_WIN_HINTS; |
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
98 static Atom XA_BLACKBOX_PID; |
8742
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
99 |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
100 #define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False) |
241f40ef5e28
More fullscreen cleanup work. Use nice macros for X atoms.
filon
parents:
8716
diff
changeset
|
101 |
7435 | 102 static int vo_old_x = 0; |
103 static int vo_old_y = 0; | |
104 static int vo_old_width = 0; | |
105 static int vo_old_height = 0; | |
106 | |
4017 | 107 #ifdef HAVE_XINERAMA |
108 int xinerama_screen = 0; | |
109 int xinerama_x = 0; | |
110 int xinerama_y = 0; | |
111 #endif | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
112 #ifdef HAVE_XF86VM |
12582 | 113 XF86VidModeModeInfo **vidmodes = NULL; |
4977
7b65a4f0b74e
vm pecs applied from daniel carter <hedonist@win.co.nz>
pontscho
parents:
4974
diff
changeset
|
114 XF86VidModeModeLine modeline; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
115 #endif |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
116 |
10587
382bf4771ee7
moved lot of global variables into static ones (and some minor spelling fixes)
alex
parents:
10570
diff
changeset
|
117 static int vo_x11_get_fs_type(int supported); |
10212
d358fa9a1068
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
alex
parents:
10193
diff
changeset
|
118 |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
119 |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
120 /* |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
121 * Sends the EWMH fullscreen state event. |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
122 * |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
123 * action: could be on of _NET_WM_STATE_REMOVE -- remove state |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
124 * _NET_WM_STATE_ADD -- add state |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
125 * _NET_WM_STATE_TOGGLE -- toggle |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
126 */ |
12582 | 127 void vo_x11_ewmh_fullscreen(int action) |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
128 { |
12582 | 129 assert(action == _NET_WM_STATE_REMOVE || |
130 action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE); | |
131 | |
132 if (vo_fs_type & vo_wm_FULLSCREEN) | |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
133 { |
12582 | 134 XEvent xev; |
135 | |
136 /* init X event structure for _NET_WM_FULLSCREEN client msg */ | |
137 xev.xclient.type = ClientMessage; | |
138 xev.xclient.serial = 0; | |
139 xev.xclient.send_event = True; | |
140 xev.xclient.message_type = XInternAtom(mDisplay, | |
141 "_NET_WM_STATE", False); | |
142 xev.xclient.window = vo_window; | |
143 xev.xclient.format = 32; | |
144 xev.xclient.data.l[0] = action; | |
145 xev.xclient.data.l[1] = XInternAtom(mDisplay, | |
146 "_NET_WM_STATE_FULLSCREEN", | |
147 False); | |
148 xev.xclient.data.l[2] = 0; | |
149 xev.xclient.data.l[3] = 0; | |
150 xev.xclient.data.l[4] = 0; | |
151 | |
152 /* finally send that damn thing */ | |
153 if (!XSendEvent(mDisplay, DefaultRootWindow(mDisplay), False, | |
154 SubstructureRedirectMask | SubstructureNotifyMask, | |
155 &xev)) | |
156 { | |
157 mp_msg(MSGT_VO, MSGL_ERR, MSGTR_EwmhFullscreenStateFailed); | |
158 } | |
12520
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
159 } |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
160 } |
94e66acdb706
Metacity fullscreen issues, patch by Alexander Strasser <eclipse7@gmx.net>,
diego
parents:
12371
diff
changeset
|
161 |
12582 | 162 void vo_hidecursor(Display * disp, Window win) |
384 | 163 { |
12582 | 164 Cursor no_ptr; |
165 Pixmap bm_no; | |
166 XColor black, dummy; | |
167 Colormap colormap; | |
13828
b4ad5f0b550d
Fix erroneus extern declarations, fix wrong signedness of some vars
atmos4
parents:
13787
diff
changeset
|
168 static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
3954 | 169 |
12582 | 170 if (WinID == 0) |
171 return; // do not hide, if we're playing at rootwin | |
172 | |
173 colormap = DefaultColormap(disp, DefaultScreen(disp)); | |
174 XAllocNamedColor(disp, colormap, "black", &black, &dummy); | |
175 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8); | |
176 no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0); | |
177 XDefineCursor(disp, win, no_ptr); | |
178 XFreeCursor(disp, no_ptr); | |
179 if (bm_no != None) | |
180 XFreePixmap(disp, bm_no); | |
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 |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1487 if ((!(vo_fs)) & vo_ontop) |
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1488 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
12582 | 1489 |
12798
33423862b159
Indentation fix from previous patch, as discussed on IRC.
rtognimp
parents:
12796
diff
changeset
|
1490 XMoveResizeWindow(mDisplay, vo_window, x, y, w, h); |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1491 } |
12582 | 1492 #ifdef HAVE_XINERAMA |
1493 vo_x11_xinerama_move(mDisplay, vo_window); | |
1494 #endif | |
12796
24075685789b
This fixes the problems that originated from my ewmh
rtognimp
parents:
12582
diff
changeset
|
1495 |
12582 | 1496 XMapRaised(mDisplay, vo_window); |
1497 XRaiseWindow(mDisplay, vo_window); | |
1498 XFlush(mDisplay); | |
1499 } | |
1500 | |
1501 void vo_x11_ontop(void) | |
1502 { | |
1503 vo_ontop = (!(vo_ontop)); | |
1504 | |
1505 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 1506 } |
1507 | |
9695 | 1508 /* |
1509 * XScreensaver stuff | |
1510 */ | |
1511 | |
1512 static int got_badwindow; | |
1513 static XErrorHandler old_handler; | |
1514 | |
12582 | 1515 static int badwindow_handler(Display * dpy, XErrorEvent * error) |
9695 | 1516 { |
1517 if (error->error_code != BadWindow) | |
12582 | 1518 return (*old_handler) (dpy, error); |
9695 | 1519 |
1520 got_badwindow = True; | |
1521 return 0; | |
1522 } | |
1523 | |
12582 | 1524 static Window find_xscreensaver_window(Display * dpy) |
9695 | 1525 { |
1526 int i; | |
1527 Window root = RootWindowOfScreen(DefaultScreenOfDisplay(dpy)); | |
1528 Window root2, parent, *kids; | |
1529 Window retval = 0; | |
1530 Atom xs_version; | |
1531 unsigned int nkids = 0; | |
1532 | |
1533 xs_version = XInternAtom(dpy, "_SCREENSAVER_VERSION", True); | |
1534 | |
1535 if (!(xs_version != None && | |
1536 XQueryTree(dpy, root, &root2, &parent, &kids, &nkids) && | |
12582 | 1537 kids && nkids)) |
1538 return 0; | |
9695 | 1539 |
1540 old_handler = XSetErrorHandler(badwindow_handler); | |
1541 | |
12582 | 1542 for (i = 0; i < nkids; i++) |
1543 { | |
1544 Atom type; | |
1545 int format; | |
1546 unsigned long nitems, bytesafter; | |
1547 char *v; | |
1548 int status; | |
9695 | 1549 |
1550 got_badwindow = False; | |
12582 | 1551 status = |
1552 XGetWindowProperty(dpy, kids[i], xs_version, 0, 200, False, | |
1553 XA_STRING, &type, &format, &nitems, | |
1554 &bytesafter, (unsigned char **) &v); | |
1555 XSync(dpy, False); | |
1556 if (got_badwindow) | |
1557 status = BadWindow; | |
9695 | 1558 |
12582 | 1559 if (status == Success && type != None) |
1560 { | |
1561 retval = kids[i]; | |
1562 break; | |
1563 } | |
9695 | 1564 } |
1565 XFree(kids); | |
1566 XSetErrorHandler(old_handler); | |
1567 | |
1568 return retval; | |
1569 } | |
1570 | |
1571 static Window xs_windowid = 0; | |
1572 static Atom deactivate; | |
1573 static Atom screensaver; | |
1574 | |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1575 static unsigned int time_last; |
9695 | 1576 |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1577 void xscreensaver_heartbeat(void) |
9695 | 1578 { |
12031
0c2b8b731d42
Use system clock for xscreensaver pings (Tobias Diedrich).
diego
parents:
11995
diff
changeset
|
1579 unsigned int time = GetTimerMS(); |
9695 | 1580 XEvent ev; |
1581 | |
10920 | 1582 if (mDisplay && xs_windowid && |
12582 | 1583 ((time - time_last) > 30000 || (time - time_last) < 0)) |
1584 { | |
1585 time_last = time; | |
9695 | 1586 |
12582 | 1587 ev.xany.type = ClientMessage; |
1588 ev.xclient.display = mDisplay; | |
1589 ev.xclient.window = xs_windowid; | |
1590 ev.xclient.message_type = screensaver; | |
1591 ev.xclient.format = 32; | |
1592 memset(&ev.xclient.data, 0, sizeof(ev.xclient.data)); | |
1593 ev.xclient.data.l[0] = (long) deactivate; | |
9695 | 1594 |
12582 | 1595 mp_msg(MSGT_VO, MSGL_DBG2, "Pinging xscreensaver.\n"); |
1596 XSendEvent(mDisplay, xs_windowid, False, 0L, &ev); | |
1597 XSync(mDisplay, False); | |
9695 | 1598 } |
1599 } | |
1600 | |
12582 | 1601 static void xscreensaver_disable(Display * dpy) |
9695 | 1602 { |
12582 | 1603 mp_msg(MSGT_VO, MSGL_DBG2, "xscreensaver_disable()\n"); |
9695 | 1604 |
1605 xs_windowid = find_xscreensaver_window(dpy); | |
12582 | 1606 if (!xs_windowid) |
1607 { | |
1608 mp_msg(MSGT_VO, MSGL_INFO, | |
1609 "xscreensaver_disable: Could not find xscreensaver window.\n"); | |
1610 return; | |
9695 | 1611 } |
12582 | 1612 mp_msg(MSGT_VO, MSGL_INFO, |
9695 | 1613 "xscreensaver_disable: xscreensaver wid=%d.\n", xs_windowid); |
1614 | |
1615 deactivate = XInternAtom(dpy, "DEACTIVATE", False); | |
1616 screensaver = XInternAtom(dpy, "SCREENSAVER", False); | |
1617 } | |
1618 | |
1619 static void xscreensaver_enable(void) | |
1620 { | |
1621 xs_windowid = 0; | |
1622 } | |
1623 | |
1624 /* | |
1625 * End of XScreensaver stuff | |
1626 */ | |
1627 | |
12582 | 1628 void saver_on(Display * mDisplay) |
1629 { | |
324 | 1630 |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1631 #ifdef HAVE_XDPMS |
324 | 1632 int nothing; |
12582 | 1633 |
324 | 1634 if (dpms_disabled) |
1635 { | |
12582 | 1636 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) |
1637 { | |
1638 if (!DPMSEnable(mDisplay)) | |
1639 { // restoring power saving settings | |
1640 mp_msg(MSGT_VO, MSGL_WARN, "DPMS not available?\n"); | |
1641 } else | |
1642 { | |
741 | 1643 // DPMS does not seem to be enabled unless we call DPMSInfo |
12582 | 1644 BOOL onoff; |
1645 CARD16 state; | |
1646 | |
1647 DPMSForceLevel(mDisplay, DPMSModeOn); | |
1648 DPMSInfo(mDisplay, &state, &onoff); | |
1649 if (onoff) | |
1650 { | |
13946 | 1651 mp_msg(MSGT_VO, MSGL_V, |
12582 | 1652 "Successfully enabled DPMS\n"); |
1653 } else | |
1654 { | |
1655 mp_msg(MSGT_VO, MSGL_WARN, "Could not enable DPMS\n"); | |
741 | 1656 } |
1657 } | |
12582 | 1658 } |
1659 dpms_disabled = 0; | |
324 | 1660 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1661 #endif |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1662 |
324 | 1663 if (timeout_save) |
1664 { | |
12582 | 1665 int dummy, interval, prefer_blank, allow_exp; |
1666 | |
1667 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, | |
1668 &allow_exp); | |
1669 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, | |
1670 allow_exp); | |
1671 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, | |
1672 &allow_exp); | |
1673 timeout_save = 0; | |
324 | 1674 } |
1675 | |
12582 | 1676 if (stop_xscreensaver) |
1677 xscreensaver_enable(); | |
1678 if (kdescreensaver_was_running && stop_xscreensaver) | |
1679 { | |
1680 system | |
1681 ("dcop kdesktop KScreensaverIface enable true 2>/dev/null >/dev/null"); | |
1682 kdescreensaver_was_running = 0; | |
8354
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1683 } |
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1684 |
6303 | 1685 |
324 | 1686 } |
1687 | |
12582 | 1688 void saver_off(Display * mDisplay) |
1689 { | |
324 | 1690 |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1691 int interval, prefer_blank, allow_exp; |
12582 | 1692 |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1693 #ifdef HAVE_XDPMS |
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1694 int nothing; |
324 | 1695 |
1696 if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) | |
1697 { | |
12582 | 1698 BOOL onoff; |
1699 CARD16 state; | |
1700 | |
1701 DPMSInfo(mDisplay, &state, &onoff); | |
1702 if (onoff) | |
1703 { | |
1704 Status stat; | |
1705 | |
13946 | 1706 mp_msg(MSGT_VO, MSGL_V, "Disabling DPMS\n"); |
12582 | 1707 dpms_disabled = 1; |
1708 stat = DPMSDisable(mDisplay); // monitor powersave off | |
1709 mp_msg(MSGT_VO, MSGL_V, "DPMSDisable stat: %d\n", stat); | |
1710 } | |
324 | 1711 } |
1345
be674b95b485
x11_common does not compile, when the XDPMS extension is not available on the
jkeil
parents:
1266
diff
changeset
|
1712 #endif |
12582 | 1713 if (!timeout_save) |
1714 { | |
1715 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, | |
1716 &allow_exp); | |
1717 if (timeout_save) | |
1718 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, | |
1719 allow_exp); | |
8097 | 1720 } |
12582 | 1721 // turning off screensaver |
1722 if (stop_xscreensaver) | |
1723 xscreensaver_disable(mDisplay); | |
8354
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1724 if (stop_xscreensaver && !kdescreensaver_was_running) |
8a0b6e083280
This patch fixes the screensaver issues in mplayer. It will correctly read
arpi
parents:
8215
diff
changeset
|
1725 { |
12582 | 1726 kdescreensaver_was_running = |
1727 (system | |
1728 ("dcop kdesktop KScreensaverIface isEnabled 2>/dev/null | sed 's/1/true/g' | grep true 2>/dev/null >/dev/null") | |
1729 == 0); | |
1730 if (kdescreensaver_was_running) | |
1731 system | |
1732 ("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
|
1733 } |
326 | 1734 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1735 |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1736 static XErrorHandler old_handler = NULL; |
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1737 static int selectinput_err = 0; |
12582 | 1738 static int x11_selectinput_errorhandler(Display * display, |
1739 XErrorEvent * event) | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1740 { |
12582 | 1741 if (event->error_code == BadAccess) |
1742 { | |
1743 selectinput_err = 1; | |
1744 mp_msg(MSGT_VO, MSGL_ERR, | |
1745 "X11 error: BadAccess during XSelectInput Call\n"); | |
1746 mp_msg(MSGT_VO, MSGL_ERR, | |
1747 "X11 error: The 'ButtonPressMask' mask of specified window has probably already used by another appication (see man XSelectInput)\n"); | |
1748 /* If you think mplayer should shutdown with this error, comments out following line */ | |
1749 return 0; | |
1750 } | |
1751 if (old_handler != NULL) | |
1752 old_handler(display, event); | |
1753 else | |
1754 x11_errorhandler(display, event); | |
1755 return 0; | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1756 } |
3990 | 1757 |
12582 | 1758 void vo_x11_selectinput_witherr(Display * display, Window w, |
1759 long event_mask) | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1760 { |
12582 | 1761 XSync(display, False); |
1762 old_handler = XSetErrorHandler(x11_selectinput_errorhandler); | |
1763 selectinput_err = 0; | |
1764 if (vo_nomouse_input) | |
1765 { | |
1766 XSelectInput(display, w, | |
1767 event_mask & | |
1768 (~(ButtonPressMask | ButtonReleaseMask))); | |
1769 } else | |
1770 { | |
1771 XSelectInput(display, w, event_mask); | |
1772 } | |
1773 XSync(display, False); | |
1774 XSetErrorHandler(old_handler); | |
1775 if (selectinput_err) | |
1776 { | |
1777 mp_msg(MSGT_VO, MSGL_ERR, | |
1778 "X11 error: MPlayer discards mouse control (reconfiguring)\n"); | |
1779 XSelectInput(display, w, | |
1780 event_mask & | |
1781 (~ | |
1782 (ButtonPressMask | ButtonReleaseMask | | |
1783 PointerMotionMask))); | |
1784 } | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6401
diff
changeset
|
1785 } |
3990 | 1786 |
1787 #ifdef HAVE_XINERAMA | |
12582 | 1788 void vo_x11_xinerama_move(Display * dsp, Window w) |
3990 | 1789 { |
12582 | 1790 if (XineramaIsActive(dsp) && !geometry_xy_changed) |
1791 { | |
1792 /* printf("XXXX Xinerama screen: x: %hd y: %hd\n",xinerama_x,xinerama_y); */ | |
1793 XMoveWindow(dsp, w, xinerama_x, xinerama_y); | |
1794 } | |
3990 | 1795 } |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
440
diff
changeset
|
1796 #endif |
3990 | 1797 |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1798 #ifdef HAVE_XF86VM |
12582 | 1799 void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width, |
1800 int *modeline_height) | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1801 { |
13828
b4ad5f0b550d
Fix erroneus extern declarations, fix wrong signedness of some vars
atmos4
parents:
13787
diff
changeset
|
1802 int vm_event, vm_error; |
b4ad5f0b550d
Fix erroneus extern declarations, fix wrong signedness of some vars
atmos4
parents:
13787
diff
changeset
|
1803 int vm_ver, vm_rev; |
12582 | 1804 int i, j, have_vm = 0; |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1805 |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1806 int modecount; |
12582 | 1807 |
1808 if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) | |
1809 { | |
1810 XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); | |
1811 mp_msg(MSGT_VO, MSGL_V, "XF86VidMode Extension v%i.%i\n", vm_ver, | |
1812 vm_rev); | |
1813 have_vm = 1; | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1814 } else |
12582 | 1815 mp_msg(MSGT_VO, MSGL_WARN, |
1816 "XF86VidMode Extenstion not available.\n"); | |
1817 | |
1818 if (have_vm) | |
1819 { | |
1820 if (vidmodes == NULL) | |
1821 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
1822 &vidmodes); | |
1823 j = 0; | |
1824 *modeline_width = vidmodes[0]->hdisplay; | |
1825 *modeline_height = vidmodes[0]->vdisplay; | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1826 |
12582 | 1827 for (i = 1; i < modecount; i++) |
1828 if ((vidmodes[i]->hdisplay >= X) | |
1829 && (vidmodes[i]->vdisplay >= Y)) | |
1830 if ((vidmodes[i]->hdisplay <= *modeline_width) | |
1831 && (vidmodes[i]->vdisplay <= *modeline_height)) | |
1832 { | |
1833 *modeline_width = vidmodes[i]->hdisplay; | |
1834 *modeline_height = vidmodes[i]->vdisplay; | |
1835 j = i; | |
1836 } | |
1837 | |
1838 mp_msg(MSGT_VO, MSGL_INFO, | |
1839 "XF86VM: Selected video mode %dx%d for image size %dx%d.\n", | |
1840 *modeline_width, *modeline_height, X, Y); | |
1841 XF86VidModeLockModeSwitch(mDisplay, mScreen, 0); | |
1842 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]); | |
1843 XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]); | |
1844 X = (vo_screenwidth - *modeline_width) / 2; | |
1845 Y = (vo_screenheight - *modeline_height) / 2; | |
1846 XF86VidModeSetViewPort(mDisplay, mScreen, X, Y); | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1847 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1848 } |
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1849 |
12582 | 1850 void vo_vm_close(Display * dpy) |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1851 { |
12582 | 1852 #ifdef HAVE_NEW_GUI |
1853 if (vidmodes != NULL && vo_window != None) | |
1854 #else | |
1855 if (vidmodes != NULL) | |
1856 #endif | |
1857 { | |
1858 int i, modecount; | |
1859 int screen; | |
1860 | |
1861 screen = DefaultScreen(dpy); | |
5019 | 1862 |
12582 | 1863 free(vidmodes); |
1864 vidmodes = NULL; | |
1865 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
1866 &vidmodes); | |
1867 for (i = 0; i < modecount; i++) | |
1868 if ((vidmodes[i]->hdisplay == vo_screenwidth) | |
1869 && (vidmodes[i]->vdisplay == vo_screenheight)) | |
1870 { | |
1871 mp_msg(MSGT_VO, MSGL_INFO, | |
1872 "Returning to original mode %dx%d\n", | |
1873 vo_screenwidth, vo_screenheight); | |
1874 break; | |
1875 } | |
5019 | 1876 |
12582 | 1877 XF86VidModeSwitchToMode(dpy, screen, vidmodes[i]); |
1878 XF86VidModeSwitchToMode(dpy, screen, vidmodes[i]); | |
1879 free(vidmodes); | |
1880 vidmodes = NULL; | |
1881 } | |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1882 } |
3990 | 1883 #endif |
4425
6144f63cbaa1
common -vm code, patch by Santi Bjar <tiarda@yahoo.es>
arpi
parents:
4181
diff
changeset
|
1884 |
12582 | 1885 #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
|
1886 |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1887 |
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 * 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
|
1890 * 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
|
1891 * 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
|
1892 * >= 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
|
1893 */ |
12582 | 1894 int vo_find_depth_from_visuals(Display * dpy, int screen, |
1895 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
|
1896 { |
12582 | 1897 XVisualInfo visual_tmpl; |
1898 XVisualInfo *visuals; | |
1899 int nvisuals, i; | |
1900 int bestvisual = -1; | |
1901 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
|
1902 |
12582 | 1903 visual_tmpl.screen = screen; |
1904 visual_tmpl.class = TrueColor; | |
1905 visuals = XGetVisualInfo(dpy, | |
1906 VisualScreenMask | VisualClassMask, | |
1907 &visual_tmpl, &nvisuals); | |
1908 if (visuals != NULL) | |
1909 { | |
1910 for (i = 0; i < nvisuals; i++) | |
1911 { | |
1912 mp_msg(MSGT_VO, MSGL_V, | |
1913 "vo: X11 truecolor visual %#x, depth %d, R:%lX G:%lX B:%lX\n", | |
1914 visuals[i].visualid, visuals[i].depth, | |
1915 visuals[i].red_mask, visuals[i].green_mask, | |
1916 visuals[i].blue_mask); | |
1917 /* | |
1918 * save the visual index and it's depth, if this is the first | |
1919 * truecolor visul, or a visual that is 'preferred' over the | |
1920 * previous 'best' visual | |
1921 */ | |
1922 if (bestvisual_depth == -1 | |
1923 || (visuals[i].depth >= 15 | |
1924 && (visuals[i].depth < bestvisual_depth | |
1925 || bestvisual_depth < 15))) | |
1926 { | |
1927 bestvisual = i; | |
1928 bestvisual_depth = visuals[i].depth; | |
1929 } | |
1930 } | |
1931 | |
1932 if (bestvisual != -1 && visual_return != NULL) | |
1933 *visual_return = visuals[bestvisual].visual; | |
1934 | |
1935 XFree(visuals); | |
7256
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1936 } |
12582 | 1937 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
|
1938 } |
ec6dd0a29d93
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
jkeil
parents:
7111
diff
changeset
|
1939 |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1940 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1941 static Colormap cmap = None; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1942 static XColor cols[256]; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1943 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
|
1944 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1945 |
12582 | 1946 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
|
1947 { |
12582 | 1948 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
|
1949 |
12582 | 1950 if (vinfo->class != DirectColor) |
1951 return XCreateColormap(mDisplay, mRootWin, vinfo->visual, | |
1952 AllocNone); | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1953 |
12582 | 1954 /* can this function get called twice or more? */ |
1955 if (cmap) | |
1956 return cmap; | |
1957 cm_size = vinfo->colormap_size; | |
1958 red_mask = vinfo->red_mask; | |
1959 green_mask = vinfo->green_mask; | |
1960 blue_mask = vinfo->blue_mask; | |
1961 ru = (red_mask & (red_mask - 1)) ^ red_mask; | |
1962 gu = (green_mask & (green_mask - 1)) ^ green_mask; | |
1963 bu = (blue_mask & (blue_mask - 1)) ^ blue_mask; | |
1964 rvu = 65536ull * ru / (red_mask + ru); | |
1965 gvu = 65536ull * gu / (green_mask + gu); | |
1966 bvu = 65536ull * bu / (blue_mask + bu); | |
1967 r = g = b = 0; | |
1968 rv = gv = bv = 0; | |
1969 m = DoRed | DoGreen | DoBlue; | |
1970 for (k = 0; k < cm_size; k++) | |
1971 { | |
1972 int t; | |
1973 | |
1974 cols[k].pixel = r | g | b; | |
1975 cols[k].red = rv; | |
1976 cols[k].green = gv; | |
1977 cols[k].blue = bv; | |
1978 cols[k].flags = m; | |
1979 t = (r + ru) & red_mask; | |
1980 if (t < r) | |
1981 m &= ~DoRed; | |
1982 r = t; | |
1983 t = (g + gu) & green_mask; | |
1984 if (t < g) | |
1985 m &= ~DoGreen; | |
1986 g = t; | |
1987 t = (b + bu) & blue_mask; | |
1988 if (t < b) | |
1989 m &= ~DoBlue; | |
1990 b = t; | |
1991 rv += rvu; | |
1992 gv += gvu; | |
1993 bv += bvu; | |
1994 } | |
1995 cmap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocAll); | |
1996 XStoreColors(mDisplay, cmap, cols, cm_size); | |
1997 return cmap; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1998 } |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
1999 |
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 * 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
|
2002 * 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
|
2003 * 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
|
2004 * 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
|
2005 */ |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2006 /* 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
|
2007 static int vo_gamma = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2008 static int vo_brightness = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2009 static int vo_contrast = 0; |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2010 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2011 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2012 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
|
2013 { |
12582 | 2014 float gamma, brightness, contrast; |
2015 float rf, gf, bf; | |
2016 int k; | |
2017 | |
2018 /* | |
2019 * IMPLEMENTME: consider using XF86VidModeSetGammaRamp in the case | |
2020 * of TrueColor-ed window but be careful: | |
2021 * unlike the colormaps, which are private for the X client | |
2022 * who created them and thus automatically destroyed on client | |
2023 * disconnect, this gamma ramp is a system-wide (X-server-wide) | |
2024 * setting and _must_ be restored before the process exit. | |
2025 * Unforunately when the process crashes (or get killed | |
2026 * for some reason) it is impossible to restore the setting, | |
2027 * and such behaviour could be rather annoying for the users. | |
2028 */ | |
2029 if (cmap == None) | |
2030 return VO_NOTAVAIL; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2031 |
12582 | 2032 if (!strcasecmp(name, "brightness")) |
2033 vo_brightness = value; | |
2034 else if (!strcasecmp(name, "contrast")) | |
2035 vo_contrast = value; | |
2036 else if (!strcasecmp(name, "gamma")) | |
2037 vo_gamma = value; | |
2038 else | |
2039 return VO_NOTIMPL; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2040 |
12582 | 2041 brightness = 0.01 * vo_brightness; |
2042 contrast = tan(0.0095 * (vo_contrast + 100) * M_PI / 4); | |
2043 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
|
2044 |
12582 | 2045 rf = (float) ((red_mask & (red_mask - 1)) ^ red_mask) / red_mask; |
2046 gf = (float) ((green_mask & (green_mask - 1)) ^ green_mask) / | |
2047 green_mask; | |
2048 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
|
2049 |
12582 | 2050 /* now recalculate the colormap using the newly set value */ |
2051 for (k = 0; k < cm_size; k++) | |
2052 { | |
2053 float s; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2054 |
12582 | 2055 s = pow(rf * k, gamma); |
2056 s = (s - 0.5) * contrast + 0.5; | |
2057 s += brightness; | |
2058 if (s < 0) | |
2059 s = 0; | |
2060 if (s > 1) | |
2061 s = 1; | |
2062 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
|
2063 |
12582 | 2064 s = pow(gf * k, gamma); |
2065 s = (s - 0.5) * contrast + 0.5; | |
2066 s += brightness; | |
2067 if (s < 0) | |
2068 s = 0; | |
2069 if (s > 1) | |
2070 s = 1; | |
2071 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
|
2072 |
12582 | 2073 s = pow(bf * k, gamma); |
2074 s = (s - 0.5) * contrast + 0.5; | |
2075 s += brightness; | |
2076 if (s < 0) | |
2077 s = 0; | |
2078 if (s > 1) | |
2079 s = 1; | |
2080 cols[k].blue = (unsigned short) (s * 65535); | |
2081 } | |
2082 | |
2083 XStoreColors(mDisplay, cmap, cols, cm_size); | |
2084 XFlush(mDisplay); | |
2085 return VO_TRUE; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2086 } |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2087 |
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2088 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
|
2089 { |
12582 | 2090 if (cmap == None) |
2091 return VO_NOTAVAIL; | |
2092 if (!strcasecmp(name, "brightness")) | |
2093 *value = vo_brightness; | |
2094 else if (!strcasecmp(name, "contrast")) | |
2095 *value = vo_contrast; | |
2096 else if (!strcasecmp(name, "gamma")) | |
2097 *value = vo_gamma; | |
2098 else | |
2099 return VO_NOTIMPL; | |
2100 return VO_TRUE; | |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2101 } |
12582 | 2102 |
10359 | 2103 #ifdef HAVE_XV |
2104 int vo_xv_set_eq(uint32_t xv_port, char *name, int value) | |
2105 { | |
2106 XvAttribute *attributes; | |
12582 | 2107 int i, howmany, xv_atom; |
7964
143d730908ae
here is a somewhat generic equalizer implementation for the X11 vo drivers
arpi
parents:
7766
diff
changeset
|
2108 |
10359 | 2109 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
|
2110 |
10359 | 2111 /* get available attributes */ |
2112 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); | |
2113 for (i = 0; i < howmany && attributes; i++) | |
12582 | 2114 if (attributes[i].flags & XvSettable) |
2115 { | |
2116 xv_atom = XInternAtom(mDisplay, attributes[i].name, True); | |
10359 | 2117 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
2118 then trigger it if it's ok so that the other values are at default upon query */ | |
12582 | 2119 if (xv_atom != None) |
2120 { | |
2121 int hue = 0, port_value, port_min, port_max; | |
10359 | 2122 |
12582 | 2123 if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && |
2124 (!strcasecmp(name, "brightness"))) | |
2125 port_value = value; | |
2126 else if (!strcmp(attributes[i].name, "XV_CONTRAST") && | |
2127 (!strcasecmp(name, "contrast"))) | |
2128 port_value = value; | |
2129 else if (!strcmp(attributes[i].name, "XV_SATURATION") && | |
2130 (!strcasecmp(name, "saturation"))) | |
2131 port_value = value; | |
2132 else if (!strcmp(attributes[i].name, "XV_HUE") && | |
2133 (!strcasecmp(name, "hue"))) | |
2134 { | |
2135 port_value = value; | |
2136 hue = 1; | |
2137 } else | |
10359 | 2138 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
12582 | 2139 if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && |
2140 (!strcasecmp(name, "red_intensity"))) | |
2141 port_value = value; | |
2142 else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") | |
2143 && (!strcasecmp(name, "green_intensity"))) | |
2144 port_value = value; | |
2145 else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") | |
2146 && (!strcasecmp(name, "blue_intensity"))) | |
2147 port_value = value; | |
2148 else | |
2149 continue; | |
2150 | |
2151 port_min = attributes[i].min_value; | |
2152 port_max = attributes[i].max_value; | |
10359 | 2153 |
12582 | 2154 /* nvidia hue workaround */ |
2155 if (hue && port_min == 0 && port_max == 360) | |
2156 { | |
2157 port_value = | |
2158 (port_value >= | |
2159 0) ? (port_value - 100) : (port_value + 100); | |
10359 | 2160 } |
12582 | 2161 // -100 -> min |
2162 // 0 -> (max+min)/2 | |
2163 // +100 -> max | |
2164 port_value = | |
2165 (port_value + 100) * (port_max - port_min) / 200 + | |
2166 port_min; | |
2167 XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value); | |
2168 return (VO_TRUE); | |
2169 } | |
2170 } | |
2171 return (VO_FALSE); | |
10359 | 2172 } |
2173 | |
2174 int vo_xv_get_eq(uint32_t xv_port, char *name, int *value) | |
2175 { | |
12582 | 2176 |
10359 | 2177 XvAttribute *attributes; |
12582 | 2178 int i, howmany, xv_atom; |
10359 | 2179 |
2180 /* get available attributes */ | |
2181 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); | |
2182 for (i = 0; i < howmany && attributes; i++) | |
12582 | 2183 if (attributes[i].flags & XvGettable) |
2184 { | |
2185 xv_atom = XInternAtom(mDisplay, attributes[i].name, True); | |
10359 | 2186 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
2187 then trigger it if it's ok so that the other values are at default upon query */ | |
12582 | 2188 if (xv_atom != None) |
2189 { | |
2190 int val, port_value = 0, port_min, port_max; | |
10359 | 2191 |
12582 | 2192 XvGetPortAttribute(mDisplay, xv_port, xv_atom, |
2193 &port_value); | |
2194 | |
2195 port_min = attributes[i].min_value; | |
2196 port_max = attributes[i].max_value; | |
2197 val = | |
2198 (port_value - port_min) * 200 / (port_max - port_min) - | |
2199 100; | |
10359 | 2200 |
12582 | 2201 if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && |
2202 (!strcasecmp(name, "brightness"))) | |
2203 *value = val; | |
2204 else if (!strcmp(attributes[i].name, "XV_CONTRAST") && | |
2205 (!strcasecmp(name, "contrast"))) | |
2206 *value = val; | |
2207 else if (!strcmp(attributes[i].name, "XV_SATURATION") && | |
2208 (!strcasecmp(name, "saturation"))) | |
2209 *value = val; | |
2210 else if (!strcmp(attributes[i].name, "XV_HUE") && | |
2211 (!strcasecmp(name, "hue"))) | |
2212 { | |
2213 /* nasty nvidia detect */ | |
2214 if (port_min == 0 && port_max == 360) | |
2215 *value = (val >= 0) ? (val - 100) : (val + 100); | |
2216 else | |
2217 *value = val; | |
2218 } else | |
10359 | 2219 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
12582 | 2220 if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && |
2221 (!strcasecmp(name, "red_intensity"))) | |
2222 *value = val; | |
2223 else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") | |
2224 && (!strcasecmp(name, "green_intensity"))) | |
2225 *value = val; | |
2226 else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") | |
2227 && (!strcasecmp(name, "blue_intensity"))) | |
2228 *value = val; | |
2229 else | |
2230 continue; | |
10359 | 2231 |
12582 | 2232 mp_dbg(MSGT_VO, MSGL_V, "xv_get_eq called! (%s, %d)\n", |
2233 name, *value); | |
2234 return (VO_TRUE); | |
2235 } | |
2236 } | |
2237 return (VO_FALSE); | |
10359 | 2238 } |
2239 | |
2240 #endif |