From 3c1bd9956fec0d9e4675fe5fd5b60be4a46d2343 Mon Sep 17 00:00:00 2001 From: IoIxD Date: Sun, 24 May 2026 22:18:29 -0700 Subject: [PATCH] wayland: 'focused' widgets should also have key events sent --- include/Mw/LowLevel/Wayland.h | 1 + src/backend/wayland/interfaces.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/Mw/LowLevel/Wayland.h b/include/Mw/LowLevel/Wayland.h index acbb95a..7d923d1 100644 --- a/include/Mw/LowLevel/Wayland.h +++ b/include/Mw/LowLevel/Wayland.h @@ -537,6 +537,7 @@ struct _MwLLWayland { MwU32 ww, wh; /* Window position */ MwPoint cur_mouse_pos; /* Currently known mouse position */ MwLL currentlyHeldWidget; + MwLL focusedWidget; int resizing; int setting_wh; diff --git a/src/backend/wayland/interfaces.c b/src/backend/wayland/interfaces.c index dfc1988..e6d6bd1 100644 --- a/src/backend/wayland/interfaces.c +++ b/src/backend/wayland/interfaces.c @@ -600,6 +600,9 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri switch(state) { case WL_POINTER_BUTTON_STATE_PRESSED: + if(button == BTN_LEFT) { + topmost_parent->wayland.focusedWidget = self; + } MwLLDispatch(self, down, &p); topmost_parent->wayland.currentlyHeldWidget = self; @@ -718,13 +721,16 @@ static void keyboard_key(void* data, MwU32 time, MwU32 key, MwU32 state) { - MwLL self = data; - MwBool inArea = 0; + MwLL self = data; + MwBool inArea = 0; + MwLL topmost_parent = self; (void)wl_keyboard; (void)serial; (void)time; + while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; + WAYLAND_EVENT_OP_START(self); if(self->wayland.framebuffer.surface) { @@ -734,6 +740,9 @@ static void keyboard_key(void* data, if(self->wayland.backbuffer.surface) { inArea |= self->wayland.backbuffer.surface == curSurface; } + + inArea |= (self == topmost_parent->wayland.focusedWidget); + if(inArea) { xkb_layout_index_t layout; MwU32 levels;