From 36bdbbe716a93c2fa213ee16e86b267cd6a207f8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 31 Aug 2014 14:26:31 +0200 Subject: x11: when using --wid, inherit event flags from parent window When embedding a X window, it's hard to control whether it receives mouse/keyboard input or not. It seems the X protocol itself makes this hard (basically due to the outdated design mismatching with modern toolkits), and we have to take care of these things explicitly. Simply do this by manually querying and using the parent window event flags. This restores some MPlayer behavior (it doesn't add back exactly the same code, but it's very similar). This probably has some potential to interfere with libmpv embedding, so bump the client API minor. CC: @mpv-player/stable (if applied, client-api-changes.rst has to be adjusted to include the 0.5.2 release) --- DOCS/client-api-changes.rst | 1 + libmpv/client.h | 2 +- video/out/x11_common.c | 15 ++++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst index bef6759877..b689921e48 100644 --- a/DOCS/client-api-changes.rst +++ b/DOCS/client-api-changes.rst @@ -25,6 +25,7 @@ API changes :: + 1.4 - subtle change in X11 and "--wid" behavior --- mpv 0.5.0 is released --- 1.3 - add MPV_MAKE_VERSION() 1.2 - remove "stream-time-pos" property (no replacement) diff --git a/libmpv/client.h b/libmpv/client.h index 4a653963eb..1e5ff4f9e7 100644 --- a/libmpv/client.h +++ b/libmpv/client.h @@ -162,7 +162,7 @@ extern "C" { * relational operators (<, >, <=, >=). */ #define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL) -#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 3) +#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 4) /** * Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with. diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 539d66e641..6309247539 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1177,11 +1177,16 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc) } // map window - vo_x11_selectinput_witherr(vo, x11->display, x11->window, - StructureNotifyMask | ExposureMask | - KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | LeaveWindowMask); + int events = StructureNotifyMask | ExposureMask; + if (vo->opts->WinID > 0) { + XWindowAttributes attribs; + if (XGetWindowAttributes(x11->display, vo->opts->WinID, &attribs)) + events |= attribs.your_event_mask; + } else { + events |= KeyPressMask | KeyReleaseMask | ButtonPressMask | + ButtonReleaseMask | PointerMotionMask | LeaveWindowMask; + } + vo_x11_selectinput_witherr(vo, x11->display, x11->window, events); XMapWindow(x11->display, x11->window); } -- cgit v1.2.3