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