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