mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-26 17:54:17 +00:00
singletagset Rutherther's fixes for issue #57
This commit is contained in:
parent
34c6a26ed2
commit
75e17ef588
@ -10,7 +10,8 @@ https://dwm.suckless.org/patches/single_tagset/
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/bencc/dwl/src/branch/singletagset)
|
||||
- [2024-05-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/singletagset/singletagset.patch)
|
||||
- [2024-05-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/singletagset/singletagset.patch)
|
||||
|
||||
### Authors
|
||||
- [Ben Collerson](https://codeberg.org/bencc)
|
||||
- [Rutherther](https://codeberg.org/Rutherther)
|
||||
|
||||
@ -1,26 +1,25 @@
|
||||
From 8aff7cfe2137c3410bc4b02e3fdf685a67a3217e Mon Sep 17 00:00:00 2001
|
||||
From 140fe587bf34cf43e44acaf365b16ec3e385f742 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Tue, 2 Jan 2024 10:22:31 +1000
|
||||
Date: Thu, 16 May 2024 09:56:58 +1000
|
||||
Subject: [PATCH] singletagset
|
||||
|
||||
---
|
||||
dwl.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
|
||||
1 file changed, 81 insertions(+), 10 deletions(-)
|
||||
dwl.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 140 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bf763dfc..56586125 100644
|
||||
index bf763dfc..5b1d594f 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -71,7 +71,7 @@
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
@@ -72,6 +72,7 @@
|
||||
#define ROUND(X) ((int)((X < 0) ? (X - 0.5) : (X + 0.5)))
|
||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
||||
-#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
+#define VISIBLEON(C, M) ((M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
+#define SVISIBLEON(C, M) ((M) && (C)->mon && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define END(A) ((A) + LENGTH(A))
|
||||
#define TAGMASK ((1u << TAGCOUNT) - 1)
|
||||
@@ -246,6 +246,7 @@ static void arrange(Monitor *m);
|
||||
@@ -246,6 +247,7 @@ static void arrange(Monitor *m);
|
||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
@ -28,7 +27,7 @@ index bf763dfc..56586125 100644
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
@@ -283,6 +284,7 @@ static void focusmon(const Arg *arg);
|
||||
@@ -283,6 +285,7 @@ static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
@ -36,23 +35,72 @@ index bf763dfc..56586125 100644
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
@@ -558,6 +560,15 @@ arrangelayers(Monitor *m)
|
||||
@@ -470,7 +473,18 @@ applyrules(Client *c)
|
||||
}
|
||||
}
|
||||
}
|
||||
+ wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]);
|
||||
+
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ // tag with different monitor selected by rules
|
||||
+ if (m->tagset[m->seltags] & newtags) {
|
||||
+ mon = m;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
setmon(c, mon, newtags);
|
||||
+ attachclients(mon);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -558,6 +572,45 @@ arrangelayers(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+attachclients(Monitor *m)
|
||||
+{
|
||||
+ Monitor *tm;
|
||||
+ unsigned int utags = 0;
|
||||
+ Client *c;
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (c->tags & m->tagset[m->seltags])
|
||||
+ int rmons = 0;
|
||||
+
|
||||
+ if (m == NULL) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ wl_list_for_each(tm, &mons, link) {
|
||||
+ if (tm != m) {
|
||||
+ utags |= tm->tagset[tm->seltags];
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (SVISIBLEON(c, m)) {
|
||||
+ /* if client is also visible on other tags that are displayed on
|
||||
+ * other monitors, remove these tags */
|
||||
+ if (c->tags & utags) {
|
||||
+ c->tags = c->tags & m->tagset[m->seltags];
|
||||
+ rmons = 1;
|
||||
+ }
|
||||
+ setmon(c, m, c->tags);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (rmons) {
|
||||
+ wl_list_for_each(tm, &mons, link) {
|
||||
+ if (tm != m) {
|
||||
+ arrange(tm);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
axisnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -881,7 +892,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -881,7 +934,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
wlr_output_state_init(&state);
|
||||
/* Initialize monitor state using configured rules */
|
||||
@ -61,16 +109,16 @@ index bf763dfc..56586125 100644
|
||||
for (r = monrules; r < END(monrules); r++) {
|
||||
if (!r->name || strstr(wlr_output->name, r->name)) {
|
||||
m->m.x = r->x;
|
||||
@@ -1354,7 +1365,7 @@ focustop(Monitor *m)
|
||||
@@ -1354,7 +1407,7 @@ focustop(Monitor *m)
|
||||
{
|
||||
Client *c;
|
||||
wl_list_for_each(c, &fstack, flink) {
|
||||
- if (VISIBLEON(c, m))
|
||||
+ if (VISIBLEON(c, m) && c->mon)
|
||||
+ if (SVISIBLEON(c, m))
|
||||
return c;
|
||||
}
|
||||
return NULL;
|
||||
@@ -1367,6 +1378,22 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
||||
@@ -1367,6 +1420,29 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
||||
setfullscreen(c, client_wants_fullscreen(c));
|
||||
}
|
||||
|
||||
@ -79,12 +127,19 @@ index bf763dfc..56586125 100644
|
||||
+{
|
||||
+ size_t i = 0;
|
||||
+ Monitor *m;
|
||||
+ if (wl_list_empty(&mons))
|
||||
+ if (wl_list_empty(&mons)) {
|
||||
+ return i;
|
||||
+ }
|
||||
+ for (i=0; i < TAGCOUNT; i++) {
|
||||
+ int is_used = 0;
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ if (!(m->tagset[m->seltags] & (1<<i)))
|
||||
+ return i;
|
||||
+ if ((m->tagset[m->seltags] & (1<<i))) {
|
||||
+ is_used = 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!is_used) {
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+ return i;
|
||||
@ -93,7 +148,7 @@ index bf763dfc..56586125 100644
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
@@ -1915,8 +1942,6 @@ printstatus(void)
|
||||
@@ -1915,8 +1991,6 @@ printstatus(void)
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
occ = urg = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
@ -102,7 +157,7 @@ index bf763dfc..56586125 100644
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
@@ -2551,6 +2576,7 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
@@ -2551,6 +2625,7 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
@ -110,7 +165,7 @@ index bf763dfc..56586125 100644
|
||||
Client *sel = focustop(selmon);
|
||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
||||
return;
|
||||
@@ -2558,15 +2584,25 @@ tag(const Arg *arg)
|
||||
@@ -2558,15 +2633,25 @@ tag(const Arg *arg)
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
@ -137,7 +192,7 @@ index bf763dfc..56586125 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2623,12 +2659,18 @@ togglefullscreen(const Arg *arg)
|
||||
@@ -2623,12 +2708,18 @@ togglefullscreen(const Arg *arg)
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
@ -156,7 +211,7 @@ index bf763dfc..56586125 100644
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
@@ -2637,11 +2679,17 @@ toggletag(const Arg *arg)
|
||||
@@ -2637,11 +2728,17 @@ toggletag(const Arg *arg)
|
||||
void
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
@ -174,32 +229,44 @@ index bf763dfc..56586125 100644
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
@@ -2825,13 +2873,36 @@ urgent(struct wl_listener *listener, void *data)
|
||||
@@ -2759,6 +2856,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
wlr_session_lock_surface_v1_configure(m->lock_surface, m->m.width, m->m.height);
|
||||
}
|
||||
|
||||
+ attachclients(m);
|
||||
/* Calculate the effective monitor geometry to use for clients */
|
||||
arrangelayers(m);
|
||||
/* Don't move clients to the left output when plugging monitors */
|
||||
@@ -2825,13 +2923,45 @@ urgent(struct wl_listener *listener, void *data)
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
- if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
+ Monitor *m, *origm = selmon;
|
||||
+ unsigned int newtags = selmon->tagset[selmon->seltags ^ 1];
|
||||
+ unsigned int newtags;
|
||||
+
|
||||
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
+ if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) {
|
||||
return;
|
||||
- selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
+ }
|
||||
+
|
||||
+ newtags = origm->tagset[origm->seltags ^ 1];
|
||||
+
|
||||
+ /* swap tags when trying to display a tag from another monitor */
|
||||
if (arg->ui & TAGMASK)
|
||||
- selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
- arrange(selmon);
|
||||
+ if (arg->ui & TAGMASK) {
|
||||
+ newtags = arg->ui & TAGMASK;
|
||||
+ }
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ if (m != selmon && newtags & m->tagset[m->seltags]) {
|
||||
+ if (m != origm && newtags & m->tagset[m->seltags]) {
|
||||
+ /* prevent displaying all tags (MODKEY-0) when multiple monitors
|
||||
+ * are connected */
|
||||
+ if (newtags & selmon->tagset[selmon->seltags])
|
||||
+ if (newtags & origm->tagset[origm->seltags]) {
|
||||
+ return;
|
||||
+ }
|
||||
+ m->seltags ^= 1;
|
||||
+ m->tagset[m->seltags] = selmon->tagset[selmon->seltags];
|
||||
+ m->tagset[m->seltags] = origm->tagset[origm->seltags];
|
||||
+ attachclients(m);
|
||||
+ /* Beware: this changes selmon */
|
||||
+ focusclient(focustop(m), 1);
|
||||
+ arrange(m);
|
||||
+ break;
|
||||
@ -207,8 +274,14 @@ index bf763dfc..56586125 100644
|
||||
+ }
|
||||
+
|
||||
+ origm->seltags ^= 1; /* toggle sel tagset */
|
||||
+ if (arg->ui & TAGMASK)
|
||||
if (arg->ui & TAGMASK)
|
||||
- selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
- arrange(selmon);
|
||||
+ origm->tagset[origm->seltags] = arg->ui & TAGMASK;
|
||||
+
|
||||
+ /* Change selmon back to orig mon */
|
||||
+ selmon = origm;
|
||||
+ attachclients(origm);
|
||||
+ focusclient(focustop(origm), 1);
|
||||
+ arrange(origm);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user