From dda0948fa3061787f689b2216d8d1a57c54d0cff Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 20 Aug 2021 09:25:11 +0300 Subject: Window: Allow Escape to affect all splits Allow dismissing sidebars in the unfocused split. --- src/ui/window.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/window.c b/src/ui/window.c index 1727b988..c7ee2bbe 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -946,6 +946,10 @@ iBool setKeyRoot_Window(iWindow *d, iRoot *root) { return iFalse; } +iLocalDef iBool isEscapeKeypress_(const SDL_Event *ev) { + return (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) && ev->key.keysym.sym == SDLK_ESCAPE; +} + iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { if (ev->type == SDL_MOUSEMOTION) { /* Hover widget may change. */ @@ -961,7 +965,11 @@ iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { } if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP || ev->type == SDL_TEXTINPUT) && d->keyRoot != root) { - continue; /* Key events go only to the root with keyboard focus. */ + if (!isEscapeKeypress_(ev)) { + /* Key events go only to the root with keyboard focus, with the exception + of Escape that will also affect the entire window. */ + continue; + } } if (ev->type == SDL_MOUSEWHEEL && !contains_Rect(rect_Root(root), coord_MouseWheelEvent(&ev->wheel))) { -- cgit v1.2.3