apply singletagset patch

master
Ryan 2023-09-25 10:14:18 -04:00
parent 6213cb83d0
commit d436530ed3
Signed by: ryan
GPG Key ID: 7D7E2E94267DAD95
1 changed files with 79 additions and 9 deletions

88
dwl.c
View File

@ -236,6 +236,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive); struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m); static void arrangelayers(Monitor *m);
static void autostartexec(void); static void autostartexec(void);
static void attachclients(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data); static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data); static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg); static void chvt(const Arg *arg);
@ -281,6 +282,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m); static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data); static void fullscreennotify(struct wl_listener *listener, void *data);
static void handlesig(int signo); static void handlesig(int signo);
static size_t getunusedtag(void);
static void incnmaster(const Arg *arg); static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data); static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym); static int keybinding(uint32_t mods, xkb_keysym_t sym);
@ -601,6 +603,15 @@ autostartexec(void) {
} }
} }
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 void
axisnotify(struct wl_listener *listener, void *data) axisnotify(struct wl_listener *listener, void *data)
{ {
@ -969,7 +980,7 @@ createmon(struct wl_listener *listener, void *data)
/* Initialize monitor state using configured rules */ /* Initialize monitor state using configured rules */
for (i = 0; i < LENGTH(m->layers); i++) for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]); wl_list_init(&m->layers[i]);
m->tagset[0] = m->tagset[1] = 1; m->tagset[0] = m->tagset[1] = (1<<getunusedtag()) & TAGMASK;
for (r = monrules; r < END(monrules); r++) { for (r = monrules; r < END(monrules); r++) {
if (!r->name || strstr(wlr_output->name, r->name)) { if (!r->name || strstr(wlr_output->name, r->name)) {
m->mfact = r->mfact; m->mfact = r->mfact;
@ -1575,6 +1586,22 @@ fullscreennotify(struct wl_listener *listener, void *data)
setfullscreen(c, client_wants_fullscreen(c)); setfullscreen(c, client_wants_fullscreen(c));
} }
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 void
handlesig(int signo) handlesig(int signo)
{ {
@ -2114,8 +2141,6 @@ printstatus(void)
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
occ = urg = 0; occ = urg = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
occ |= c->tags; occ |= c->tags;
if (c->isurgent) if (c->isurgent)
urg |= c->tags; urg |= c->tags;
@ -2608,22 +2633,32 @@ startdrag(struct wl_listener *listener, void *data)
void void
tag(const Arg *arg) tag(const Arg *arg)
{ {
Monitor *m;
Client *sel = focustop(selmon); Client *sel = focustop(selmon);
if (!sel || (arg->ui & TAGMASK) == 0) if (!sel || (arg->ui & TAGMASK) == 0)
return; return;
sel->tags = arg->ui & TAGMASK; sel->tags = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); wl_list_for_each(m, &mons, link) {
attachclients(m);
arrange(m);
}
printstatus(); printstatus();
} }
void void
tagmon(const Arg *arg) tagmon(const Arg *arg)
{ {
Monitor *m;
Client *sel = focustop(selmon); Client *sel = focustop(selmon);
if (sel) if (sel) {
setmon(sel, dirtomon(arg->i), 0); setmon(sel, dirtomon(arg->i), 0);
wl_list_for_each(m, &mons, link) {
arrange(m);
}
focusclient(focustop(sel->mon), 1);
}
} }
void void
@ -2686,6 +2721,7 @@ togglefullscreen(const Arg *arg)
void void
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {
Monitor *m;
uint32_t newtags; uint32_t newtags;
Client *sel = focustop(selmon); Client *sel = focustop(selmon);
if (!sel) if (!sel)
@ -2694,7 +2730,12 @@ toggletag(const Arg *arg)
if (!newtags) if (!newtags)
return; return;
wl_list_for_each(m, &mons, link)
if (m !=selmon && newtags & m->tagset[m->seltags])
return;
sel->tags = newtags; sel->tags = newtags;
attachclients(selmon);
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
@ -2703,12 +2744,18 @@ toggletag(const Arg *arg)
void void
toggleview(const Arg *arg) toggleview(const Arg *arg)
{ {
Monitor *m;
uint32_t newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0; uint32_t newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0;
if (!newtagset) if (!newtagset)
return; return;
wl_list_for_each(m, &mons, link)
if (m !=selmon && newtagset & m->tagset[m->seltags])
return;
selmon->tagset[selmon->seltags] = newtagset; selmon->tagset[selmon->seltags] = newtagset;
attachclients(selmon);
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
@ -2877,13 +2924,36 @@ urgent(struct wl_listener *listener, void *data)
void void
view(const Arg *arg) 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]) if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return; return;
selmon->seltags ^= 1; /* toggle sel tagset */
/* swap tags when trying to display a tag from another monitor */
if (arg->ui & TAGMASK) if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; newtags = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1); wl_list_for_each(m, &mons, link) {
arrange(selmon); 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(); printstatus();
} }