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