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