~ruther/dwl

202a61f84ae5421a9161a4287e8239d181cd5fc9 — Ben Collerson 1 year, 3 months ago 6340989
singletagset
1 files changed, 80 insertions(+), 9 deletions(-)

M dwl.c
M dwl.c => dwl.c +80 -9
@@ 66,7 66,7 @@
#define MAX(A, B)               ((A) > (B) ? (A) : (B))
#define MIN(A, B)               ((A) < (B) ? (A) : (B))
#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 LENGTH(X)               (sizeof X / sizeof X[0])
#define END(A)                  ((A) + LENGTH(A))
#define TAGMASK                 ((1u << TAGCOUNT) - 1)


@@ 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);


@@ 534,6 536,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)
{
	/* This event is forwarded by the cursor when a pointer emits an axis event,


@@ 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;


@@ 1290,6 1301,22 @@ fullscreennotify(struct wl_listener *listener, void *data)
	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
handlesig(int signo)
{


@@ 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();
}


Do not follow this link