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