summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-28 20:11:00 +0200
committerwm4 <wm4@nowhere>2014-09-28 20:11:00 +0200
commit3273db1ef72a9d1ee76ba704ace6c1b1898ab945 (patch)
treed0602014e7e0cfcf8cee335b3a4aee2a1c10e227 /video
parentaeaa1767e9f62fd45607c2d5b73253ccf6b3e241 (diff)
downloadmpv-3273db1ef72a9d1ee76ba704ace6c1b1898ab945.tar.bz2
mpv-3273db1ef72a9d1ee76ba704ace6c1b1898ab945.tar.xz
client API, X11: change default keyboard input handling again
Commit 64b7811c tried to do the "right thing" with respect to whether keyboard input should be enabled or not. It turns out that X11 does something stupid by design. All modern toolkits work around this native X11 behavior, but embedding breaks these workarounds. The only way to handle this correctly is the XEmbed protocol. It needs to be supported by the toolkit, and probably also some mpv support. But Qt has inconsistent support for it. In Qt 4, a X11 specific embedding widget was needed. Qt 5.0 doesn't support it at all. Qt 5.1 apparently supports it via QWindow, but if it really does, I couldn't get it to work. So add a hack instead. The new --input-x11-keyboard option controls whether mpv should enable keyboard input on the X11 window or not. In the command line player, it's enabled by default, but in libmpv it's disabled. This hack has the same problem as all previous embedding had: move the mouse outside of the window, and you don't get keyboard input anymore. Likewise, mpv will steal all keyboard input from the parent application as long as the mouse is inside of the mpv window. Also see issue #1090.
Diffstat (limited to 'video')
-rw-r--r--video/out/x11_common.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index ab700be5e0..390d40a024 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1254,15 +1254,12 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
}
// map window
- int events = StructureNotifyMask | ExposureMask | PropertyChangeMask;
- 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;
- }
+ int events = StructureNotifyMask | ExposureMask | PropertyChangeMask |
+ LeaveWindowMask;
+ if (mp_input_mouse_enabled(vo->input_ctx))
+ events |= PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
+ if (mp_input_x11_keyboard_enabled(vo->input_ctx))
+ events |= KeyPressMask | KeyReleaseMask;
vo_x11_selectinput_witherr(vo, x11->display, x11->window, events);
XMapWindow(x11->display, x11->window);
}
@@ -1667,9 +1664,6 @@ static void vo_x11_selectinput_witherr(struct vo *vo,
Window w,
long event_mask)
{
- if (!mp_input_mouse_enabled(vo->input_ctx))
- event_mask &= ~(PointerMotionMask | ButtonPressMask | ButtonReleaseMask);
-
XSelectInput(display, w, NoEventMask);
// NOTE: this can raise BadAccess, which should be ignored by the X error