From 3459130e5c5873f3db794a98d63d261e483e23dc Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 12 Jan 2015 12:53:49 +0100 Subject: client API: reasonable behavior if window is closed Closing the video window sends CLOSE_WIN, which is normally mapped to the "quit" command. The client API normally disables all key bindings, and closing the window does nothing. It's simply left to the application to handle this. This is fine - an embedded window can not be destroyed by user interaction. But sometimes, the window might be destroyed anyway, for example because the containing window is destroyed. If this happens, CLOSE_WIN should better not be ignored. We can't expect client API users to handle this specially (by providing their own input.conf), so provide some fallback for this pseudo key binding. The "quit" command might be too intrusive (not every client necessarily handles "unexpected" MPV_EVENT_SHUTDOWN), but I think it's still reasonable. --- input/input.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'input') diff --git a/input/input.c b/input/input.c index 96d99e94f9..79197e5a62 100644 --- a/input/input.c +++ b/input/input.c @@ -460,6 +460,8 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, struct cmd_bind *cmd = find_any_bind_for_key(ictx, force_section, code); if (cmd == NULL) { + if (code == MP_KEY_CLOSE_WIN) + return mp_input_parse_cmd_strv(ictx->log, (const char*[]){"quit", 0}); int msgl = MSGL_WARN; if (code == MP_KEY_MOUSE_MOVE || code == MP_KEY_MOUSE_LEAVE) msgl = MSGL_DEBUG; -- cgit v1.2.3