mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-27 18:24:26 +00:00
update globalkey
This commit is contained in:
parent
970ae42e95
commit
6f806dc096
@ -1,12 +1,12 @@
|
|||||||
From 9c8632f65f0145b5d6bcb4df7830a12eea058838 Mon Sep 17 00:00:00 2001
|
From d22333d0f165cf30fc2621f8efa46216c607e2f1 Mon Sep 17 00:00:00 2001
|
||||||
From: korei999 <ju7t1xe@gmail.com>
|
From: korei999 <ju7t1xe@gmail.com>
|
||||||
Date: Sat, 8 Jun 2024 20:08:22 +0300
|
Date: Fri, 14 Jun 2024 18:28:34 +0300
|
||||||
Subject: [PATCH] implement globalkey patch
|
Subject: [PATCH] implement globalkey patch
|
||||||
|
|
||||||
---
|
---
|
||||||
config.def.h | 8 ++++++++
|
config.def.h | 8 ++++++++
|
||||||
dwl.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
dwl.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
2 files changed, 64 insertions(+)
|
2 files changed, 66 insertions(+)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index a784eb4..59c5267 100644
|
index a784eb4..59c5267 100644
|
||||||
@ -28,7 +28,7 @@ index a784eb4..59c5267 100644
|
|||||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index 6f041a0..9625c10 100644
|
index 5a31aee..2590815 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -218,6 +218,13 @@ typedef struct {
|
@@ -218,6 +218,13 @@ typedef struct {
|
||||||
@ -53,31 +53,33 @@ index 6f041a0..9625c10 100644
|
|||||||
static void keypressmod(struct wl_listener *listener, void *data);
|
static void keypressmod(struct wl_listener *listener, void *data);
|
||||||
static int keyrepeat(void *data);
|
static int keyrepeat(void *data);
|
||||||
static void killclient(const Arg *arg);
|
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. */
|
/* This event is raised when a key is pressed or released. */
|
||||||
KeyboardGroup *group = wl_container_of(listener, group, key);
|
KeyboardGroup *group = wl_container_of(listener, group, key);
|
||||||
struct wlr_keyboard_key_event *event = data;
|
struct wlr_keyboard_key_event *event = data;
|
||||||
+ struct wlr_surface *last_surface = seat->keyboard_state.focused_surface;
|
+ 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 */
|
/* Translate libinput keycode -> xkbcommon */
|
||||||
uint32_t keycode = event->keycode + 8;
|
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)
|
if (handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
+ /* passed keys won't be repeated */
|
+ /* don't pass when popup is focused
|
||||||
+ if (last_surface) {
|
+ * this is better than having popups (like fuzzel or wmenu) closing while typing in a passed keybind */
|
||||||
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(last_surface);
|
+ pass = (xdg_surface && xdg_surface->role != WLR_XDG_SURFACE_ROLE_POPUP) || !last_surface
|
||||||
+ /* don't pass when popup is focused
|
+#ifdef XWAYLAND
|
||||||
+ * this is better than having popups (like fuzzel or wmenu) closing while typing in a passed keybind */
|
+ || xsurface
|
||||||
+ if (xdg_surface && xdg_surface->role != WLR_XDG_SURFACE_ROLE_POPUP) {
|
+#endif
|
||||||
+ keypressglobal(last_surface, &group->wlr_group->keyboard, event, mods, syms[0]);
|
+ ;
|
||||||
+ }
|
+ /* passed keys don't get repeated */
|
||||||
+ } else {
|
+ if (pass)
|
||||||
+ /* if no surface pass anyway */
|
|
||||||
+ keypressglobal(last_surface, &group->wlr_group->keyboard, event, mods, syms[0]);
|
+ keypressglobal(last_surface, &group->wlr_group->keyboard, event, mods, syms[0]);
|
||||||
+ }
|
|
||||||
+
|
+
|
||||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||||
/* Pass unhandled keycodes along to the client. */
|
/* Pass unhandled keycodes along to the client. */
|
||||||
@ -122,5 +124,5 @@ index 6f041a0..9625c10 100644
|
|||||||
keypressmod(struct wl_listener *listener, void *data)
|
keypressmod(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
--
|
--
|
||||||
2.45.1
|
2.45.2
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user