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 /DOCS | |
parent | aeaa1767e9f62fd45607c2d5b73253ccf6b3e241 (diff) | |
download | mpv-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 'DOCS')
-rw-r--r-- | DOCS/client-api-changes.rst | 5 | ||||
-rw-r--r-- | DOCS/client_api_examples/qtexample.cpp | 4 | ||||
-rw-r--r-- | DOCS/client_api_examples/simple.c | 1 | ||||
-rw-r--r-- | DOCS/man/options.rst | 18 |
4 files changed, 28 insertions, 0 deletions
diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst index b689921e48..be6d86cd46 100644 --- a/DOCS/client-api-changes.rst +++ b/DOCS/client-api-changes.rst @@ -25,7 +25,12 @@ API changes :: + 1.5 - change in X11 and "--wid" behavior again. The previous change didn't + work as expected, and now the behavior can be explicitly controlled + with the "input-x11-keyboard" option. This is only a temporary + measure until XEmbed is implemented and confirmed working. 1.4 - subtle change in X11 and "--wid" behavior + (this change was added to 0.5.2, and broke some things, see #1090) --- mpv 0.5.0 is released --- 1.3 - add MPV_MAKE_VERSION() 1.2 - remove "stream-time-pos" property (no replacement) diff --git a/DOCS/client_api_examples/qtexample.cpp b/DOCS/client_api_examples/qtexample.cpp index 39dc1fd1d4..84b1102055 100644 --- a/DOCS/client_api_examples/qtexample.cpp +++ b/DOCS/client_api_examples/qtexample.cpp @@ -53,6 +53,10 @@ MainWindow::MainWindow(QWidget *parent) : // mpv as backend would implement its own key bindings. mpv_set_option_string(mpv, "input-default-bindings", "yes"); + // Enable keyboard input on the X11 window. For the messy details, see + // --input-x11-keyboard on the manpage. + mpv_set_option_string(mpv, "input-x11-keyboard", "yes"); + // Let us receive property change events with MPV_EVENT_PROPERTY_CHANGE if // this property changes. mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE); diff --git a/DOCS/client_api_examples/simple.c b/DOCS/client_api_examples/simple.c index d3a4c78c26..6dbc40506a 100644 --- a/DOCS/client_api_examples/simple.c +++ b/DOCS/client_api_examples/simple.c @@ -21,6 +21,7 @@ int main(int argc, char *argv[]) // Enable default key bindings, so the user can actually interact with // the player (and e.g. close the window). check_error(mpv_set_option_string(ctx, "input-default-bindings", "yes")); + mpv_set_option_string(ctx, "input-x11-keyboard", "yes"); int val = 1; check_error(mpv_set_option(ctx, "osc", MPV_FORMAT_FLAG, &val)); diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index b61484ccfe..b0292ae90c 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2163,6 +2163,24 @@ Input Use the right Alt key as Alt Gr to produce special characters. If disabled, count the right Alt as an Alt modifier key. Enabled by default. +``--input-x11-keyboard=<yes|no>`` + Disable all keyboard input on the X11 VO window. Generally useful for + embedding only. + + On X11, a sub-window with input enabled grabs all keyboard input as long + as it is 1. a child of a focused window, and 2. the mouse is inside of + the sub-window. The can steal away all keyboard input from the + application embedding the mpv window, and on the other hand, the mpv + window will receive no input if the mouse is outside of the mpv window, + even though mpv has focus. Modern toolkits work around this weird X11 + behavior, but naively embedding foreign windows breaks it. + + The only way to handle this reasonably is using the XEmbed protocol, which + was designed to solve these problems. But Qt has questionable support, and + mpv doesn't implement it yet. + + As a workaround, this option is disabled by default in libmpv. (Note that + ``input-default-bindings`` is disabled by default in libmpv as well.) OSD --- |