~ruther/dwl

e750aa243a25ec78e611883b5e72314067326746 — wochap 1 year, 6 months ago 0dc34ef
add focusortogglescratch function
2 files changed, 38 insertions(+), 0 deletions(-)

M config.def.h
M dwl.c
M config.def.h => config.def.h +1 -0
@@ 125,6 125,7 @@ static const Key keys[] = {
	{ MODKEY,                    XKB_KEY_p,          spawn,          {.v = menucmd} },
	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,     spawn,          {.v = termcmd} },
	{ MODKEY,                    XKB_KEY_grave,      togglescratch,  {.v = scratchpadcmd } },
	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_grave,      focusortogglescratch, {.v = scratchpadcmd } },
	{ MODKEY,                    XKB_KEY_j,          focusstack,     {.i = +1} },
	{ MODKEY,                    XKB_KEY_k,          focusstack,     {.i = -1} },
	{ MODKEY,                    XKB_KEY_i,          incnmaster,     {.i = +1} },

M dwl.c => dwl.c +37 -0
@@ 317,6 317,7 @@ static void tile(Monitor *m);
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 toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);


@@ 2494,6 2495,42 @@ togglescratch(const Arg *arg)
}

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

	/* search for first window that matches the scratchkey */
	wl_list_for_each(c, &clients, link)
		if (c->scratchkey == ((char**)arg->v)[0][0]) {
			found = 1;
			break;
		}

	if (found) {
		if (VISIBLEON(c, selmon)) {
			cwithfocus = focustop(selmon);
			if (cwithfocus == c) {
				// hide
				c->tags = 0;
				focusclient(cwithfocus, 1);
			} else {
				// focus
				focusclient(c, 1);
			}
		} else {
			// show
			c->tags = selmon->tagset[selmon->seltags];
			focusclient(c, 1);
		}
		arrange(selmon);
	} else{
		spawnscratch(arg);
	}
}

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

Do not follow this link