~ruther/dwl

0b3d70706a0aca6d4414d20a3f2ac4928e70d04e — wochap 1 year, 1 month ago b2702af
add focusortogglematchingscratch

works like focusortoggle but it also hides all others scratchpads
1 files changed, 43 insertions(+), 0 deletions(-)

M dwl.c
M dwl.c => dwl.c +43 -0
@@ 318,6 318,7 @@ static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void togglescratch(const Arg *arg);
static void focusortogglescratch(const Arg *arg);
static void focusortogglematchingscratch(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);


@@ 2529,6 2530,48 @@ focusortogglescratch(const Arg *arg)
}

void
focusortogglematchingscratch(const Arg *arg)
{
	Client *c;
	unsigned int found = 0;

	wl_list_for_each(c, &clients, link) {
		if (c->scratchkey == 0) {
			continue;
		}
		if (c->scratchkey == ((char**)arg->v)[0][0]) {
			found = 1;
			if (VISIBLEON(c, selmon)) {
				if (focustop(selmon) == c) {
					// hide
					c->tags = 0;
					focusclient(focustop(selmon), 1);
				} else {
					// focus
					focusclient(c, 1);
				}
			} else {
				// show
				c->tags = selmon->tagset[selmon->seltags];
				// focus
				focusclient(c, 1);
			}
			continue;
		}
		if (VISIBLEON(c, selmon)) {
			// hide
			c->tags = 0;
		}
	}

	if (found) {
		arrange(selmon);
	} else {
		spawnscratch(arg);
	}
}

void
toggletag(const Arg *arg)
{
	uint32_t newtags;

Do not follow this link