summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/window.c10
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
949iLocalDef iBool isEscapeKeypress_(const SDL_Event *ev) {
950 return (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) && ev->key.keysym.sym == SDLK_ESCAPE;
951}
952
949iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { 953iBool 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))) {