commit a717af5b10c89986ae12bed1422a9778f2c103b6
parent 0e3bcfdfed1868cc8949859439e2c2b31e944219
Author: hhvn <dev@hhvn.uk>
Date: Sun, 9 Jan 2022 14:50:17 +0000
config.h tabbed.c: option for only using SchemeSel if focused by window manager
Diffstat:
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/config.h b/config.h
@@ -15,6 +15,8 @@ static const int tabwidth = 200;
static const Bool foreground = True;
static Bool urgentswitch = False;
static Bool focusnew = True; /* focus on a newly embedded window */
+static const Bool mainselectcol = True; /* only colour windows as selected
+ if main window selected */
/*
* Where to place a new tab when it is opened. When npisrelative is True,
diff --git a/tabbed.c b/tabbed.c
@@ -102,6 +102,7 @@ static void *erealloc(void *o, size_t size);
static void expose(const XEvent *e);
static void focus(int c);
static void focusin(const XEvent *e);
+static void focusout(const XEvent *e);
static void focusonce(const Arg *arg);
static void focusurgent(const Arg *arg);
static void fullscreen(const Arg *arg);
@@ -149,6 +150,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
[DestroyNotify] = destroynotify,
[Expose] = expose,
[FocusIn] = focusin,
+ [FocusOut] = focusout,
[KeyPress] = keypress,
[MapRequest] = maprequest,
[PropertyNotify] = propertynotify,
@@ -331,6 +333,8 @@ void
drawbar(void)
{
XftColor *col;
+ Window focused;
+ int null;
int c, cc, fc, width;
char *name = NULL;
char tabtitle[256];
@@ -367,9 +371,10 @@ drawbar(void)
}
cc = MIN(cc, nclients);
+ XGetInputFocus(dpy, &focused, &null);
for (c = fc; c < fc + cc; c++) {
dc.w = width / cc;
- if (c == sel) {
+ if (c == sel && (!mainselectcol || clients[c]->win == focused)) {
col = dc.sel;
dc.w += width % cc;
} else {
@@ -511,6 +516,11 @@ focusin(const XEvent *e)
}
void
+focusout(const XEvent *e) {
+ drawbar();
+}
+
+void
focusonce(const Arg *arg)
{
nextfocus = True;