swapfocus: minor update

This commit is contained in:
iglt
2026-10-25 12:32:30 +01:00
parent 8a28588683
commit ae0fe9e212
3 changed files with 165 additions and 23 deletions
+9 -22
View File
@@ -1,15 +1,5 @@
From 364b9f20b830886b9c0e6539ddba2cc206a286eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Thu, 21 May 2026 09:50:03 -0300
Subject: [PATCH] swapfocus patch
---
config.def.h | 1 +
dwl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..23e502d 100644
index a4019d3..02ee21c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -132,6 +132,7 @@ static const Key keys[] = {
@@ -21,18 +11,18 @@ 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..c512323 100644
index d5f2f98..5e65cfa 100644
--- a/dwl.c
+++ b/dwl.c
@@ -332,6 +332,7 @@ static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -362,6 +362,7 @@ static struct wlr_scene_node *snapshot(struct wlr_scene_node *node,
struct wlr_scene_tree *parent, void *data);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
+static void swapfocus(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@@ -375,6 +376,7 @@ static struct wlr_xdg_activation_v1 *activation;
@@ -410,6 +411,7 @@ static struct wlr_xdg_activation_v1 *activation;
static struct wlr_xdg_decoration_manager_v1 *xdg_decoration_mgr;
static struct wl_list clients; /* tiling order */
static struct wl_list fstack; /* focus order */
@@ -40,7 +30,7 @@ index 101a45f..c512323 100644
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
@@ -1330,6 +1332,8 @@ destroynotify(struct wl_listener *listener, void *data)
@@ -1500,6 +1502,8 @@ destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
Client *c = wl_container_of(listener, c, destroy);
@@ -49,7 +39,7 @@ index 101a45f..c512323 100644
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
@@ -1424,6 +1428,11 @@ focusclient(Client *c, int lift)
@@ -1600,6 +1604,11 @@ focusclient(Client *c, LayerSurface *l, int lift)
wlr_xdg_popup_destroy(popup);
}
@@ -61,7 +51,7 @@ index 101a45f..c512323 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,87 @@ spawn(const Arg *arg)
@@ -3015,6 +3024,87 @@ spawn(const Arg *arg)
}
}
@@ -116,7 +106,7 @@ index 101a45f..c512323 100644
+ /* End of not changing tags logic */
+ } else {
+ /* Tag IS visible: Just swap focus within the same view */
+ focusclient(prevclient, 1);
+ focusclient(prevclient, NULL, 1);
+ }
+ } else {
+ Arg a = {.ui = 0};
@@ -149,6 +139,3 @@ index 101a45f..c512323 100644
void
startdrag(struct wl_listener *listener, void *data)
{
--
2.53.0