diff options
author | wm4 <wm4@nowhere> | 2014-08-31 14:26:31 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-08-31 14:48:26 +0200 |
commit | 64b7811c28c3caadf42c394d54cfce222ad5503d (patch) | |
tree | 39001714d27ac59e3b07444e29e81e26185a41a5 /video/out/x11_common.c | |
parent | a910b5c6df1c257ae3b4be62030e48ff9ffb6bad (diff) | |
download | mpv-64b7811c28c3caadf42c394d54cfce222ad5503d.tar.bz2 mpv-64b7811c28c3caadf42c394d54cfce222ad5503d.tar.xz |
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)
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r-- | video/out/x11_common.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c index e9389c5f38..9da95ab200 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1242,11 +1242,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); } |