diff options
author | wm4 <wm4@nowhere> | 2014-09-28 20:11:00 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-28 20:11:00 +0200 |
commit | 3273db1ef72a9d1ee76ba704ace6c1b1898ab945 (patch) | |
tree | d0602014e7e0cfcf8cee335b3a4aee2a1c10e227 /input | |
parent | aeaa1767e9f62fd45607c2d5b73253ccf6b3e241 (diff) |
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 'input')
-rw-r--r-- | input/input.c | 11 | ||||
-rw-r--r-- | input/input.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/input/input.c b/input/input.c index c0c5b57cd8..dd3e0b33c4 100644 --- a/input/input.c +++ b/input/input.c @@ -175,6 +175,7 @@ struct input_opts { int use_media_keys; int default_bindings; int enable_mouse_movements; + int x11_key_input; int test; }; @@ -195,6 +196,7 @@ const struct m_sub_options input_config = { OPT_FLAG("right-alt-gr", use_alt_gr, CONF_GLOBAL), OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000), OPT_FLAG("cursor", enable_mouse_movements, CONF_GLOBAL), + OPT_FLAG("x11-keyboard", x11_key_input, CONF_GLOBAL), #if HAVE_LIRC OPT_STRING("lirc-conf", lirc_configfile, CONF_GLOBAL), #endif @@ -218,6 +220,7 @@ const struct m_sub_options input_config = { .use_media_keys = 1, #endif .default_bindings = 1, + .x11_key_input = 1, }, }; @@ -706,6 +709,14 @@ bool mp_input_mouse_enabled(struct input_ctx *ictx) return r; } +bool mp_input_x11_keyboard_enabled(struct input_ctx *ictx) +{ + input_lock(ictx); + bool r = ictx->opts->x11_key_input; + input_unlock(ictx); + return r; +} + void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y) { input_lock(ictx); diff --git a/input/input.h b/input/input.h index 9a6596d3d2..39489fff75 100644 --- a/input/input.h +++ b/input/input.h @@ -156,6 +156,8 @@ void mp_input_get_mouse_pos(struct input_ctx *ictx, int *x, int *y); // Return whether we want/accept mouse input. bool mp_input_mouse_enabled(struct input_ctx *ictx); +bool mp_input_x11_keyboard_enabled(struct input_ctx *ictx); + /* Make mp_input_set_mouse_pos() mangle the mouse coordinates. Hack for certain * VOs. dst=NULL, src=NULL reset it. src can be NULL. */ |