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