9 #include "x11_common.h"
19 #include "video_out.h"
23 #include "osdep/timer.h"
27 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
31 #include <X11/extensions/dpms.h>
35 #include <X11/extensions/Xinerama.h>
39 #include <X11/extensions/xf86vmode.h>
43 #include <X11/XF86keysym.h>
47 #include <X11/extensions/Xv.h>
48 #include <X11/extensions/Xvlib.h>
50 #include "subopt-helper.h"
53 #include "input/input.h"
54 #include "input/mouse.h"
57 #include "Gui/interface.h"
61 #define WIN_LAYER_ONBOTTOM 2
62 #define WIN_LAYER_NORMAL 4
63 #define WIN_LAYER_ONTOP 6
64 #define WIN_LAYER_ABOVE_DOCK 10
66 int fs_layer
= WIN_LAYER_ABOVE_DOCK
;
67 static int orig_layer
= 0;
68 static int old_gravity
= NorthWestGravity
;
70 int stop_xscreensaver
= 0;
72 static int dpms_disabled
= 0;
73 static int timeout_save
= 0;
74 static int kdescreensaver_was_running
= 0;
76 char *mDisplayName
= NULL
;
77 Display
*mDisplay
= NULL
;
82 /* output window id */
83 int vo_mouse_autohide
= 0;
85 int vo_fs_type
= 0; // needs to be accessible for GUI X11 code
86 static int vo_fs_flip
= 0;
87 char **vo_fstype_list
;
89 /* if equal to 1 means that WM is a metacity (broken as hell) */
90 int metacity_hack
= 0;
92 static Atom XA_NET_SUPPORTED
;
93 static Atom XA_NET_WM_STATE
;
94 static Atom XA_NET_WM_STATE_FULLSCREEN
;
95 static Atom XA_NET_WM_STATE_ABOVE
;
96 static Atom XA_NET_WM_STATE_STAYS_ON_TOP
;
97 static Atom XA_NET_WM_STATE_BELOW
;
98 static Atom XA_NET_WM_PID
;
99 static Atom XA_WIN_PROTOCOLS
;
100 static Atom XA_WIN_LAYER
;
101 static Atom XA_WIN_HINTS
;
102 static Atom XA_BLACKBOX_PID
;
103 static Atom XAWM_PROTOCOLS
;
104 static Atom XAWM_DELETE_WINDOW
;
106 #define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False)
108 static int vo_old_x
= 0;
109 static int vo_old_y
= 0;
110 static int vo_old_width
= 0;
111 static int vo_old_height
= 0;
114 XF86VidModeModeInfo
**vidmodes
= NULL
;
115 XF86VidModeModeLine modeline
;
118 static int vo_x11_get_fs_type(int supported
);
122 * Sends the EWMH fullscreen state event.
124 * action: could be on of _NET_WM_STATE_REMOVE -- remove state
125 * _NET_WM_STATE_ADD -- add state
126 * _NET_WM_STATE_TOGGLE -- toggle
128 void vo_x11_ewmh_fullscreen(int action
)
130 assert(action
== _NET_WM_STATE_REMOVE
||
131 action
== _NET_WM_STATE_ADD
|| action
== _NET_WM_STATE_TOGGLE
);
133 if (vo_fs_type
& vo_wm_FULLSCREEN
)
137 /* init X event structure for _NET_WM_FULLSCREEN client msg */
138 xev
.xclient
.type
= ClientMessage
;
139 xev
.xclient
.serial
= 0;
140 xev
.xclient
.send_event
= True
;
141 xev
.xclient
.message_type
= XInternAtom(mDisplay
,
142 "_NET_WM_STATE", False
);
143 xev
.xclient
.window
= vo_window
;
144 xev
.xclient
.format
= 32;
145 xev
.xclient
.data
.l
[0] = action
;
146 xev
.xclient
.data
.l
[1] = XInternAtom(mDisplay
,
147 "_NET_WM_STATE_FULLSCREEN",
149 xev
.xclient
.data
.l
[2] = 0;
150 xev
.xclient
.data
.l
[3] = 0;
151 xev
.xclient
.data
.l
[4] = 0;
153 /* finally send that damn thing */
154 if (!XSendEvent(mDisplay
, DefaultRootWindow(mDisplay
), False
,
155 SubstructureRedirectMask
| SubstructureNotifyMask
,
158 mp_msg(MSGT_VO
, MSGL_ERR
, MSGTR_EwmhFullscreenStateFailed
);
163 void vo_hidecursor(Display
* disp
, Window win
)
169 static char bm_no_data
[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
172 return; // do not hide, if we're playing at rootwin
174 colormap
= DefaultColormap(disp
, DefaultScreen(disp
));
175 if ( !XAllocNamedColor(disp
, colormap
, "black", &black
, &dummy
) )
177 return; // color alloc failed, give up
179 bm_no
= XCreateBitmapFromData(disp
, win
, bm_no_data
, 8, 8);
180 no_ptr
= XCreatePixmapCursor(disp
, bm_no
, bm_no
, &black
, &black
, 0, 0);
181 XDefineCursor(disp
, win
, no_ptr
);
182 XFreeCursor(disp
, no_ptr
);
184 XFreePixmap(disp
, bm_no
);
185 XFreeColors(disp
,colormap
,&black
.pixel
,1,0);
188 void vo_showcursor(Display
* disp
, Window win
)
192 XDefineCursor(disp
, win
, 0);
195 static int x11_errorhandler(Display
* display
, XErrorEvent
* event
)
200 XGetErrorText(display
, event
->error_code
, (char *) &msg
, MSGLEN
);
202 mp_msg(MSGT_VO
, MSGL_ERR
, "X11 error: %s\n", msg
);
204 mp_msg(MSGT_VO
, MSGL_V
,
205 "Type: %x, display: %p, resourceid: %lx, serial: %lx\n",
206 event
->type
, event
->display
, event
->resourceid
, event
->serial
);
207 mp_msg(MSGT_VO
, MSGL_V
,
208 "Error code: %x, request code: %x, minor code: %x\n",
209 event
->error_code
, event
->request_code
, event
->minor_code
);
212 //exit_player("X11 error");
216 void fstype_help(void)
218 mp_msg(MSGT_VO
, MSGL_INFO
, MSGTR_AvailableFsType
);
219 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_FULL_SCREEN_TYPES\n");
221 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "none",
222 "don't set fullscreen window layer");
223 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "layer",
224 "use _WIN_LAYER hint with default layer");
225 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "layer=<0..15>",
226 "use _WIN_LAYER hint with a given layer number");
227 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "netwm",
228 "force NETWM style");
229 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "above",
230 "use _NETWM_STATE_ABOVE hint if available");
231 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "below",
232 "use _NETWM_STATE_BELOW hint if available");
233 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "fullscreen",
234 "use _NETWM_STATE_FULLSCREEN hint if availale");
235 mp_msg(MSGT_VO
, MSGL_INFO
, " %-15s %s\n", "stays_on_top",
236 "use _NETWM_STATE_STAYS_ON_TOP hint if available");
237 mp_msg(MSGT_VO
, MSGL_INFO
,
238 "You can also negate the settings with simply putting '-' in the beginning");
239 mp_msg(MSGT_VO
, MSGL_INFO
, "\n");
242 static void fstype_dump(int fstype
)
246 mp_msg(MSGT_VO
, MSGL_V
, "[x11] Current fstype setting honours");
247 if (fstype
& vo_wm_LAYER
)
248 mp_msg(MSGT_VO
, MSGL_V
, " LAYER");
249 if (fstype
& vo_wm_FULLSCREEN
)
250 mp_msg(MSGT_VO
, MSGL_V
, " FULLSCREEN");
251 if (fstype
& vo_wm_STAYS_ON_TOP
)
252 mp_msg(MSGT_VO
, MSGL_V
, " STAYS_ON_TOP");
253 if (fstype
& vo_wm_ABOVE
)
254 mp_msg(MSGT_VO
, MSGL_V
, " ABOVE");
255 if (fstype
& vo_wm_BELOW
)
256 mp_msg(MSGT_VO
, MSGL_V
, " BELOW");
257 mp_msg(MSGT_VO
, MSGL_V
, " X atoms\n");
259 mp_msg(MSGT_VO
, MSGL_V
,
260 "[x11] Current fstype setting doesn't honour any X atoms\n");
263 static int net_wm_support_state_test(Atom atom
)
265 #define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } }
267 NET_WM_STATE_TEST(FULLSCREEN
);
268 NET_WM_STATE_TEST(ABOVE
);
269 NET_WM_STATE_TEST(STAYS_ON_TOP
);
270 NET_WM_STATE_TEST(BELOW
);
274 static int x11_get_property(Atom type
, Atom
** args
, unsigned long *nitems
)
277 unsigned long bytesafter
;
280 XGetWindowProperty(mDisplay
, mRootWin
, type
, 0, 16384, False
,
281 AnyPropertyType
, &type
, &format
, nitems
,
282 &bytesafter
, (unsigned char **) args
)
286 static int vo_wm_detect(void)
290 unsigned long nitems
;
296 // -- supports layers
297 if (x11_get_property(XA_WIN_PROTOCOLS
, &args
, &nitems
))
299 mp_msg(MSGT_VO
, MSGL_V
, "[x11] Detected wm supports layers.\n");
300 for (i
= 0; i
< nitems
; i
++)
302 if (args
[i
] == XA_WIN_LAYER
)
307 // metacity is the only manager I know which reports support only for _WIN_LAYER
308 // hint in _WIN_PROTOCOLS (what's more support for it is broken)
312 if (wm
&& (metacity_hack
== 1))
314 // metacity reports that it supports layers, but it is not really truth :-)
316 mp_msg(MSGT_VO
, MSGL_V
,
317 "[x11] Using workaround for Metacity bugs.\n");
321 if (x11_get_property(XA_NET_SUPPORTED
, &args
, &nitems
))
323 mp_msg(MSGT_VO
, MSGL_V
, "[x11] Detected wm supports NetWM.\n");
324 for (i
= 0; i
< nitems
; i
++)
325 wm
|= net_wm_support_state_test(args
[i
]);
328 // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support
329 // (in their implementation it only changes internal state of window, nothing more!!!)
330 if (wm
& vo_wm_FULLSCREEN
)
332 if (x11_get_property(XA_BLACKBOX_PID
, &args
, &nitems
))
334 mp_msg(MSGT_VO
, MSGL_V
,
335 "[x11] Detected wm is a broken OpenBox.\n");
336 wm
^= vo_wm_FULLSCREEN
;
344 mp_msg(MSGT_VO
, MSGL_V
, "[x11] Unknown wm type...\n");
348 static void init_atoms(void)
350 XA_INIT(_NET_SUPPORTED
);
351 XA_INIT(_NET_WM_STATE
);
352 XA_INIT(_NET_WM_STATE_FULLSCREEN
);
353 XA_INIT(_NET_WM_STATE_ABOVE
);
354 XA_INIT(_NET_WM_STATE_STAYS_ON_TOP
);
355 XA_INIT(_NET_WM_STATE_BELOW
);
356 XA_INIT(_NET_WM_PID
);
357 XA_INIT(_WIN_PROTOCOLS
);
360 XA_INIT(_BLACKBOX_PID
);
361 XA_INIT(WM_PROTOCOLS
);
362 XA_INIT(WM_DELETE_WINDOW
);
365 void update_xinerama_info(void) {
366 int screen
= xinerama_screen
;
367 xinerama_x
= xinerama_y
= 0;
369 if (screen
>= -1 && XineramaIsActive(mDisplay
))
371 XineramaScreenInfo
*screens
;
374 screens
= XineramaQueryScreens(mDisplay
, &num_screens
);
375 if (screen
>= num_screens
)
376 screen
= num_screens
- 1;
378 int x
= vo_dx
+ vo_dwidth
/ 2;
379 int y
= vo_dy
+ vo_dheight
/ 2;
380 for (screen
= num_screens
- 1; screen
> 0; screen
--) {
381 int left
= screens
[screen
].x_org
;
382 int right
= left
+ screens
[screen
].width
;
383 int top
= screens
[screen
].y_org
;
384 int bottom
= top
+ screens
[screen
].height
;
385 if (left
<= x
&& x
<= right
&& top
<= y
&& y
<= bottom
)
391 vo_screenwidth
= screens
[screen
].width
;
392 vo_screenheight
= screens
[screen
].height
;
393 xinerama_x
= screens
[screen
].x_org
;
394 xinerama_y
= screens
[screen
].y_org
;
399 aspect_save_screenres(vo_screenwidth
, vo_screenheight
);
408 // char * DisplayName = ":0.0";
409 // Display * mDisplay;
410 XImage
*mXImage
= NULL
;
413 XWindowAttributes attribs
;
417 WinID
= 0; // use root win
419 if (vo_depthonscreen
)
422 return 1; // already called
425 XSetErrorHandler(x11_errorhandler
);
429 if (!(mDisplayName
= getenv("DISPLAY")))
430 mDisplayName
= strdup(":0.0");
432 dispName
= XDisplayName(mDisplayName
);
435 mp_msg(MSGT_VO
, MSGL_V
, "X11 opening display: %s\n", dispName
);
437 mDisplay
= XOpenDisplay(dispName
);
440 mp_msg(MSGT_VO
, MSGL_ERR
,
441 "vo: couldn't open the X11 display (%s)!\n", dispName
);
444 mScreen
= DefaultScreen(mDisplay
); // Screen ID.
445 mRootWin
= RootWindow(mDisplay
, mScreen
); // Root window ID.
453 XF86VidModeGetModeLine(mDisplay
, mScreen
, &clock
, &modeline
);
455 vo_screenwidth
= modeline
.hdisplay
;
456 if (!vo_screenheight
)
457 vo_screenheight
= modeline
.vdisplay
;
462 vo_screenwidth
= DisplayWidth(mDisplay
, mScreen
);
463 if (!vo_screenheight
)
464 vo_screenheight
= DisplayHeight(mDisplay
, mScreen
);
466 // get color depth (from root window, or the best visual):
467 XGetWindowAttributes(mDisplay
, mRootWin
, &attribs
);
468 depth
= attribs
.depth
;
470 if (depth
!= 15 && depth
!= 16 && depth
!= 24 && depth
!= 32)
474 depth
= vo_find_depth_from_visuals(mDisplay
, mScreen
, &visual
);
476 mXImage
= XCreateImage(mDisplay
, visual
, depth
, ZPixmap
,
477 0, NULL
, 1, 1, 8, 1);
480 XGetImage(mDisplay
, mRootWin
, 0, 0, 1, 1, AllPlanes
, ZPixmap
);
482 vo_depthonscreen
= depth
; // display depth on screen
484 // get bits/pixel from XImage structure:
491 * for the depth==24 case, the XImage structures might use
492 * 24 or 32 bits of data per pixel. The global variable
493 * vo_depthonscreen stores the amount of data per pixel in the
496 * Maybe we should rename vo_depthonscreen to (or add) vo_bpp?
498 bpp
= mXImage
->bits_per_pixel
;
499 if ((vo_depthonscreen
+ 7) / 8 != (bpp
+ 7) / 8)
500 vo_depthonscreen
= bpp
; // by A'rpi
502 mXImage
->red_mask
| mXImage
->green_mask
| mXImage
->blue_mask
;
503 mp_msg(MSGT_VO
, MSGL_V
,
504 "vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", mask
,
505 mXImage
->red_mask
, mXImage
->green_mask
, mXImage
->blue_mask
);
506 XDestroyImage(mXImage
);
508 if (((vo_depthonscreen
+ 7) / 8) == 2)
511 vo_depthonscreen
= 15;
512 else if (mask
== 0xFFFF)
513 vo_depthonscreen
= 16;
515 // XCloseDisplay( mDisplay );
516 /* slightly improved local display detection AST */
517 if (strncmp(dispName
, "unix:", 5) == 0)
519 else if (strncmp(dispName
, "localhost:", 10) == 0)
521 if (*dispName
== ':' && atoi(dispName
+ 1) < 10)
525 mp_msg(MSGT_VO
, MSGL_V
,
526 "vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n",
527 vo_screenwidth
, vo_screenheight
, depth
, vo_depthonscreen
,
528 dispName
, mLocalDisplay
? "local" : "remote");
530 vo_wm_type
= vo_wm_detect();
532 vo_fs_type
= vo_x11_get_fs_type(vo_wm_type
);
534 fstype_dump(vo_fs_type
);
544 mp_msg(MSGT_VO
, MSGL_V
,
545 "vo: x11 uninit called but X11 not inited..\n");
548 // if( !vo_depthonscreen ) return;
549 mp_msg(MSGT_VO
, MSGL_V
, "vo: uninit ...\n");
550 XSetErrorHandler(NULL
);
551 XCloseDisplay(mDisplay
);
552 vo_depthonscreen
= 0;
556 #include "osdep/keycodes.h"
559 extern void mplayer_put_key(int code
);
561 #ifdef XF86XK_AudioPause
562 void vo_x11_putkey_ext(int keysym
)
566 case XF86XK_AudioPause
:
567 mplayer_put_key(KEY_PAUSE
);
569 case XF86XK_AudioStop
:
570 mplayer_put_key(KEY_STOP
);
572 case XF86XK_AudioPrev
:
573 mplayer_put_key(KEY_PREV
);
575 case XF86XK_AudioNext
:
576 mplayer_put_key(KEY_NEXT
);
584 void vo_x11_putkey(int key
)
589 mplayer_put_key(KEY_LEFT
);
592 mplayer_put_key(KEY_RIGHT
);
595 mplayer_put_key(KEY_UP
);
598 mplayer_put_key(KEY_DOWN
);
601 mplayer_put_key(' ');
604 mplayer_put_key(KEY_ESC
);
607 mplayer_put_key(KEY_TAB
);
610 mplayer_put_key(KEY_ENTER
);
613 mplayer_put_key(KEY_BS
);
616 mplayer_put_key(KEY_DELETE
);
619 mplayer_put_key(KEY_INSERT
);
622 mplayer_put_key(KEY_HOME
);
625 mplayer_put_key(KEY_END
);
628 mplayer_put_key(KEY_PAGE_UP
);
631 mplayer_put_key(KEY_PAGE_DOWN
);
634 mplayer_put_key(KEY_F
+ 1);
637 mplayer_put_key(KEY_F
+ 2);
640 mplayer_put_key(KEY_F
+ 3);
643 mplayer_put_key(KEY_F
+ 4);
646 mplayer_put_key(KEY_F
+ 5);
649 mplayer_put_key(KEY_F
+ 6);
652 mplayer_put_key(KEY_F
+ 7);
655 mplayer_put_key(KEY_F
+ 8);
658 mplayer_put_key(KEY_F
+ 9);
661 mplayer_put_key(KEY_F
+ 10);
664 mplayer_put_key(KEY_F
+ 11);
667 mplayer_put_key(KEY_F
+ 12);
671 mplayer_put_key('-');
675 mplayer_put_key('+');
679 mplayer_put_key('*');
683 mplayer_put_key('/');
686 mplayer_put_key('<');
689 mplayer_put_key('>');
692 mplayer_put_key(KEY_KP0
);
696 mplayer_put_key(KEY_KP1
);
700 mplayer_put_key(KEY_KP2
);
704 mplayer_put_key(KEY_KP3
);
708 mplayer_put_key(KEY_KP4
);
712 mplayer_put_key(KEY_KP5
);
716 mplayer_put_key(KEY_KP6
);
720 mplayer_put_key(KEY_KP7
);
724 mplayer_put_key(KEY_KP8
);
728 mplayer_put_key(KEY_KP9
);
731 mplayer_put_key(KEY_KPDEC
);
734 mplayer_put_key(KEY_KPINS
);
737 mplayer_put_key(KEY_KPDEL
);
740 mplayer_put_key(KEY_KPENTER
);
743 mplayer_put_key('`');
746 mplayer_put_key('~');
749 mplayer_put_key('!');
752 mplayer_put_key('@');
755 mplayer_put_key('#');
758 mplayer_put_key('$');
761 mplayer_put_key('%');
764 mplayer_put_key('^');
767 mplayer_put_key('&');
770 mplayer_put_key('(');
773 mplayer_put_key(')');
776 mplayer_put_key('_');
779 mplayer_put_key('{');
782 mplayer_put_key('}');
785 mplayer_put_key(':');
788 mplayer_put_key(';');
791 mplayer_put_key('\"');
794 mplayer_put_key('\'');
797 mplayer_put_key(',');
800 mplayer_put_key('.');
803 mplayer_put_key('?');
806 mplayer_put_key('\\');
809 mplayer_put_key('|');
812 mplayer_put_key('=');
815 mplayer_put_key('[');
818 mplayer_put_key(']');
823 if ((key
>= 'a' && key
<= 'z') || (key
>= 'A' && key
<= 'Z') ||
824 (key
>= '0' && key
<= '9'))
825 mplayer_put_key(key
);
831 // ----- Motif header: -------
833 #define MWM_HINTS_FUNCTIONS (1L << 0)
834 #define MWM_HINTS_DECORATIONS (1L << 1)
835 #define MWM_HINTS_INPUT_MODE (1L << 2)
836 #define MWM_HINTS_STATUS (1L << 3)
838 #define MWM_FUNC_ALL (1L << 0)
839 #define MWM_FUNC_RESIZE (1L << 1)
840 #define MWM_FUNC_MOVE (1L << 2)
841 #define MWM_FUNC_MINIMIZE (1L << 3)
842 #define MWM_FUNC_MAXIMIZE (1L << 4)
843 #define MWM_FUNC_CLOSE (1L << 5)
845 #define MWM_DECOR_ALL (1L << 0)
846 #define MWM_DECOR_BORDER (1L << 1)
847 #define MWM_DECOR_RESIZEH (1L << 2)
848 #define MWM_DECOR_TITLE (1L << 3)
849 #define MWM_DECOR_MENU (1L << 4)
850 #define MWM_DECOR_MINIMIZE (1L << 5)
851 #define MWM_DECOR_MAXIMIZE (1L << 6)
853 #define MWM_INPUT_MODELESS 0
854 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
855 #define MWM_INPUT_SYSTEM_MODAL 2
856 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
857 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
859 #define MWM_TEAROFF_WINDOW (1L<<0)
870 static MotifWmHints vo_MotifWmHints
;
871 static Atom vo_MotifHints
= None
;
873 void vo_x11_decoration(Display
* vo_Display
, Window w
, int d
)
875 static unsigned int olddecor
= MWM_DECOR_ALL
;
876 static unsigned int oldfuncs
=
877 MWM_FUNC_MOVE
| MWM_FUNC_CLOSE
| MWM_FUNC_MINIMIZE
|
878 MWM_FUNC_MAXIMIZE
| MWM_FUNC_RESIZE
;
881 unsigned long mn
, mb
;
888 XSetTransientForHint(vo_Display
, w
,
889 RootWindow(vo_Display
, mScreen
));
892 vo_MotifHints
= XInternAtom(vo_Display
, "_MOTIF_WM_HINTS", 0);
893 if (vo_MotifHints
!= None
)
897 MotifWmHints
*mhints
= NULL
;
899 XGetWindowProperty(vo_Display
, w
, vo_MotifHints
, 0, 20, False
,
900 vo_MotifHints
, &mtype
, &mformat
, &mn
,
901 &mb
, (unsigned char **) &mhints
);
904 if (mhints
->flags
& MWM_HINTS_DECORATIONS
)
905 olddecor
= mhints
->decorations
;
906 if (mhints
->flags
& MWM_HINTS_FUNCTIONS
)
907 oldfuncs
= mhints
->functions
;
912 memset(&vo_MotifWmHints
, 0, sizeof(MotifWmHints
));
913 vo_MotifWmHints
.flags
=
914 MWM_HINTS_FUNCTIONS
| MWM_HINTS_DECORATIONS
;
917 vo_MotifWmHints
.functions
= oldfuncs
;
921 vo_MotifWmHints
.decorations
=
922 d
| ((vo_fsmode
& 2) ? 0 : MWM_DECOR_MENU
);
924 vo_MotifWmHints
.decorations
=
925 d
| ((vo_fsmode
& 2) ? MWM_DECOR_MENU
: 0);
927 XChangeProperty(vo_Display
, w
, vo_MotifHints
, vo_MotifHints
, 32,
929 (unsigned char *) &vo_MotifWmHints
,
930 (vo_fsmode
& 4) ? 4 : 5);
934 void vo_x11_classhint(Display
* display
, Window window
, char *name
)
937 pid_t pid
= getpid();
939 wmClass
.res_name
= name
;
940 wmClass
.res_class
= "MPlayer";
941 XSetClassHint(display
, window
, &wmClass
);
942 XChangeProperty(display
, window
, XA_NET_WM_PID
, XA_CARDINAL
, 32,
943 PropModeReplace
, (unsigned char *) &pid
, 1);
946 Window vo_window
= None
;
952 void vo_setwindow(Window w
, GC g
)
959 void vo_x11_uninit(void)
962 if (vo_window
!= None
)
963 vo_showcursor(mDisplay
, vo_window
);
967 XFreeGC(mDisplay
, f_gc
);
971 /* destroy window only if it's not controlled by GUI */
977 XSetBackground(mDisplay
, vo_gc
, 0);
978 XFreeGC(mDisplay
, vo_gc
);
981 if (vo_window
!= None
)
983 XClearWindow(mDisplay
, vo_window
);
988 XUnmapWindow(mDisplay
, vo_window
);
989 XDestroyWindow(mDisplay
, vo_window
);
992 XNextEvent(mDisplay
, &xev
);
994 while (xev
.type
!= DestroyNotify
995 || xev
.xdestroywindow
.event
!= vo_window
);
1000 vo_old_width
= vo_old_height
= 0;
1004 static unsigned int mouse_timer
;
1005 static int mouse_waiting_hide
;
1007 int vo_x11_check_events(Display
* mydisplay
)
1013 static XComposeStatus stat
;
1015 // unsigned long vo_KeyTable[512];
1017 if ((vo_mouse_autohide
) && mouse_waiting_hide
&&
1018 (GetTimerMS() - mouse_timer
>= 1000)) {
1019 vo_hidecursor(mydisplay
, vo_window
);
1020 mouse_waiting_hide
= 0;
1023 while (XPending(mydisplay
))
1025 XNextEvent(mydisplay
, &Event
);
1029 guiGetEvent(0, (char *) &Event
);
1030 if (vo_window
!= Event
.xany
.window
)
1034 // printf("\rEvent.type=%X \n",Event.type);
1038 ret
|= VO_EVENT_EXPOSE
;
1040 case ConfigureNotify
:
1041 // if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break;
1042 // if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
1043 if (vo_window
== None
)
1045 vo_dwidth
= Event
.xconfigure
.width
;
1046 vo_dheight
= Event
.xconfigure
.height
;
1048 /* when resizing, x and y are zero :( */
1049 vo_dx
= Event
.xconfigure
.x
;
1050 vo_dy
= Event
.xconfigure
.y
;
1057 XGetGeometry(mydisplay
, vo_window
, &root
, &foo
, &foo
,
1058 &foo
/*width */ , &foo
/*height */ , &foo
,
1060 XTranslateCoordinates(mydisplay
, vo_window
, root
, 0, 0,
1061 &vo_dx
, &vo_dy
, &win
);
1064 ret
|= VO_EVENT_RESIZE
;
1071 if ( use_gui
) { break; }
1074 XLookupString(&Event
.xkey
, buf
, sizeof(buf
), &keySym
,
1076 #ifdef XF86XK_AudioPause
1077 vo_x11_putkey_ext(keySym
);
1080 ((keySym
& 0xff00) !=
1081 0 ? ((keySym
& 0x00ff) + 256) : (keySym
));
1083 ret
|= VO_EVENT_KEYPRESS
;
1087 if (vo_mouse_autohide
)
1089 vo_showcursor(mydisplay
, vo_window
);
1090 mouse_waiting_hide
= 1;
1091 mouse_timer
= GetTimerMS();
1095 if (vo_mouse_autohide
)
1097 vo_showcursor(mydisplay
, vo_window
);
1098 mouse_waiting_hide
= 1;
1099 mouse_timer
= GetTimerMS();
1101 // Ignore mouse whell press event
1102 if (Event
.xbutton
.button
> 3)
1104 mplayer_put_key(MOUSE_BTN0
+ Event
.xbutton
.button
- 1);
1108 // Ignor mouse button 1 - 3 under gui
1109 if (use_gui
&& (Event
.xbutton
.button
>= 1)
1110 && (Event
.xbutton
.button
<= 3))
1113 mplayer_put_key((MOUSE_BTN0
+ Event
.xbutton
.button
-
1117 if (vo_mouse_autohide
)
1119 vo_showcursor(mydisplay
, vo_window
);
1120 mouse_waiting_hide
= 1;
1121 mouse_timer
= GetTimerMS();
1124 // Ignor mouse button 1 - 3 under gui
1125 if (use_gui
&& (Event
.xbutton
.button
>= 1)
1126 && (Event
.xbutton
.button
<= 3))
1129 mplayer_put_key(MOUSE_BTN0
+ Event
.xbutton
.button
- 1);
1131 case PropertyNotify
:
1134 XGetAtomName(mydisplay
, Event
.xproperty
.atom
);
1139 // fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",vo_window,name,Event.xproperty.atom );
1145 vo_hint
.win_gravity
= old_gravity
;
1146 XSetWMNormalHints(mDisplay
, vo_window
, &vo_hint
);
1150 if (Event
.xclient
.message_type
== XAWM_PROTOCOLS
&&
1151 Event
.xclient
.data
.l
[0] == XAWM_DELETE_WINDOW
)
1152 mplayer_put_key(KEY_CLOSE_WIN
);
1160 * \brief sets the size and position of the non-fullscreen window.
1162 void vo_x11_nofs_sizepos(int x
, int y
, int width
, int height
)
1167 vo_old_width
= width
;
1168 vo_old_height
= height
;
1173 vo_dheight
= height
;
1174 XMoveResizeWindow(mDisplay
, vo_window
, x
, y
, width
, height
);
1178 void vo_x11_sizehint(int x
, int y
, int width
, int height
, int max
)
1180 vo_hint
.flags
= PPosition
| PSize
| PWinGravity
;
1183 vo_hint
.flags
|= PAspect
;
1184 vo_hint
.min_aspect
.x
= width
;
1185 vo_hint
.min_aspect
.y
= height
;
1186 vo_hint
.max_aspect
.x
= width
;
1187 vo_hint
.max_aspect
.y
= height
;
1192 vo_hint
.width
= width
;
1193 vo_hint
.height
= height
;
1196 vo_hint
.max_width
= width
;
1197 vo_hint
.max_height
= height
;
1198 vo_hint
.flags
|= PMaxSize
;
1201 vo_hint
.max_width
= 0;
1202 vo_hint
.max_height
= 0;
1205 // set min height/width to 4 to avoid off by one errors
1206 // and because mga_vid requires a minial size of 4 pixel
1207 vo_hint
.min_width
= vo_hint
.min_height
= 4;
1208 vo_hint
.flags
|= PMinSize
;
1210 vo_hint
.win_gravity
= StaticGravity
;
1211 XSetWMNormalHints(mDisplay
, vo_window
, &vo_hint
);
1214 static int vo_x11_get_gnome_layer(Display
* mDisplay
, Window win
)
1218 unsigned long nitems
;
1219 unsigned long bytesafter
;
1220 unsigned short *args
= NULL
;
1222 if (XGetWindowProperty(mDisplay
, win
, XA_WIN_LAYER
, 0, 16384,
1223 False
, AnyPropertyType
, &type
, &format
, &nitems
,
1225 (unsigned char **) &args
) == Success
1226 && nitems
> 0 && args
)
1228 mp_msg(MSGT_VO
, MSGL_V
, "[x11] original window layer is %d.\n",
1232 return WIN_LAYER_NORMAL
;
1236 Window
vo_x11_create_smooth_window(Display
* mDisplay
, Window mRoot
,
1237 Visual
* vis
, int x
, int y
,
1238 unsigned int width
, unsigned int height
,
1239 int depth
, Colormap col_map
)
1241 unsigned long xswamask
= CWBackingStore
| CWBorderPixel
;
1242 XSetWindowAttributes xswa
;
1245 if (col_map
!= CopyFromParent
)
1247 xswa
.colormap
= col_map
;
1248 xswamask
|= CWColormap
;
1250 xswa
.background_pixel
= 0;
1251 xswa
.border_pixel
= 0;
1252 xswa
.backing_store
= Always
;
1253 xswa
.bit_gravity
= StaticGravity
;
1256 XCreateWindow(mDisplay
, mRootWin
, x
, y
, width
, height
, 0, depth
,
1257 CopyFromParent
, vis
, xswamask
, &xswa
);
1258 XSetWMProtocols(mDisplay
, ret_win
, &XAWM_DELETE_WINDOW
, 1);
1260 f_gc
= XCreateGC(mDisplay
, ret_win
, 0, 0);
1261 XSetForeground(mDisplay
, f_gc
, 0);
1267 void vo_x11_clearwindow_part(Display
* mDisplay
, Window vo_window
,
1268 int img_width
, int img_height
, int use_fs
)
1270 int u_dheight
, u_dwidth
, left_ov
, left_ov2
;
1275 u_dheight
= use_fs
? vo_screenheight
: vo_dheight
;
1276 u_dwidth
= use_fs
? vo_screenwidth
: vo_dwidth
;
1277 if ((u_dheight
<= img_height
) && (u_dwidth
<= img_width
))
1280 left_ov
= (u_dheight
- img_height
) / 2;
1281 left_ov2
= (u_dwidth
- img_width
) / 2;
1283 XFillRectangle(mDisplay
, vo_window
, f_gc
, 0, 0, u_dwidth
, left_ov
);
1284 XFillRectangle(mDisplay
, vo_window
, f_gc
, 0, u_dheight
- left_ov
- 1,
1285 u_dwidth
, left_ov
+ 1);
1287 if (u_dwidth
> img_width
)
1289 XFillRectangle(mDisplay
, vo_window
, f_gc
, 0, left_ov
, left_ov2
,
1291 XFillRectangle(mDisplay
, vo_window
, f_gc
, u_dwidth
- left_ov2
- 1,
1292 left_ov
, left_ov2
, img_height
);
1298 void vo_x11_clearwindow(Display
* mDisplay
, Window vo_window
)
1302 XFillRectangle(mDisplay
, vo_window
, f_gc
, 0, 0, vo_screenwidth
,
1309 void vo_x11_setlayer(Display
* mDisplay
, Window vo_window
, int layer
)
1314 if (vo_fs_type
& vo_wm_LAYER
)
1316 XClientMessageEvent xev
;
1319 orig_layer
= vo_x11_get_gnome_layer(mDisplay
, vo_window
);
1321 memset(&xev
, 0, sizeof(xev
));
1322 xev
.type
= ClientMessage
;
1323 xev
.display
= mDisplay
;
1324 xev
.window
= vo_window
;
1325 xev
.message_type
= XA_WIN_LAYER
;
1327 xev
.data
.l
[0] = layer
? fs_layer
: orig_layer
; // if not fullscreen, stay on default layer
1328 xev
.data
.l
[1] = CurrentTime
;
1329 mp_msg(MSGT_VO
, MSGL_V
,
1330 "[x11] Layered style stay on top (layer %ld).\n",
1332 XSendEvent(mDisplay
, mRootWin
, False
, SubstructureNotifyMask
,
1334 } else if (vo_fs_type
& vo_wm_NETWM
)
1336 XClientMessageEvent xev
;
1339 memset(&xev
, 0, sizeof(xev
));
1340 xev
.type
= ClientMessage
;
1341 xev
.message_type
= XA_NET_WM_STATE
;
1342 xev
.display
= mDisplay
;
1343 xev
.window
= vo_window
;
1345 xev
.data
.l
[0] = layer
;
1347 if (vo_fs_type
& vo_wm_STAYS_ON_TOP
)
1348 xev
.data
.l
[1] = XA_NET_WM_STATE_STAYS_ON_TOP
;
1349 else if (vo_fs_type
& vo_wm_ABOVE
)
1350 xev
.data
.l
[1] = XA_NET_WM_STATE_ABOVE
;
1351 else if (vo_fs_type
& vo_wm_FULLSCREEN
)
1352 xev
.data
.l
[1] = XA_NET_WM_STATE_FULLSCREEN
;
1353 else if (vo_fs_type
& vo_wm_BELOW
)
1354 // This is not fallback. We can safely assume that situation where
1355 // only NETWM_STATE_BELOW is supported and others not, doesn't exist.
1356 xev
.data
.l
[1] = XA_NET_WM_STATE_BELOW
;
1358 XSendEvent(mDisplay
, mRootWin
, False
, SubstructureRedirectMask
,
1360 state
= XGetAtomName(mDisplay
, xev
.data
.l
[1]);
1361 mp_msg(MSGT_VO
, MSGL_V
,
1362 "[x11] NET style stay on top (layer %d). Using state %s.\n",
1368 static int vo_x11_get_fs_type(int supported
)
1371 int type
= supported
;
1376 for (i
= 0; vo_fstype_list
[i
]; i
++)
1379 char *arg
= vo_fstype_list
[i
];
1381 if (vo_fstype_list
[i
][0] == '-')
1384 arg
= vo_fstype_list
[i
] + 1;
1387 if (!strncmp(arg
, "layer", 5))
1389 if (!neg
&& (arg
[5] == '='))
1391 char *endptr
= NULL
;
1392 int layer
= strtol(vo_fstype_list
[i
] + 6, &endptr
, 10);
1394 if (endptr
&& *endptr
== '\0' && layer
>= 0
1399 type
&= ~vo_wm_LAYER
;
1401 type
|= vo_wm_LAYER
;
1402 } else if (!strcmp(arg
, "above"))
1405 type
&= ~vo_wm_ABOVE
;
1407 type
|= vo_wm_ABOVE
;
1408 } else if (!strcmp(arg
, "fullscreen"))
1411 type
&= ~vo_wm_FULLSCREEN
;
1413 type
|= vo_wm_FULLSCREEN
;
1414 } else if (!strcmp(arg
, "stays_on_top"))
1417 type
&= ~vo_wm_STAYS_ON_TOP
;
1419 type
|= vo_wm_STAYS_ON_TOP
;
1420 } else if (!strcmp(arg
, "below"))
1423 type
&= ~vo_wm_BELOW
;
1425 type
|= vo_wm_BELOW
;
1426 } else if (!strcmp(arg
, "netwm"))
1429 type
&= ~vo_wm_NETWM
;
1431 type
|= vo_wm_NETWM
;
1432 } else if (!strcmp(arg
, "none"))
1440 void vo_x11_fullscreen(void)
1444 if (WinID
>= 0 || vo_fs_flip
)
1450 if ( ! (vo_fs_type
& vo_wm_FULLSCREEN
) ) // not needed with EWMH fs
1452 if (vo_dwidth
!= vo_screenwidth
&& vo_dheight
!= vo_screenheight
)
1460 vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE
); // removes fullscreen state if wm supports EWMH
1465 vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD
); // sends fullscreen state to be added if wm supports EWMH
1468 if ( ! (vo_fs_type
& vo_wm_FULLSCREEN
) ) // not needed with EWMH fs
1471 (vo_dwidth
== vo_screenwidth
&& vo_dwidth
!= vo_old_width
) &&
1472 (vo_dheight
== vo_screenheight
&& vo_dheight
!= vo_old_height
))
1476 vo_old_width
= vo_dwidth
;
1477 vo_old_height
= vo_dheight
;
1478 update_xinerama_info();
1482 h
= vo_screenheight
;
1488 XGetWMNormalHints(mDisplay
, vo_window
, &vo_hint
, &dummy
);
1489 if (!(vo_hint
.flags
& PWinGravity
))
1490 old_gravity
= NorthWestGravity
;
1492 old_gravity
= vo_hint
.win_gravity
;
1494 if (vo_wm_type
== 0 && !(vo_fsmode
& 16))
1496 XUnmapWindow(mDisplay
, vo_window
); // required for MWM
1497 XWithdrawWindow(mDisplay
, vo_window
, mScreen
);
1501 if ( ! (vo_fs_type
& vo_wm_FULLSCREEN
) ) // not needed with EWMH fs
1503 vo_x11_decoration(mDisplay
, vo_window
, (vo_fs
) ? 0 : 1);
1504 vo_x11_sizehint(x
, y
, w
, h
, 0);
1505 vo_x11_setlayer(mDisplay
, vo_window
, vo_fs
);
1508 XMoveResizeWindow(mDisplay
, vo_window
, x
, y
, w
, h
);
1510 /* some WMs lose ontop after fullscreeen */
1511 if ((!(vo_fs
)) & vo_ontop
)
1512 vo_x11_setlayer(mDisplay
, vo_window
, vo_ontop
);
1514 XMapRaised(mDisplay
, vo_window
);
1515 XRaiseWindow(mDisplay
, vo_window
);
1519 void vo_x11_ontop(void)
1521 vo_ontop
= (!(vo_ontop
));
1523 vo_x11_setlayer(mDisplay
, vo_window
, vo_ontop
);
1527 * XScreensaver stuff
1530 static int got_badwindow
;
1531 static XErrorHandler old_handler
;
1533 static int badwindow_handler(Display
* dpy
, XErrorEvent
* error
)
1535 if (error
->error_code
!= BadWindow
)
1536 return (*old_handler
) (dpy
, error
);
1538 got_badwindow
= True
;
1542 static Window
find_xscreensaver_window(Display
* dpy
)
1545 Window root
= RootWindowOfScreen(DefaultScreenOfDisplay(dpy
));
1546 Window root2
, parent
, *kids
;
1549 unsigned int nkids
= 0;
1551 xs_version
= XInternAtom(dpy
, "_SCREENSAVER_VERSION", True
);
1553 if (!(xs_version
!= None
&&
1554 XQueryTree(dpy
, root
, &root2
, &parent
, &kids
, &nkids
) &&
1558 old_handler
= XSetErrorHandler(badwindow_handler
);
1560 for (i
= 0; i
< nkids
; i
++)
1564 unsigned long nitems
, bytesafter
;
1568 got_badwindow
= False
;
1570 XGetWindowProperty(dpy
, kids
[i
], xs_version
, 0, 200, False
,
1571 XA_STRING
, &type
, &format
, &nitems
,
1572 &bytesafter
, (unsigned char **) &v
);
1577 if (status
== Success
&& type
!= None
)
1584 XSetErrorHandler(old_handler
);
1589 static Window xs_windowid
= 0;
1590 static Atom deactivate
;
1591 static Atom screensaver
;
1593 static unsigned int time_last
;
1595 void xscreensaver_heartbeat(void)
1597 unsigned int time
= GetTimerMS();
1600 if (mDisplay
&& xs_windowid
&& (time
- time_last
) > 30000)
1604 ev
.xany
.type
= ClientMessage
;
1605 ev
.xclient
.display
= mDisplay
;
1606 ev
.xclient
.window
= xs_windowid
;
1607 ev
.xclient
.message_type
= screensaver
;
1608 ev
.xclient
.format
= 32;
1609 memset(&ev
.xclient
.data
, 0, sizeof(ev
.xclient
.data
));
1610 ev
.xclient
.data
.l
[0] = (long) deactivate
;
1612 mp_msg(MSGT_VO
, MSGL_DBG2
, "Pinging xscreensaver.\n");
1613 old_handler
= XSetErrorHandler(badwindow_handler
);
1614 XSendEvent(mDisplay
, xs_windowid
, False
, 0L, &ev
);
1615 XSync(mDisplay
, False
);
1616 XSetErrorHandler(old_handler
);
1620 static void xscreensaver_disable(Display
* dpy
)
1622 mp_msg(MSGT_VO
, MSGL_DBG2
, "xscreensaver_disable()\n");
1624 xs_windowid
= find_xscreensaver_window(dpy
);
1627 mp_msg(MSGT_VO
, MSGL_INFO
, MSGTR_CouldNotFindXScreenSaver
);
1630 mp_msg(MSGT_VO
, MSGL_INFO
,
1631 "xscreensaver_disable: xscreensaver wid=%ld.\n", xs_windowid
);
1633 deactivate
= XInternAtom(dpy
, "DEACTIVATE", False
);
1634 screensaver
= XInternAtom(dpy
, "SCREENSAVER", False
);
1637 static void xscreensaver_enable(void)
1643 * End of XScreensaver stuff
1646 void saver_on(Display
* mDisplay
)
1654 if (DPMSQueryExtension(mDisplay
, ¬hing
, ¬hing
))
1656 if (!DPMSEnable(mDisplay
))
1657 { // restoring power saving settings
1658 mp_msg(MSGT_VO
, MSGL_WARN
, "DPMS not available?\n");
1661 // DPMS does not seem to be enabled unless we call DPMSInfo
1665 DPMSForceLevel(mDisplay
, DPMSModeOn
);
1666 DPMSInfo(mDisplay
, &state
, &onoff
);
1669 mp_msg(MSGT_VO
, MSGL_V
,
1670 "Successfully enabled DPMS\n");
1673 mp_msg(MSGT_VO
, MSGL_WARN
, "Could not enable DPMS\n");
1683 int dummy
, interval
, prefer_blank
, allow_exp
;
1685 XGetScreenSaver(mDisplay
, &dummy
, &interval
, &prefer_blank
,
1687 XSetScreenSaver(mDisplay
, timeout_save
, interval
, prefer_blank
,
1689 XGetScreenSaver(mDisplay
, &timeout_save
, &interval
, &prefer_blank
,
1694 if (stop_xscreensaver
)
1695 xscreensaver_enable();
1696 if (kdescreensaver_was_running
&& stop_xscreensaver
)
1699 ("dcop kdesktop KScreensaverIface enable true 2>/dev/null >/dev/null");
1700 kdescreensaver_was_running
= 0;
1706 void saver_off(Display
* mDisplay
)
1709 int interval
, prefer_blank
, allow_exp
;
1714 if (DPMSQueryExtension(mDisplay
, ¬hing
, ¬hing
))
1719 DPMSInfo(mDisplay
, &state
, &onoff
);
1724 mp_msg(MSGT_VO
, MSGL_V
, "Disabling DPMS\n");
1726 stat
= DPMSDisable(mDisplay
); // monitor powersave off
1727 mp_msg(MSGT_VO
, MSGL_V
, "DPMSDisable stat: %d\n", stat
);
1733 XGetScreenSaver(mDisplay
, &timeout_save
, &interval
, &prefer_blank
,
1736 XSetScreenSaver(mDisplay
, 0, interval
, prefer_blank
,
1739 // turning off screensaver
1740 if (stop_xscreensaver
)
1741 xscreensaver_disable(mDisplay
);
1742 if (stop_xscreensaver
&& !kdescreensaver_was_running
)
1744 kdescreensaver_was_running
=
1746 ("dcop kdesktop KScreensaverIface isEnabled 2>/dev/null | sed 's/1/true/g' | grep true 2>/dev/null >/dev/null")
1748 if (kdescreensaver_was_running
)
1750 ("dcop kdesktop KScreensaverIface enable false 2>/dev/null >/dev/null");
1754 static XErrorHandler old_handler
= NULL
;
1755 static int selectinput_err
= 0;
1756 static int x11_selectinput_errorhandler(Display
* display
,
1757 XErrorEvent
* event
)
1759 if (event
->error_code
== BadAccess
)
1761 selectinput_err
= 1;
1762 mp_msg(MSGT_VO
, MSGL_ERR
,
1763 "X11 error: BadAccess during XSelectInput Call\n");
1764 mp_msg(MSGT_VO
, MSGL_ERR
,
1765 "X11 error: The 'ButtonPressMask' mask of specified window has probably already used by another appication (see man XSelectInput)\n");
1766 /* If you think mplayer should shutdown with this error, comments out following line */
1769 if (old_handler
!= NULL
)
1770 old_handler(display
, event
);
1772 x11_errorhandler(display
, event
);
1776 void vo_x11_selectinput_witherr(Display
* display
, Window w
,
1779 XSync(display
, False
);
1780 old_handler
= XSetErrorHandler(x11_selectinput_errorhandler
);
1781 selectinput_err
= 0;
1782 if (vo_nomouse_input
)
1784 XSelectInput(display
, w
,
1786 (~(ButtonPressMask
| ButtonReleaseMask
)));
1789 XSelectInput(display
, w
, event_mask
);
1791 XSync(display
, False
);
1792 XSetErrorHandler(old_handler
);
1793 if (selectinput_err
)
1795 mp_msg(MSGT_VO
, MSGL_ERR
,
1796 "X11 error: MPlayer discards mouse control (reconfiguring)\n");
1797 XSelectInput(display
, w
,
1800 (ButtonPressMask
| ButtonReleaseMask
|
1801 PointerMotionMask
)));
1806 void vo_vm_switch(uint32_t X
, uint32_t Y
, int *modeline_width
,
1807 int *modeline_height
)
1809 int vm_event
, vm_error
;
1811 int i
, j
, have_vm
= 0;
1815 if (XF86VidModeQueryExtension(mDisplay
, &vm_event
, &vm_error
))
1817 XF86VidModeQueryVersion(mDisplay
, &vm_ver
, &vm_rev
);
1818 mp_msg(MSGT_VO
, MSGL_V
, "XF86VidMode extension v%i.%i\n", vm_ver
,
1822 mp_msg(MSGT_VO
, MSGL_WARN
,
1823 "XF86VidMode extension not available.\n");
1827 if (vidmodes
== NULL
)
1828 XF86VidModeGetAllModeLines(mDisplay
, mScreen
, &modecount
,
1831 *modeline_width
= vidmodes
[0]->hdisplay
;
1832 *modeline_height
= vidmodes
[0]->vdisplay
;
1834 for (i
= 1; i
< modecount
; i
++)
1835 if ((vidmodes
[i
]->hdisplay
>= X
)
1836 && (vidmodes
[i
]->vdisplay
>= Y
))
1837 if ((vidmodes
[i
]->hdisplay
<= *modeline_width
)
1838 && (vidmodes
[i
]->vdisplay
<= *modeline_height
))
1840 *modeline_width
= vidmodes
[i
]->hdisplay
;
1841 *modeline_height
= vidmodes
[i
]->vdisplay
;
1845 mp_msg(MSGT_VO
, MSGL_INFO
, MSGTR_SelectedVideoMode
,
1846 *modeline_width
, *modeline_height
, X
, Y
);
1847 XF86VidModeLockModeSwitch(mDisplay
, mScreen
, 0);
1848 XF86VidModeSwitchToMode(mDisplay
, mScreen
, vidmodes
[j
]);
1849 XF86VidModeSwitchToMode(mDisplay
, mScreen
, vidmodes
[j
]);
1850 X
= (vo_screenwidth
- *modeline_width
) / 2;
1851 Y
= (vo_screenheight
- *modeline_height
) / 2;
1852 XF86VidModeSetViewPort(mDisplay
, mScreen
, X
, Y
);
1856 void vo_vm_close(Display
* dpy
)
1859 if (vidmodes
!= NULL
&& vo_window
!= None
)
1861 if (vidmodes
!= NULL
)
1867 screen
= DefaultScreen(dpy
);
1871 XF86VidModeGetAllModeLines(mDisplay
, mScreen
, &modecount
,
1873 for (i
= 0; i
< modecount
; i
++)
1874 if ((vidmodes
[i
]->hdisplay
== vo_screenwidth
)
1875 && (vidmodes
[i
]->vdisplay
== vo_screenheight
))
1877 mp_msg(MSGT_VO
, MSGL_INFO
,
1878 "Returning to original mode %dx%d\n",
1879 vo_screenwidth
, vo_screenheight
);
1883 XF86VidModeSwitchToMode(dpy
, screen
, vidmodes
[i
]);
1884 XF86VidModeSwitchToMode(dpy
, screen
, vidmodes
[i
]);
1891 #endif /* X11_FULLSCREEN */
1895 * Scan the available visuals on this Display/Screen. Try to find
1896 * the 'best' available TrueColor visual that has a decent color
1897 * depth (at least 15bit). If there are multiple visuals with depth
1898 * >= 15bit, we prefer visuals with a smaller color depth.
1900 int vo_find_depth_from_visuals(Display
* dpy
, int screen
,
1901 Visual
** visual_return
)
1903 XVisualInfo visual_tmpl
;
1904 XVisualInfo
*visuals
;
1906 int bestvisual
= -1;
1907 int bestvisual_depth
= -1;
1909 visual_tmpl
.screen
= screen
;
1910 visual_tmpl
.class = TrueColor
;
1911 visuals
= XGetVisualInfo(dpy
,
1912 VisualScreenMask
| VisualClassMask
,
1913 &visual_tmpl
, &nvisuals
);
1914 if (visuals
!= NULL
)
1916 for (i
= 0; i
< nvisuals
; i
++)
1918 mp_msg(MSGT_VO
, MSGL_V
,
1919 "vo: X11 truecolor visual %#lx, depth %d, R:%lX G:%lX B:%lX\n",
1920 visuals
[i
].visualid
, visuals
[i
].depth
,
1921 visuals
[i
].red_mask
, visuals
[i
].green_mask
,
1922 visuals
[i
].blue_mask
);
1924 * save the visual index and it's depth, if this is the first
1925 * truecolor visul, or a visual that is 'preferred' over the
1926 * previous 'best' visual
1928 if (bestvisual_depth
== -1
1929 || (visuals
[i
].depth
>= 15
1930 && (visuals
[i
].depth
< bestvisual_depth
1931 || bestvisual_depth
< 15)))
1934 bestvisual_depth
= visuals
[i
].depth
;
1938 if (bestvisual
!= -1 && visual_return
!= NULL
)
1939 *visual_return
= visuals
[bestvisual
].visual
;
1943 return bestvisual_depth
;
1947 static Colormap cmap
= None
;
1948 static XColor cols
[256];
1949 static int cm_size
, red_mask
, green_mask
, blue_mask
;
1952 Colormap
vo_x11_create_colormap(XVisualInfo
* vinfo
)
1954 unsigned k
, r
, g
, b
, ru
, gu
, bu
, m
, rv
, gv
, bv
, rvu
, gvu
, bvu
;
1956 if (vinfo
->class != DirectColor
)
1957 return XCreateColormap(mDisplay
, mRootWin
, vinfo
->visual
,
1960 /* can this function get called twice or more? */
1963 cm_size
= vinfo
->colormap_size
;
1964 red_mask
= vinfo
->red_mask
;
1965 green_mask
= vinfo
->green_mask
;
1966 blue_mask
= vinfo
->blue_mask
;
1967 ru
= (red_mask
& (red_mask
- 1)) ^ red_mask
;
1968 gu
= (green_mask
& (green_mask
- 1)) ^ green_mask
;
1969 bu
= (blue_mask
& (blue_mask
- 1)) ^ blue_mask
;
1970 rvu
= 65536ull * ru
/ (red_mask
+ ru
);
1971 gvu
= 65536ull * gu
/ (green_mask
+ gu
);
1972 bvu
= 65536ull * bu
/ (blue_mask
+ bu
);
1975 m
= DoRed
| DoGreen
| DoBlue
;
1976 for (k
= 0; k
< cm_size
; k
++)
1980 cols
[k
].pixel
= r
| g
| b
;
1985 t
= (r
+ ru
) & red_mask
;
1989 t
= (g
+ gu
) & green_mask
;
1993 t
= (b
+ bu
) & blue_mask
;
2001 cmap
= XCreateColormap(mDisplay
, mRootWin
, vinfo
->visual
, AllocAll
);
2002 XStoreColors(mDisplay
, cmap
, cols
, cm_size
);
2007 * Via colormaps/gamma ramps we can do gamma, brightness, contrast,
2008 * hue and red/green/blue intensity, but we cannot do saturation.
2009 * Currently only gamma, brightness and contrast are implemented.
2010 * Is there sufficient interest for hue and/or red/green/blue intensity?
2012 /* these values have range [-100,100] and are initially 0 */
2013 static int vo_gamma
= 0;
2014 static int vo_brightness
= 0;
2015 static int vo_contrast
= 0;
2018 uint32_t vo_x11_set_equalizer(char *name
, int value
)
2020 float gamma
, brightness
, contrast
;
2025 * IMPLEMENTME: consider using XF86VidModeSetGammaRamp in the case
2026 * of TrueColor-ed window but be careful:
2027 * unlike the colormaps, which are private for the X client
2028 * who created them and thus automatically destroyed on client
2029 * disconnect, this gamma ramp is a system-wide (X-server-wide)
2030 * setting and _must_ be restored before the process exit.
2031 * Unforunately when the process crashes (or get killed
2032 * for some reason) it is impossible to restore the setting,
2033 * and such behaviour could be rather annoying for the users.
2038 if (!strcasecmp(name
, "brightness"))
2039 vo_brightness
= value
;
2040 else if (!strcasecmp(name
, "contrast"))
2041 vo_contrast
= value
;
2042 else if (!strcasecmp(name
, "gamma"))
2047 brightness
= 0.01 * vo_brightness
;
2048 contrast
= tan(0.0095 * (vo_contrast
+ 100) * M_PI
/ 4);
2049 gamma
= pow(2, -0.02 * vo_gamma
);
2051 rf
= (float) ((red_mask
& (red_mask
- 1)) ^ red_mask
) / red_mask
;
2052 gf
= (float) ((green_mask
& (green_mask
- 1)) ^ green_mask
) /
2054 bf
= (float) ((blue_mask
& (blue_mask
- 1)) ^ blue_mask
) / blue_mask
;
2056 /* now recalculate the colormap using the newly set value */
2057 for (k
= 0; k
< cm_size
; k
++)
2061 s
= pow(rf
* k
, gamma
);
2062 s
= (s
- 0.5) * contrast
+ 0.5;
2068 cols
[k
].red
= (unsigned short) (s
* 65535);
2070 s
= pow(gf
* k
, gamma
);
2071 s
= (s
- 0.5) * contrast
+ 0.5;
2077 cols
[k
].green
= (unsigned short) (s
* 65535);
2079 s
= pow(bf
* k
, gamma
);
2080 s
= (s
- 0.5) * contrast
+ 0.5;
2086 cols
[k
].blue
= (unsigned short) (s
* 65535);
2089 XStoreColors(mDisplay
, cmap
, cols
, cm_size
);
2094 uint32_t vo_x11_get_equalizer(char *name
, int *value
)
2098 if (!strcasecmp(name
, "brightness"))
2099 *value
= vo_brightness
;
2100 else if (!strcasecmp(name
, "contrast"))
2101 *value
= vo_contrast
;
2102 else if (!strcasecmp(name
, "gamma"))
2110 int vo_xv_set_eq(uint32_t xv_port
, char *name
, int value
)
2112 XvAttribute
*attributes
;
2113 int i
, howmany
, xv_atom
;
2115 mp_dbg(MSGT_VO
, MSGL_V
, "xv_set_eq called! (%s, %d)\n", name
, value
);
2117 /* get available attributes */
2118 attributes
= XvQueryPortAttributes(mDisplay
, xv_port
, &howmany
);
2119 for (i
= 0; i
< howmany
&& attributes
; i
++)
2120 if (attributes
[i
].flags
& XvSettable
)
2122 xv_atom
= XInternAtom(mDisplay
, attributes
[i
].name
, True
);
2123 /* since we have SET_DEFAULTS first in our list, we can check if it's available
2124 then trigger it if it's ok so that the other values are at default upon query */
2125 if (xv_atom
!= None
)
2127 int hue
= 0, port_value
, port_min
, port_max
;
2129 if (!strcmp(attributes
[i
].name
, "XV_BRIGHTNESS") &&
2130 (!strcasecmp(name
, "brightness")))
2132 else if (!strcmp(attributes
[i
].name
, "XV_CONTRAST") &&
2133 (!strcasecmp(name
, "contrast")))
2135 else if (!strcmp(attributes
[i
].name
, "XV_SATURATION") &&
2136 (!strcasecmp(name
, "saturation")))
2138 else if (!strcmp(attributes
[i
].name
, "XV_HUE") &&
2139 (!strcasecmp(name
, "hue")))
2144 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */
2145 if (!strcmp(attributes
[i
].name
, "XV_RED_INTENSITY") &&
2146 (!strcasecmp(name
, "red_intensity")))
2148 else if (!strcmp(attributes
[i
].name
, "XV_GREEN_INTENSITY")
2149 && (!strcasecmp(name
, "green_intensity")))
2151 else if (!strcmp(attributes
[i
].name
, "XV_BLUE_INTENSITY")
2152 && (!strcasecmp(name
, "blue_intensity")))
2157 port_min
= attributes
[i
].min_value
;
2158 port_max
= attributes
[i
].max_value
;
2160 /* nvidia hue workaround */
2161 if (hue
&& port_min
== 0 && port_max
== 360)
2165 0) ? (port_value
- 100) : (port_value
+ 100);
2171 (port_value
+ 100) * (port_max
- port_min
) / 200 +
2173 XvSetPortAttribute(mDisplay
, xv_port
, xv_atom
, port_value
);
2180 int vo_xv_get_eq(uint32_t xv_port
, char *name
, int *value
)
2183 XvAttribute
*attributes
;
2184 int i
, howmany
, xv_atom
;
2186 /* get available attributes */
2187 attributes
= XvQueryPortAttributes(mDisplay
, xv_port
, &howmany
);
2188 for (i
= 0; i
< howmany
&& attributes
; i
++)
2189 if (attributes
[i
].flags
& XvGettable
)
2191 xv_atom
= XInternAtom(mDisplay
, attributes
[i
].name
, True
);
2192 /* since we have SET_DEFAULTS first in our list, we can check if it's available
2193 then trigger it if it's ok so that the other values are at default upon query */
2194 if (xv_atom
!= None
)
2196 int val
, port_value
= 0, port_min
, port_max
;
2198 XvGetPortAttribute(mDisplay
, xv_port
, xv_atom
,
2201 port_min
= attributes
[i
].min_value
;
2202 port_max
= attributes
[i
].max_value
;
2204 (port_value
- port_min
) * 200 / (port_max
- port_min
) -
2207 if (!strcmp(attributes
[i
].name
, "XV_BRIGHTNESS") &&
2208 (!strcasecmp(name
, "brightness")))
2210 else if (!strcmp(attributes
[i
].name
, "XV_CONTRAST") &&
2211 (!strcasecmp(name
, "contrast")))
2213 else if (!strcmp(attributes
[i
].name
, "XV_SATURATION") &&
2214 (!strcasecmp(name
, "saturation")))
2216 else if (!strcmp(attributes
[i
].name
, "XV_HUE") &&
2217 (!strcasecmp(name
, "hue")))
2219 /* nasty nvidia detect */
2220 if (port_min
== 0 && port_max
== 360)
2221 *value
= (val
>= 0) ? (val
- 100) : (val
+ 100);
2225 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */
2226 if (!strcmp(attributes
[i
].name
, "XV_RED_INTENSITY") &&
2227 (!strcasecmp(name
, "red_intensity")))
2229 else if (!strcmp(attributes
[i
].name
, "XV_GREEN_INTENSITY")
2230 && (!strcasecmp(name
, "green_intensity")))
2232 else if (!strcmp(attributes
[i
].name
, "XV_BLUE_INTENSITY")
2233 && (!strcasecmp(name
, "blue_intensity")))
2238 mp_dbg(MSGT_VO
, MSGL_V
, "xv_get_eq called! (%s, %d)\n",
2246 /** \brief contains flags changing the execution of the colorkeying code */
2247 xv_ck_info_t xv_ck_info
= { CK_METHOD_MANUALFILL
, CK_SRC_CUR
};
2248 unsigned long xv_colorkey
; ///< The color used for manual colorkeying.
2249 unsigned int xv_port
; ///< The selected Xv port.
2252 * \brief Interns the requested atom if it is available.
2254 * \param atom_name String containing the name of the requested atom.
2256 * \return Returns the atom if available, else None is returned.
2259 static Atom
xv_intern_atom_if_exists( char const * atom_name
)
2261 XvAttribute
* attributes
;
2263 Atom xv_atom
= None
;
2265 attributes
= XvQueryPortAttributes( mDisplay
, xv_port
, &attrib_count
);
2266 if( attributes
!=NULL
)
2268 for ( i
= 0; i
< attrib_count
; ++i
)
2270 if ( strcmp(attributes
[i
].name
, atom_name
) == 0 )
2272 xv_atom
= XInternAtom( mDisplay
, atom_name
, False
);
2273 break; // found what we want, break out
2276 XFree( attributes
);
2283 * \brief Try to enable vsync for xv.
2284 * \return Returns -1 if not available, 0 on failure and 1 on success.
2286 int vo_xv_enable_vsync()
2288 Atom xv_atom
= xv_intern_atom_if_exists("XV_SYNC_TO_VBLANK");
2289 if (xv_atom
== None
)
2291 return XvSetPortAttribute(mDisplay
, xv_port
, xv_atom
, 1) == Success
;
2295 * \brief Get maximum supported source image dimensions.
2297 * This function does not set the variables pointed to by
2298 * width and height if the information could not be retreived.
2299 * So the caller is reponsible for initing them properly.
2301 * \param width [out] The maximum width gets stored here.
2302 * \param height [out] The maximum height gets stored here.
2305 void vo_xv_get_max_img_dim( uint32_t * width
, uint32_t * height
)
2307 XvEncodingInfo
* encodings
;
2308 //unsigned long num_encodings, idx; to int or too long?!
2309 unsigned int num_encodings
, idx
;
2311 XvQueryEncodings( mDisplay
, xv_port
, &num_encodings
, &encodings
);
2315 for ( idx
= 0; idx
< num_encodings
; ++idx
)
2317 if ( strcmp( encodings
[idx
].name
, "XV_IMAGE" ) == 0 )
2319 *width
= encodings
[idx
].width
;
2320 *height
= encodings
[idx
].height
;
2326 mp_msg( MSGT_VO
, MSGL_V
,
2327 "[xv common] Maximum source image dimensions: %ux%u\n",
2330 XvFreeEncodingInfo( encodings
);
2334 * \brief Print information about the colorkey method and source.
2336 * \param ck_handling Integer value containing the information about
2337 * colorkey handling (see x11_common.h).
2339 * Outputs the content of |ck_handling| as a readable message.
2342 void vo_xv_print_ck_info()
2344 mp_msg( MSGT_VO
, MSGL_V
, "[xv common] " );
2346 switch ( xv_ck_info
.method
)
2348 case CK_METHOD_NONE
:
2349 mp_msg( MSGT_VO
, MSGL_V
, "Drawing no colorkey.\n" ); return;
2350 case CK_METHOD_AUTOPAINT
:
2351 mp_msg( MSGT_VO
, MSGL_V
, "Colorkey is drawn by Xv." ); break;
2352 case CK_METHOD_MANUALFILL
:
2353 mp_msg( MSGT_VO
, MSGL_V
, "Drawing colorkey manually." ); break;
2354 case CK_METHOD_BACKGROUND
:
2355 mp_msg( MSGT_VO
, MSGL_V
, "Colorkey is drawn as window background." ); break;
2358 mp_msg( MSGT_VO
, MSGL_V
, "\n[xv common] " );
2360 switch ( xv_ck_info
.source
)
2363 mp_msg( MSGT_VO
, MSGL_V
, "Using colorkey from Xv (0x%06lx).\n",
2367 if ( xv_ck_info
.method
== CK_METHOD_AUTOPAINT
)
2369 mp_msg( MSGT_VO
, MSGL_V
,
2370 "Ignoring colorkey from MPlayer (0x%06lx).\n",
2375 mp_msg( MSGT_VO
, MSGL_V
,
2376 "Using colorkey from MPlayer (0x%06lx)."
2377 " Use -colorkey to change.\n",
2382 mp_msg( MSGT_VO
, MSGL_V
,
2383 "Setting and using colorkey from MPlayer (0x%06lx)."
2384 " Use -colorkey to change.\n",
2390 * \brief Init colorkey depending on the settings in xv_ck_info.
2392 * \return Returns 0 on failure and 1 on success.
2394 * Sets the colorkey variable according to the CK_SRC_* and CK_METHOD_*
2395 * flags in xv_ck_info.
2399 * - manual colorkey drawing ( CK_METHOD_MANUALFILL )
2400 * - set colorkey as window background ( CK_METHOD_BACKGROUND )
2401 * - let Xv paint the colorkey ( CK_METHOD_AUTOPAINT )
2403 * - use currently set colorkey ( CK_SRC_CUR )
2404 * - use colorkey in vo_colorkey ( CK_SRC_USE )
2405 * - use and set colorkey in vo_colorkey ( CK_SRC_SET )
2407 * NOTE: If vo_colorkey has bits set after the first 3 low order bytes
2408 * we don't draw anything as this means it was forced to off.
2410 int vo_xv_init_colorkey()
2415 /* check if colorkeying is needed */
2416 xv_atom
= xv_intern_atom_if_exists( "XV_COLORKEY" );
2418 /* if we have to deal with colorkeying ... */
2419 if( xv_atom
!= None
&& !(vo_colorkey
& 0xFF000000) )
2421 /* check if we should use the colorkey specified in vo_colorkey */
2422 if ( xv_ck_info
.source
!= CK_SRC_CUR
)
2424 xv_colorkey
= vo_colorkey
;
2426 /* check if we have to set the colorkey too */
2427 if ( xv_ck_info
.source
== CK_SRC_SET
)
2429 xv_atom
= XInternAtom(mDisplay
, "XV_COLORKEY",False
);
2431 rez
= XvSetPortAttribute( mDisplay
, xv_port
, xv_atom
, vo_colorkey
);
2432 if ( rez
!= Success
)
2434 mp_msg( MSGT_VO
, MSGL_FATAL
,
2435 "[xv common] Couldn't set colorkey!\n" );
2436 return 0; // error setting colorkey
2444 rez
=XvGetPortAttribute(mDisplay
,xv_port
, xv_atom
, &colorkey_ret
);
2445 if ( rez
== Success
)
2447 xv_colorkey
= colorkey_ret
;
2451 mp_msg( MSGT_VO
, MSGL_FATAL
,
2452 "[xv common] Couldn't get colorkey!"
2453 "Maybe the selected Xv port has no overlay.\n" );
2454 return 0; // error getting colorkey
2458 xv_atom
= xv_intern_atom_if_exists( "XV_AUTOPAINT_COLORKEY" );
2460 /* should we draw the colorkey ourselves or activate autopainting? */
2461 if ( xv_ck_info
.method
== CK_METHOD_AUTOPAINT
)
2463 rez
= !Success
; // reset rez to something different than Success
2465 if ( xv_atom
!= None
) // autopaint is supported
2467 rez
= XvSetPortAttribute( mDisplay
, xv_port
, xv_atom
, 1 );
2470 if ( rez
!= Success
)
2472 // fallback to manual colorkey drawing
2473 xv_ck_info
.method
= CK_METHOD_MANUALFILL
;
2476 else // disable colorkey autopainting if supported
2478 if ( xv_atom
!= None
) // we have autopaint attribute
2480 XvSetPortAttribute( mDisplay
, xv_port
, xv_atom
, 0 );
2484 else // do no colorkey drawing at all
2486 xv_ck_info
.method
= CK_METHOD_NONE
;
2487 } /* end: should we draw colorkey */
2489 /* output information about the curren colorkey settings */
2490 vo_xv_print_ck_info();
2492 return 1; // success
2496 * \brief Draw the colorkey on the video window.
2498 * Draws the colorkey depending on the set method ( colorkey_handling ).
2500 * It also draws the black bars ( when the video doesn't fit to the
2501 * display in full screen ) seperately, so they don't overlap with the
2503 * It doesn't call XFlush
2506 inline void vo_xv_draw_colorkey( int32_t x
, int32_t y
,
2507 int32_t w
, int32_t h
)
2509 if( xv_ck_info
.method
== CK_METHOD_MANUALFILL
||
2510 xv_ck_info
.method
== CK_METHOD_BACKGROUND
)//less tearing than XClearWindow()
2512 XSetForeground( mDisplay
, vo_gc
, xv_colorkey
);
2513 XFillRectangle( mDisplay
, vo_window
, vo_gc
,
2518 /* draw black bars if needed */
2519 /* TODO! move this to vo_x11_clearwindow_part() */
2522 XSetForeground( mDisplay
, vo_gc
, 0 );
2523 /* making non overlap fills, requiare 8 checks instead of 4*/
2525 XFillRectangle( mDisplay
, vo_window
, vo_gc
,
2529 XFillRectangle( mDisplay
, vo_window
, vo_gc
,
2531 x
, vo_screenheight
);
2532 if (x
+ w
< vo_screenwidth
)
2533 XFillRectangle( mDisplay
, vo_window
, vo_gc
,
2535 vo_screenwidth
, vo_screenheight
);
2536 if (y
+ h
< vo_screenheight
)
2537 XFillRectangle( mDisplay
, vo_window
, vo_gc
,
2539 vo_screenwidth
, vo_screenheight
);
2543 /** \brief tests if a valid arg for the ck suboption was given */
2544 int xv_test_ck( void * arg
)
2546 strarg_t
* strarg
= (strarg_t
*)arg
;
2548 if ( strargcmp( strarg
, "use" ) == 0 ||
2549 strargcmp( strarg
, "set" ) == 0 ||
2550 strargcmp( strarg
, "cur" ) == 0 )
2557 /** \brief tests if a valid arg for the ck-method suboption was given */
2558 int xv_test_ckm( void * arg
)
2560 strarg_t
* strarg
= (strarg_t
*)arg
;
2562 if ( strargcmp( strarg
, "bg" ) == 0 ||
2563 strargcmp( strarg
, "man" ) == 0 ||
2564 strargcmp( strarg
, "auto" ) == 0 )
2573 * \brief Modify the colorkey_handling var according to str
2575 * Checks if a valid pointer ( not NULL ) to the string
2576 * was given. And in that case modifies the colorkey_handling
2577 * var to reflect the requested behaviour.
2578 * If nothing happens the content of colorkey_handling stays
2581 * \param str Pointer to the string or NULL
2584 void xv_setup_colorkeyhandling( char const * ck_method_str
,
2585 char const * ck_str
)
2587 /* check if a valid pointer to the string was passed */
2590 if ( strncmp( ck_str
, "use", 3 ) == 0 )
2592 xv_ck_info
.source
= CK_SRC_USE
;
2594 else if ( strncmp( ck_str
, "set", 3 ) == 0 )
2596 xv_ck_info
.source
= CK_SRC_SET
;
2599 /* check if a valid pointer to the string was passed */
2600 if ( ck_method_str
)
2602 if ( strncmp( ck_method_str
, "bg", 2 ) == 0 )
2604 xv_ck_info
.method
= CK_METHOD_BACKGROUND
;
2606 else if ( strncmp( ck_method_str
, "man", 3 ) == 0 )
2608 xv_ck_info
.method
= CK_METHOD_MANUALFILL
;
2610 else if ( strncmp( ck_method_str
, "auto", 4 ) == 0 )
2612 xv_ck_info
.method
= CK_METHOD_AUTOPAINT
;