input: close window when window close button is pressed with --input-test
The window close button is usually mapped to the CLOSE_WIN pseudo-key. Until now, --input-test treated this pseudo-key like any other key (like the rest of the input handling code), so you couldn't close the window in this mode. The manpage had silly instructions and warnings how to deal with this. Just always quit when CLOSE_WIN is received, and improve the instructions.
This commit is contained in:
1 parent
3b12d0add9
commit
ecb4c08ee2
3 files changed
+14
-5
No files matched your search
@@ -21,10 +21,10 @@ In general, keys can be combined with ``Shift``, ``Ctrl`` and ``Alt``::
|
||||
**mpv** can be started in input test mode, which displays key bindings and the
|
||||
commands they're bound to on the OSD, instead of executing the commands::
|
||||
|
||||
mpv --input-test --demuxer=rawvideo --demuxer-rawvideo=w=1280:h=720 /dev/zero
|
||||
mpv --input-test --force-window --idle
|
||||
|
||||
(Commands which normally close the player will not work in this mode, and you
|
||||
must kill **mpv** externally to make it exit.)
|
||||
(Only closing the window will make **mpv** exit, pressing normal keys will
|
||||
merely display the binding, even if mapped to quit.)
|
||||
|
||||
General Input Command Syntax
|
||||
----------------------------
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
# Also see mpv --input-cmdlist for other possible options.
|
||||
# The file should be placed in the $HOME/.mpv directory.
|
||||
#
|
||||
# mpv --input-test --pause dummy.mkv can be used to test which commands keys are
|
||||
# bound to.
|
||||
# mpv --input-test --force-window --idle can be used to test which commands
|
||||
# keys are bound to.
|
||||
#
|
||||
# If you wish to unbind a key, bind it to the 'ignore' command:
|
||||
# KEY ignore
|
||||
|
||||
@@ -311,6 +311,15 @@ static void append_bind_info(struct input_ctx *ictx, char **pmsg,
|
||||
|
||||
static mp_cmd_t *handle_test(struct input_ctx *ictx, int code)
|
||||
{
|
||||
if (code == MP_KEY_CLOSE_WIN) {
|
||||
MP_WARN(ictx,
|
||||
"CLOSE_WIN was received. This pseudo key can be remapped too,\n"
|
||||
"but --input-test will always quit when receiving it.\n");
|
||||
const char *args[] = {"quit", NULL};
|
||||
mp_cmd_t *res = mp_input_parse_cmd_strv(ictx->log, 0, args, "");
|
||||
return res;
|
||||
}
|
||||
|
||||
char *key_buf = mp_input_get_key_combo_name(&code, 1);
|
||||
char *msg = talloc_asprintf(NULL, "Key %s is bound to:\n", key_buf);
|
||||
talloc_free(key_buf);
|
||||
|
||||
Reference in new issue
Block a user