mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-26 09:44:21 +00:00
add singletagset patch
This commit is contained in:
parent
591a36a5d9
commit
bdf407a942
202
singletagset/singletagset.patch
Normal file
202
singletagset/singletagset.patch
Normal file
@ -0,0 +1,202 @@
|
||||
From 2311e2e20f533f1aae16581a6359ca871c7869cd Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Tue, 2 Jan 2024 10:22:31 +1000
|
||||
Subject: [PATCH] singletagset
|
||||
|
||||
---
|
||||
dwl.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 79 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 4d19357f..f84c8a27 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -236,6 +236,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);
|
||||
+static void attachclients(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
@@ -269,6 +270,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);
|
||||
+static size_t getunusedtag(void);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
@@ -533,6 +535,15 @@ arrangelayers(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+attachclients(Monitor *m)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (c->tags & m->tagset[m->seltags])
|
||||
+ setmon(c, m, c->tags);
|
||||
+}
|
||||
+
|
||||
void
|
||||
axisnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -856,7 +867,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
wlr_output_state_init(&state);
|
||||
/* Initialize monitor state using configured rules */
|
||||
- m->tagset[0] = m->tagset[1] = 1;
|
||||
+ m->tagset[0] = m->tagset[1] = (1<<getunusedtag()) & TAGMASK;
|
||||
for (r = monrules; r < END(monrules); r++) {
|
||||
if (!r->name || strstr(wlr_output->name, r->name)) {
|
||||
m->m.x = r->x;
|
||||
@@ -1311,6 +1322,22 @@ handlesig(int signo)
|
||||
}
|
||||
}
|
||||
|
||||
+size_t
|
||||
+getunusedtag(void)
|
||||
+{
|
||||
+ size_t i = 0;
|
||||
+ Monitor *m;
|
||||
+ if (wl_list_empty(&mons))
|
||||
+ return i;
|
||||
+ for (i=0; i < TAGCOUNT; i++) {
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ if (!(m->tagset[m->seltags] & (1<<i)))
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+ return i;
|
||||
+}
|
||||
+
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -1807,8 +1834,6 @@ printstatus(void)
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
occ = urg = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
- if (c->mon != m)
|
||||
- continue;
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
@@ -2431,6 +2456,7 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
+ Monitor *m;
|
||||
Client *sel = focustop(selmon);
|
||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
||||
return;
|
||||
@@ -2438,15 +2464,25 @@ tag(const Arg *arg)
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ attachclients(m);
|
||||
+ arrange(m);
|
||||
+ }
|
||||
printstatus();
|
||||
}
|
||||
|
||||
void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
+ Monitor *m;
|
||||
Client *sel = focustop(selmon);
|
||||
- if (sel)
|
||||
+ if (sel) {
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ arrange(m);
|
||||
+ }
|
||||
+ focusclient(focustop(sel->mon), 1);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2502,12 +2538,18 @@ togglefullscreen(const Arg *arg)
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
+ Monitor *m;
|
||||
uint32_t newtags;
|
||||
Client *sel = focustop(selmon);
|
||||
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
||||
return;
|
||||
|
||||
+ wl_list_for_each(m, &mons, link)
|
||||
+ if (m !=selmon && newtags & m->tagset[m->seltags])
|
||||
+ return;
|
||||
+
|
||||
sel->tags = newtags;
|
||||
+ attachclients(selmon);
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
@@ -2516,11 +2558,17 @@ toggletag(const Arg *arg)
|
||||
void
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
+ Monitor *m;
|
||||
uint32_t newtagset;
|
||||
if (!(newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0))
|
||||
return;
|
||||
|
||||
+ wl_list_for_each(m, &mons, link)
|
||||
+ if (m !=selmon && newtagset & m->tagset[m->seltags])
|
||||
+ return;
|
||||
+
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
+ attachclients(selmon);
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
@@ -2704,13 +2752,36 @@ urgent(struct wl_listener *listener, void *data)
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
+ Monitor *m, *origm = selmon;
|
||||
+ unsigned int newtags = selmon->tagset[selmon->seltags ^ 1];
|
||||
+
|
||||
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
- selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
+
|
||||
+ /* 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);
|
||||
+ newtags = arg->ui & TAGMASK;
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ if (m != selmon && newtags & m->tagset[m->seltags]) {
|
||||
+ /* prevent displaying all tags (MODKEY-0) when multiple monitors
|
||||
+ * are connected */
|
||||
+ if (newtags & selmon->tagset[selmon->seltags])
|
||||
+ return;
|
||||
+ m->seltags ^= 1;
|
||||
+ m->tagset[m->seltags] = selmon->tagset[selmon->seltags];
|
||||
+ attachclients(m);
|
||||
+ focusclient(focustop(m), 1);
|
||||
+ arrange(m);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ origm->seltags ^= 1; /* toggle sel tagset */
|
||||
+ if (arg->ui & TAGMASK)
|
||||
+ origm->tagset[origm->seltags] = arg->ui & TAGMASK;
|
||||
+ attachclients(origm);
|
||||
+ focusclient(focustop(origm), 1);
|
||||
+ arrange(origm);
|
||||
printstatus();
|
||||
}
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user