commit b960a22ace4115017013098036ed6f79bbf1d172
parent a5a2d7c6c9bf4043fb55b77aa1a4515648b5f03c
Author: Mahdi Mirzade <[email protected]>
Date: Sun, 22 May 2022 19:33:59 +0430
Better implementation of hidetabs and keyrelease, other small changes
Diffstat:
M | config.h | | | 72 | ++++++++++++++++++++++++++++++++++++++++-------------------------------- |
M | tabbed.c | | | 46 | +++++++++++++++++++++++++++++----------------- |
2 files changed, 69 insertions(+), 49 deletions(-)
diff --git a/config.h b/config.h
@@ -1,6 +1,8 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
+#define HIDETABS 0
+
static const char* font = "monospace:size=9";
static const char* normbgcolor = "#222222";
static const char* normfgcolor = "#cccccc";
@@ -8,15 +10,15 @@ static const char* selbgcolor = "#555555";
static const char* selfgcolor = "#ffffff";
static const char* urgbgcolor = "#111111";
static const char* urgfgcolor = "#cc0000";
-static const char before[] = "<";
-static const char after[] = ">";
+static const char before[] = "";
+static const char after[] = "";
static const char titletrim[] = "...";
static const int tabwidth = 150;
static const Bool foreground = True;
static Bool urgentswitch = False;
-static const int clientNumber = 1;
-static const int barHeight = 0;
+static const int clientNumber = 0;
+static const int barHeight = 20;
/*
* Where to place a new tab when it is opened. When npisrelative is True,
@@ -38,42 +40,48 @@ static Bool npisrelative = True;
#define MODKEY ControlMask
static Key keys[] = {
- /* modifier key function argument */
- { MODKEY|Mod1Mask, XK_Return, focusonce, { 0 } },
- { MODKEY|Mod1Mask, XK_Return, spawn, { 0 } },
+ /* modifier key function argument */
+ { MODKEY|Mod1Mask, XK_Return, focusonce, { 0 } },
+ { MODKEY|Mod1Mask, XK_Return, spawn, { 0 } },
- { MODKEY|Mod1Mask, XK_l, rotate, { .i = +1 } },
- { MODKEY|Mod1Mask, XK_h, rotate, { .i = -1 } },
- { MODKEY|Mod1Mask, XK_j, movetab, { .i = -1 } },
- { MODKEY|Mod1Mask, XK_k, movetab, { .i = +1 } },
- { MODKEY, XK_Tab, rotate, { .i = 0 } },
+ { MODKEY|Mod1Mask, XK_l, rotate, { .i = +1 } },
+ { MODKEY|Mod1Mask, XK_h, rotate, { .i = -1 } },
+ { MODKEY|Mod1Mask, XK_j, movetab, { .i = -1 } },
+ { MODKEY|Mod1Mask, XK_k, movetab, { .i = +1 } },
+ { MODKEY, XK_Tab, rotate, { .i = 0 } },
- { MODKEY, XK_grave, spawn, SETPROP("_TABBED_SELECT_TAB") },
- { MODKEY, XK_1, move, { .i = 0 } },
- { MODKEY, XK_2, move, { .i = 1 } },
- { MODKEY, XK_3, move, { .i = 2 } },
- { MODKEY, XK_4, move, { .i = 3 } },
- { MODKEY, XK_5, move, { .i = 4 } },
- { MODKEY, XK_6, move, { .i = 5 } },
- { MODKEY, XK_7, move, { .i = 6 } },
- { MODKEY, XK_8, move, { .i = 7 } },
- { MODKEY, XK_9, move, { .i = 8 } },
- { MODKEY, XK_0, move, { .i = 9 } },
+ { MODKEY, XK_grave, spawn, SETPROP("_TABBED_SELECT_TAB") },
+ { MODKEY, XK_1, move, { .i = 0 } },
+ { MODKEY, XK_2, move, { .i = 1 } },
+ { MODKEY, XK_3, move, { .i = 2 } },
+ { MODKEY, XK_4, move, { .i = 3 } },
+ { MODKEY, XK_5, move, { .i = 4 } },
+ { MODKEY, XK_6, move, { .i = 5 } },
+ { MODKEY, XK_7, move, { .i = 6 } },
+ { MODKEY, XK_8, move, { .i = 7 } },
+ { MODKEY, XK_9, move, { .i = 8 } },
+ { MODKEY, XK_0, move, { .i = 9 } },
- //{ MODKEY, XK_d, killclient, { 0 } },
- { MODKEY, XK_q, killclient, { 0 } },
+ { MODKEY, XK_q, killclient, { 0 } },
- { MODKEY, XK_u, focusurgent, { 0 } },
- { MODKEY|Mod1Mask, XK_u, toggle, { .v = (void*) &urgentswitch } },
+ { MODKEY, XK_u, focusurgent, { 0 } },
+ { MODKEY|Mod1Mask, XK_u, toggle, { .v = (void*) &urgentswitch } },
- { 0, XK_F11, fullscreen, { 0 } },
+ { 0, XK_F11, fullscreen, { 0 } },
- { MODKEY, XK_Alt_L, showbar, { .i = 1 } },
+ #if HIDETABS
+ { MODKEY, XK_Alt_L, showbar, { .i = 1 } },
{ Mod1Mask, XK_Control_L, showbar, { .i = 1 } },
+ #endif
};
static Key keyreleases[] = {
- /* modifier key function argument */
- { MODKEY|Mod1Mask, XK_Alt_L, showbar, { .i = 0 } },
- { MODKEY|Mod1Mask, XK_Control_L, showbar, { .i = 0 } },
+ /* modifier key function argument */
+ #if HIDETABS
+ { MODKEY|Mod1Mask, XK_Alt_L, showbar, { .i = 0 } },
+ { MODKEY|Mod1Mask, XK_Control_L, showbar, { .i = 0 } },
+ #else
+ { MODKEY|Mod1Mask, XK_Control_L, NULL, { 0 } },
+ #endif
};
+
diff --git a/tabbed.c b/tabbed.c
@@ -185,7 +185,11 @@ static char winid[64];
static char **cmd;
static char *wmname = "tabbed";
static const char *geometry;
+#if HIDETABS
static Bool barvisibility = False;
+#else
+static Bool barvisibility = True;
+#endif
static Colormap cmap;
static Visual *visual = NULL;
@@ -349,7 +353,11 @@ drawbar(void)
char *name = NULL;
char tabtitle[256];
- nbh = barvisibility ? vbh : 0;
+ #if HIDETABS
+ nbh = barvisibility && nclients > 1 ? vbh : 0;
+ #else
+ nbh = nclients > 1 ? vbh : 0;
+ #endif
if (nbh != bh) {
bh = nbh;
for (c = 0; c < nclients; c++)
@@ -400,9 +408,12 @@ drawbar(void)
} else {
col = clients[c]->urgent ? dc.urg : dc.norm;
}
- snprintf(tabtitle, sizeof(tabtitle), "%d: %s",
- c + 1, clients[c]->name);
- drawtext(tabtitle, col);
+ if (clientNumber) {
+ snprintf(tabtitle, sizeof(tabtitle), "%d: %s",
+ c + 1, clients[c]->name);
+ drawtext(tabtitle, col);
+ } else
+ drawtext(clients[c]->name, col);
dc.x += dc.w;
clients[c]->tabx = dc.x;
}
@@ -426,7 +437,7 @@ drawtext(const char *text, XftColor col[ColLast])
olen = strlen(text);
h = dc.font.ascent + dc.font.descent;
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
- x = dc.x + (h / 2);
+ x = dc.x + (h / 2);
/* shorten text if necessary */
for (len = MIN(olen, sizeof(buf));
@@ -439,7 +450,7 @@ drawtext(const char *text, XftColor col[ColLast])
if (len < olen) {
for (i = len, j = strlen(titletrim); j && i;
buf[--i] = titletrim[--j])
- ;
+ ;
}
d = XftDrawCreate(dpy, dc.drawable, visual, cmap);
@@ -1098,13 +1109,13 @@ setup(void)
XRenderPictFormat *fmt;
int nvi;
int i;
-
+
XVisualInfo tpl = {
.screen = screen,
.depth = 32,
.class = TrueColor
};
-
+
vis = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &tpl, &nvi);
for(i = 0; i < nvi; i ++) {
fmt = XRenderFindVisualFormat(dpy, vis[i].visual);
@@ -1113,14 +1124,14 @@ setup(void)
break;
}
}
-
+
XFree(vis);
-
+
if (! visual) {
fprintf(stderr, "Couldn't find ARGB visual.\n");
exit(1);
}
-
+
cmap = XCreateColormap( dpy, root, visual, None);
dc.norm[ColBG] = getcolor(normbgcolor);
dc.norm[ColFG] = getcolor(normfgcolor);
@@ -1137,16 +1148,16 @@ setup(void)
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
attrs.background_pixmap = None ;
attrs.colormap = cmap;
-
+
win = XCreateWindow(dpy, root, wx, wy,
ww, wh, 0, 32, InputOutput,
visual, CWBackPixmap | CWBorderPixel | CWBitGravity
| CWEventMask | CWColormap, &attrs);
-
+
dc.drawable = XCreatePixmap(dpy, win, ww, wh,
32);
dc.gc = XCreateGC(dpy, dc.drawable, 0, 0);
-
+
XMapRaised(dpy, win);
XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask |
ButtonPressMask | ExposureMask | KeyPressMask |
@@ -1405,13 +1416,13 @@ xrdb_load(void)
xrdb = XrmGetStringDatabase(xrm);
XRESOURCE_LOAD_STRING("color8", normbgcolor);
- XRESOURCE_LOAD_STRING("color7", normfgcolor);
+ XRESOURCE_LOAD_STRING("color15", normfgcolor);
XRESOURCE_LOAD_STRING("color0", selbgcolor);
- XRESOURCE_LOAD_STRING("color15", selfgcolor);
+ XRESOURCE_LOAD_STRING("color7", selfgcolor);
XRESOURCE_LOAD_STRING("color8", urgbgcolor);
- XRESOURCE_LOAD_STRING("color6", urgfgcolor);
+ XRESOURCE_LOAD_STRING("color5", urgfgcolor);
XRESOURCE_LOAD_STRING("font", font);
}
@@ -1540,3 +1551,4 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+