~ruther/dwl

2daeeb4ffd1b7b382b80976a14f0ae5f23b920b9 — Leonardo Hernández Hernández 1 year, 5 months ago 3d2e36f
allow clients to be focused on activation requests

Not all clients are allow to do so. Users can specify which clients through rules

Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
2 files changed, 35 insertions(+), 10 deletions(-)

M config.def.h
M dwl.c
M config.def.h => config.def.h +5 -5
@@ 29,12 29,12 @@ static int log_level = WLR_ERROR;

/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
	/* app_id             title       tags mask     isfloating  isterm  noswallow  monitor scratchkey */
	/* app_id             title       tags mask     isfloating  isterm  noswallow allow_activation monitor scratchkey */
	/* examples: */
  { "Gimp_EXAMPLE",     NULL,       0,            1,          0,      0,         -1,     0 }, /* Start on currently visible tags floating, not tiled */
  { "firefox_EXAMPLE",  NULL,       1 << 8,       0,          0,      0,         -1,     0 }, /* Start on ONLY tag "9" */
  { "foot",             NULL,       0,            0,          1,      1,         -1,     0 }, /* make foot swallow clients that are not foot */
	{ NULL,               "scratchpad", 0,          1,          0,      0,         -1,     's' },
  { "Gimp_EXAMPLE",     NULL,       0,            1,          0,      0,        0,               -1,     0   }, /* Start on currently visible tags floating, not tiled */
  { "firefox_EXAMPLE",  NULL,       1 << 8,       0,          0,      0,        0,               -1,     0   }, /* Start on ONLY tag "9" */
  { "foot",             NULL,       0,            0,          1,      1,        1,               -1,     0   }, /* make foot swallow clients that are not foot */
	{ NULL,               "scratchpad", 0,          1,          0,      0,        0,               -1,     's' },
};

/* layout(s) */

M dwl.c => dwl.c +30 -5
@@ 148,6 148,7 @@ struct Client {
	uint32_t tags;
  int isfloating, isurgent, isfullscreen, issticky, isterm, noswallow;
	char scratchkey;
	int allow_activation;
	uint32_t resize; /* configure serial of a pending resize */
	pid_t pid;
	Client *swallowing, *swallowedby;


@@ 258,6 259,7 @@ typedef struct {
	int isfloating;
	int isterm;
	int noswallow;
	int allow_activation;
	int monitor;
	const char scratchkey;
} Rule;


@@ 599,6 601,7 @@ applyrules(Client *c)
			c->isterm     = r->isterm;
			c->noswallow  = r->noswallow;
			c->scratchkey = r->scratchkey;
			c->allow_activation = r->allow_activation;
			newtags |= r->tags;
			i = 0;
			wl_list_for_each(m, &mons, link) {


@@ 3785,10 3788,20 @@ urgent(struct wl_listener *listener, void *data)
		return;

	c->isurgent = 1;
	printstatus();
	if (!client_surface(c)->mapped) {
		printstatus();
		return;
	}

	if (client_surface(c)->mapped)
	if (event->token->seat && event->token->surface && c->allow_activation) {
		selmon = c->mon;
		if (!VISIBLEON(c, c->mon))
			view(&((Arg){.ui = c->tags}));
		focusclient(c, 1);
	} else {
		client_set_border_color(c, urgentcolor);
		printstatus();
	}
}

void


@@ 4031,10 4044,22 @@ sethints(struct wl_listener *listener, void *data)
		return;

	c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
	printstatus();
	if (!surface || !surface->mapped) {
		printstatus();
		return;
	}

	if (c->isurgent && surface && surface->mapped)
		client_set_border_color(c, urgentcolor);
	if (c->isurgent) {
		if (c->allow_activation) {
			selmon = c->mon;
			if (!VISIBLEON(c, c->mon))
				view(&((Arg){.ui = c->tags}));
			focusclient(c, 1);
		} else {
			client_set_border_color(c, urgentcolor);
			printstatus();
		}
	}
}

void