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