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