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