diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-20 09:25:11 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-20 09:25:11 +0300 |
commit | dda0948fa3061787f689b2216d8d1a57c54d0cff (patch) | |
tree | caeee1d74c34bf18b807dc68fd0ecb8ea6ba5e94 | |
parent | 91e83c498f94433146f61103f310f64088b0b066 (diff) |
Window: Allow Escape to affect all splits
Allow dismissing sidebars in the unfocused split.
-rw-r--r-- | src/ui/window.c | 10 |
1 files changed, 9 insertions, 1 deletions
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) { | |||
946 | return iFalse; | 946 | return iFalse; |
947 | } | 947 | } |
948 | 948 | ||
949 | iLocalDef iBool isEscapeKeypress_(const SDL_Event *ev) { | ||
950 | return (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) && ev->key.keysym.sym == SDLK_ESCAPE; | ||
951 | } | ||
952 | |||
949 | iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { | 953 | iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { |
950 | if (ev->type == SDL_MOUSEMOTION) { | 954 | if (ev->type == SDL_MOUSEMOTION) { |
951 | /* Hover widget may change. */ | 955 | /* Hover widget may change. */ |
@@ -961,7 +965,11 @@ iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
961 | } | 965 | } |
962 | if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP || ev->type == SDL_TEXTINPUT) | 966 | if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP || ev->type == SDL_TEXTINPUT) |
963 | && d->keyRoot != root) { | 967 | && d->keyRoot != root) { |
964 | continue; /* Key events go only to the root with keyboard focus. */ | 968 | if (!isEscapeKeypress_(ev)) { |
969 | /* Key events go only to the root with keyboard focus, with the exception | ||
970 | of Escape that will also affect the entire window. */ | ||
971 | continue; | ||
972 | } | ||
965 | } | 973 | } |
966 | if (ev->type == SDL_MOUSEWHEEL && !contains_Rect(rect_Root(root), | 974 | if (ev->type == SDL_MOUSEWHEEL && !contains_Rect(rect_Root(root), |
967 | coord_MouseWheelEvent(&ev->wheel))) { | 975 | coord_MouseWheelEvent(&ev->wheel))) { |