From 6f806dc0967de8faf3bed5cfeaaae930b5c8b661 Mon Sep 17 00:00:00 2001 From: korei999 Date: Fri, 14 Jun 2024 18:29:31 +0300 Subject: [PATCH] update globalkey --- patches/globalkey/globalkey.patch | 42 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/patches/globalkey/globalkey.patch b/patches/globalkey/globalkey.patch index e8665fd..7a581df 100644 --- a/patches/globalkey/globalkey.patch +++ b/patches/globalkey/globalkey.patch @@ -1,12 +1,12 @@ -From 9c8632f65f0145b5d6bcb4df7830a12eea058838 Mon Sep 17 00:00:00 2001 +From d22333d0f165cf30fc2621f8efa46216c607e2f1 Mon Sep 17 00:00:00 2001 From: korei999 -Date: Sat, 8 Jun 2024 20:08:22 +0300 +Date: Fri, 14 Jun 2024 18:28:34 +0300 Subject: [PATCH] implement globalkey patch --- config.def.h | 8 ++++++++ - dwl.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 64 insertions(+) + dwl.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 66 insertions(+) diff --git a/config.def.h b/config.def.h index a784eb4..59c5267 100644 @@ -28,7 +28,7 @@ index a784eb4..59c5267 100644 /* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */ /* modifier key function argument */ diff --git a/dwl.c b/dwl.c -index 6f041a0..9625c10 100644 +index 5a31aee..2590815 100644 --- a/dwl.c +++ b/dwl.c @@ -218,6 +218,13 @@ typedef struct { @@ -53,31 +53,33 @@ index 6f041a0..9625c10 100644 static void keypressmod(struct wl_listener *listener, void *data); static int keyrepeat(void *data); static void killclient(const Arg *arg); -@@ -1516,6 +1524,8 @@ keypress(struct wl_listener *listener, void *data) +@@ -1513,6 +1521,12 @@ keypress(struct wl_listener *listener, void *data) /* This event is raised when a key is pressed or released. */ KeyboardGroup *group = wl_container_of(listener, group, key); struct wlr_keyboard_key_event *event = data; + struct wlr_surface *last_surface = seat->keyboard_state.focused_surface; -+ struct wlr_xdg_surface* xdg_surface = NULL; ++ struct wlr_xdg_surface *xdg_surface = last_surface ? wlr_xdg_surface_try_from_wlr_surface(last_surface) : NULL; ++ int pass = 0; ++#ifdef XWAYLAND ++ struct wlr_xwayland_surface *xsurface = last_surface ? wlr_xwayland_surface_try_from_wlr_surface(last_surface) : NULL; ++#endif /* Translate libinput keycode -> xkbcommon */ uint32_t keycode = event->keycode + 8; -@@ -1550,12 +1560,58 @@ keypress(struct wl_listener *listener, void *data) +@@ -1547,12 +1561,56 @@ keypress(struct wl_listener *listener, void *data) if (handled) return; -+ /* passed keys won't be repeated */ -+ if (last_surface) { -+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(last_surface); -+ /* don't pass when popup is focused -+ * this is better than having popups (like fuzzel or wmenu) closing while typing in a passed keybind */ -+ if (xdg_surface && xdg_surface->role != WLR_XDG_SURFACE_ROLE_POPUP) { -+ keypressglobal(last_surface, &group->wlr_group->keyboard, event, mods, syms[0]); -+ } -+ } else { -+ /* if no surface pass anyway */ ++ /* don't pass when popup is focused ++ * this is better than having popups (like fuzzel or wmenu) closing while typing in a passed keybind */ ++ pass = (xdg_surface && xdg_surface->role != WLR_XDG_SURFACE_ROLE_POPUP) || !last_surface ++#ifdef XWAYLAND ++ || xsurface ++#endif ++ ; ++ /* passed keys don't get repeated */ ++ if (pass) + keypressglobal(last_surface, &group->wlr_group->keyboard, event, mods, syms[0]); -+ } + wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard); /* Pass unhandled keycodes along to the client. */ @@ -122,5 +124,5 @@ index 6f041a0..9625c10 100644 keypressmod(struct wl_listener *listener, void *data) { -- -2.45.1 +2.45.2