diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-03 14:30:13 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-03 14:30:13 +0300 |
commit | 808ca2028981247bf697b8df5902ffe7c3e50b3f (patch) | |
tree | dcce8ff91e7ca068d00aa38517d9daa5b6766e3c | |
parent | 052a2c7a8a1afe4f3a7bc49481f781e4b879432e (diff) |
Window: Dispatch key events only to the root with key focus
-rw-r--r-- | src/ui/widget.c | 1 | ||||
-rw-r--r-- | src/ui/window.c | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index 62112e86..00fe0f5f 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -879,6 +879,7 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
879 | printf("[%p] %s:'%s' ate the key\n", | 879 | printf("[%p] %s:'%s' ate the key\n", |
880 | child, class_Widget(child)->name, | 880 | child, class_Widget(child)->name, |
881 | cstr_String(id_Widget(child))); | 881 | cstr_String(id_Widget(child))); |
882 | identify_Widget(child); | ||
882 | fflush(stdout); | 883 | fflush(stdout); |
883 | } | 884 | } |
884 | #endif | 885 | #endif |
diff --git a/src/ui/window.c b/src/ui/window.c index 39adba83..577caa4c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -941,6 +941,10 @@ iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
941 | if (isCommand_SDLEvent(ev) && ev->user.data2 && ev->user.data2 != root) { | 941 | if (isCommand_SDLEvent(ev) && ev->user.data2 && ev->user.data2 != root) { |
942 | continue; /* Not meant for this root. */ | 942 | continue; /* Not meant for this root. */ |
943 | } | 943 | } |
944 | else if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP || ev->type == SDL_TEXTINPUT) | ||
945 | && d->keyRoot != root) { | ||
946 | continue; /* Key events go only to the root with keyboard focus. */ | ||
947 | } | ||
944 | setCurrent_Root(root); | 948 | setCurrent_Root(root); |
945 | const iBool wasUsed = dispatchEvent_Widget(root->widget, ev); | 949 | const iBool wasUsed = dispatchEvent_Widget(root->widget, ev); |
946 | if (wasUsed) { | 950 | if (wasUsed) { |