minor improvement on swapfocus patch

This commit is contained in:
André Desgualdo Pereira 2026-05-01 08:20:19 -03:00
parent 4e3a344e8d
commit 1587a40514

View File

@ -1,12 +1,12 @@
From 34c613a77683ab0e2beac36276315d037ba222a5 Mon Sep 17 00:00:00 2001
From c4a9254ef63bbe1bae9ed525250e0b187668397f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Thu, 30 Apr 2026 13:36:03 -0300
Subject: [PATCH] add swapfocus patch
Date: Fri, 1 May 2026 08:17:28 -0300
Subject: [PATCH] swapfocus patch improvement
---
config.def.h | 1 +
dwl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
dwl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..23e502d 100644
@ -21,7 +21,7 @@ index 8a6eda0..23e502d 100644
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
diff --git a/dwl.c b/dwl.c
index 101a45f..dac34a6 100644
index 101a45f..5e78719 100644
--- a/dwl.c
+++ b/dwl.c
@@ -332,6 +332,7 @@ static void setsel(struct wl_listener *listener, void *data);
@ -61,7 +61,7 @@ index 101a45f..dac34a6 100644
/* Put the new client atop the focus stack and select its monitor */
if (c && !client_is_unmanaged(c)) {
wl_list_remove(&c->flink);
@@ -2679,6 +2688,42 @@ spawn(const Arg *arg)
@@ -2679,6 +2688,44 @@ spawn(const Arg *arg)
}
}
@ -71,14 +71,13 @@ index 101a45f..dac34a6 100644
+ Client *c;
+ int found = 0;
+
+ if (!prevclient)
+ return;
+
+ /* Verify the client still exists in the list of managed windows */
+ wl_list_for_each(c, &clients, link) {
+ if (c == prevclient) {
+ found = 1;
+ break;
+ if (prevclient) {
+ wl_list_for_each(c, &clients, link) {
+ if (c == prevclient) {
+ found = 1;
+ break;
+ }
+ }
+ }
+
@ -98,6 +97,9 @@ index 101a45f..dac34a6 100644
+ /* Tag IS visible: Just swap focus within the same view */
+ focusclient(prevclient, 1);
+ }
+ } else {
+ Arg a = {.ui = 0};
+ view(&a);
+ }
+}
+