Made left and right padding to status text configurable in dwm patch

This commit is contained in:
Ashish Kumar Yadav 2021-01-25 16:50:09 +05:30
parent 8c7c4d777b
commit 9bdfdb6c99
2 changed files with 53 additions and 49 deletions

View file

@ -1,6 +1,6 @@
diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
--- dwm-6.2-ori/config.def.h 2019-02-02 18:25:28.000000000 +0530
+++ dwm-6.2/config.def.h 2020-12-27 19:52:54.790231420 +0530
+++ dwm-6.2/config.def.h 2021-01-25 16:40:17.983232710 +0530
@@ -12,10 +12,26 @@
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
@ -43,7 +43,7 @@ diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
--- dwm-6.2-ori/dwm.c 2019-02-02 18:25:28.000000000 +0530
+++ dwm-6.2/dwm.c 2021-01-10 05:23:06.472038418 +0530
+++ dwm-6.2/dwm.c 2021-01-25 16:40:58.116619683 +0530
@@ -40,6 +40,7 @@
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
@ -52,7 +52,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
#include "drw.h"
#include "util.h"
@@ -56,10 +57,14 @@
@@ -56,10 +57,16 @@
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
@ -61,6 +61,8 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+#define STATUSLENGTH 256
+#define DWMBLOCKSLOCKFILE "/tmp/dwmblocks.pid"
+#define DELIMITERENDCHAR 10
+#define LSPAD (lrpad / 2) /* padding on left side of status text */
+#define RSPAD (lrpad / 2) /* padding on right side of status text */
/* enums */
-enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@ -69,7 +71,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -124,6 +129,7 @@
@@ -124,6 +131,7 @@
unsigned int tagset[2];
int showbar;
int topbar;
@ -77,7 +79,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
Client *clients;
Client *sel;
Client *stack;
@@ -205,6 +211,7 @@
@@ -205,6 +213,7 @@
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
@ -85,7 +87,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
@@ -219,6 +226,7 @@
@@ -219,6 +228,7 @@
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
@ -93,7 +95,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static int updategeom(void);
static void updatenumlockmask(void);
static void updatesizehints(Client *c);
@@ -236,12 +244,15 @@
@@ -236,12 +246,15 @@
/* variables */
static const char broken[] = "broken";
@ -111,7 +113,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
@@ -416,13 +427,13 @@
@@ -416,13 +429,13 @@
void
buttonpress(XEvent *e)
{
@ -127,7 +129,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
/* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon) {
unfocus(selmon->sel, 1);
@@ -430,25 +441,29 @@
@@ -430,25 +443,29 @@
focus(NULL);
}
if (ev->window == selmon->barwin) {
@ -155,7 +157,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ click = ClkLtSymbol;
+ else if (ev->x < selmon->ww - wstext)
+ click = ClkWinTitle;
+ else if ((x = selmon->ww - lrpad / 2 - ev->x) > 0 && (x -= wstext - lrpad) <= 0) {
+ else if ((x = selmon->ww - RSPAD - ev->x) > 0 && (x -= wstext - LSPAD - RSPAD) <= 0) {
+ updatedwmblockssig(x);
+ click = ClkStatusText;
+ } else
@ -171,7 +173,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@@ -695,7 +710,7 @@
@@ -695,7 +712,7 @@
void
drawbar(Monitor *m)
{
@ -180,7 +182,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
@@ -703,9 +718,32 @@
@@ -703,9 +720,32 @@
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
@ -193,7 +195,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ x = m->ww - wstext;
+ drw_rect(drw, x, 0, lrpad / 2, bh, 1, 1); x += lrpad / 2; /* to keep left padding clean */
+ drw_rect(drw, x, 0, LSPAD, bh, 1, 1); x += LSPAD; /* to keep left padding clean */
+ for (;;) {
+ if ((unsigned char)*stc >= ' ') {
+ stc++;
@ -216,7 +218,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
}
for (c = m->clients; c; c = c->next) {
@@ -724,11 +762,17 @@
@@ -724,11 +764,17 @@
urg & 1 << i);
x += w;
}
@ -236,7 +238,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -1119,17 +1163,24 @@
@@ -1119,17 +1165,24 @@
motionnotify(XEvent *e)
{
static Monitor *mon = NULL;
@ -259,8 +261,8 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ focus(NULL);
+ }
+ mon = m;
+ } else if (ev->window == selmon->barwin && (x = selmon->ww - lrpad / 2 - ev->x) > 0
+ && (x -= wstext - lrpad) <= 0)
+ } else if (ev->window == selmon->barwin && (x = selmon->ww - RSPAD - ev->x) > 0
+ && (x -= wstext - LSPAD - RSPAD) <= 0)
+ updatedwmblockssig(x);
+ else if (selmon->statushandcursor) {
+ selmon->statushandcursor = 0;
@ -269,7 +271,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
}
void
@@ -1564,6 +1615,7 @@
@@ -1564,6 +1617,7 @@
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
@ -277,7 +279,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
@@ -1637,6 +1689,40 @@
@@ -1637,6 +1691,40 @@
}
void
@ -318,7 +320,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
spawn(const Arg *arg)
{
if (arg->v == dmenucmd)
@@ -1805,7 +1891,7 @@
@@ -1805,7 +1893,7 @@
XSetWindowAttributes wa = {
.override_redirect = True,
.background_pixmap = ParentRelative,
@ -327,7 +329,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
};
XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
@@ -1847,6 +1933,41 @@
@@ -1847,6 +1935,41 @@
(unsigned char *) &(c->win), 1);
}
@ -369,7 +371,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
int
updategeom(void)
{
@@ -1987,9 +2108,27 @@
@@ -1987,9 +2110,27 @@
void
updatestatus(void)
{
@ -390,11 +392,11 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ else
+ *(sts++) = *rst;
+ *stp = *stc = *sts = '\0';
+ wstext = TEXTW(stextp);
+ wstext = TTEXTW(stextp) + LSPAD + RSPAD;
+ } else {
+ strcpy(stextc, "dwm-"VERSION);
+ strcpy(stexts, stextc);
+ wstext = TEXTW(stextc);
+ wstext = TTEXTW(stextc) + LSPAD + RSPAD;
+ }
+ drawbar(selmon);
}

View file

@ -43,7 +43,7 @@ diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
--- dwm-6.2-ori/dwm.c 2020-08-17 23:51:19.057243495 +0530
+++ dwm-6.2/dwm.c 2021-01-10 05:24:06.575894250 +0530
+++ dwm-6.2/dwm.c 2021-01-25 16:46:54.472584837 +0530
@@ -40,6 +40,7 @@
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
@ -52,7 +52,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
#include "drw.h"
#include "util.h"
@@ -56,6 +57,11 @@
@@ -56,6 +57,13 @@
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
@ -61,10 +61,12 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+#define STATUSLENGTH 256
+#define DWMBLOCKSLOCKFILE "/tmp/dwmblocks.pid"
+#define DELIMITERENDCHAR 10
+#define LSPAD (lrpad / 2) /* padding on left side of status text */
+#define RSPAD (lrpad / 2) /* padding on right side of status text */
#define SYSTEM_TRAY_REQUEST_DOCK 0
@@ -74,8 +80,7 @@
@@ -74,8 +82,7 @@
#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
/* enums */
@ -74,7 +76,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
@@ -142,6 +147,7 @@
@@ -142,6 +149,7 @@
unsigned int tagset[2];
int showbar;
int topbar;
@ -82,7 +84,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
Client *clients;
Client *sel;
Client *stack;
@@ -234,6 +240,7 @@
@@ -234,6 +242,7 @@
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
@ -90,7 +92,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static void spawn(const Arg *arg);
static Monitor *systraytomon(Monitor *m);
static void tag(const Arg *arg);
@@ -249,6 +256,7 @@
@@ -249,6 +258,7 @@
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
@ -98,7 +100,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static int updategeom(void);
static void updatenumlockmask(void);
static void updatesizehints(Client *c);
@@ -269,14 +277,17 @@
@@ -269,14 +279,17 @@
static void zoom(const Arg *arg);
/* variables */
@ -119,7 +121,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
@@ -303,6 +314,7 @@
@@ -303,6 +316,7 @@
static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
@ -127,7 +129,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -452,13 +464,13 @@
@@ -452,13 +466,13 @@
void
buttonpress(XEvent *e)
{
@ -143,7 +145,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
/* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon) {
unfocus(selmon->sel, 1);
@@ -466,25 +478,29 @@
@@ -466,25 +480,29 @@
focus(NULL);
}
if (ev->window == selmon->barwin) {
@ -171,7 +173,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ click = ClkLtSymbol;
+ else if (ev->x < wsbar - wstext)
+ click = ClkWinTitle;
+ else if ((x = wsbar - lrpad / 2 - ev->x) > 0 && (x -= wstext - lrpad) <= 0) {
+ else if ((x = wsbar - RSPAD - ev->x) > 0 && (x -= wstext - LSPAD - RSPAD) <= 0) {
+ updatedwmblockssig(x);
+ click = ClkStatusText;
+ } else
@ -187,7 +189,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@@ -789,23 +805,47 @@
@@ -789,23 +807,47 @@
void
drawbar(Monitor *m)
{
@ -216,7 +218,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ wsbar = wbar;
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ x = wbar - wstext;
+ drw_rect(drw, x, 0, lrpad / 2, bh, 1, 1); x += lrpad / 2; /* to keep left padding clean */
+ drw_rect(drw, x, 0, LSPAD, bh, 1, 1); x += LSPAD; /* to keep left padding clean */
+ for (;;) {
+ if ((unsigned char)*stc >= ' ') {
+ stc++;
@ -242,7 +244,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
for (c = m->clients; c; c = c->next) {
occ |= c->tags;
if (c->isurgent)
@@ -822,11 +862,17 @@
@@ -822,11 +864,17 @@
urg & 1 << i);
x += w;
}
@ -262,7 +264,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -837,7 +883,9 @@
@@ -837,7 +885,9 @@
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}
@ -273,7 +275,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
}
void
@@ -1243,17 +1291,24 @@
@@ -1243,17 +1293,24 @@
motionnotify(XEvent *e)
{
static Monitor *mon = NULL;
@ -296,8 +298,8 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ focus(NULL);
+ }
+ mon = m;
+ } else if (ev->window == selmon->barwin && (x = wsbar - lrpad / 2 - ev->x) > 0
+ && (x -= wstext - lrpad) <= 0)
+ } else if (ev->window == selmon->barwin && (x = wsbar - RSPAD - ev->x) > 0
+ && (x -= wstext - LSPAD - RSPAD) <= 0)
+ updatedwmblockssig(x);
+ else if (selmon->statushandcursor) {
+ selmon->statushandcursor = 0;
@ -306,7 +308,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
}
void
@@ -1750,6 +1805,7 @@
@@ -1750,6 +1807,7 @@
xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
@ -314,7 +316,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
@@ -1825,6 +1881,40 @@
@@ -1825,6 +1883,40 @@
}
void
@ -355,7 +357,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
spawn(const Arg *arg)
{
if (arg->v == dmenucmd)
@@ -2011,7 +2101,7 @@
@@ -2011,7 +2103,7 @@
XSetWindowAttributes wa = {
.override_redirect = True,
.background_pixmap = ParentRelative,
@ -364,7 +366,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
};
XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
@@ -2058,6 +2148,41 @@
@@ -2058,6 +2150,41 @@
(unsigned char *) &(c->win), 1);
}
@ -406,7 +408,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
int
updategeom(void)
{
@@ -2198,10 +2323,27 @@
@@ -2198,10 +2325,27 @@
void
updatestatus(void)
{
@ -428,11 +430,11 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ else
+ *(sts++) = *rst;
+ *stp = *stc = *sts = '\0';
+ wstext = TEXTW(stextp);
+ wstext = TEXTW(stextp) + LSPAD + RSPAD;
+ } else {
+ strcpy(stextc, "dwm-"VERSION);
+ strcpy(stexts, stextc);
+ wstext = TEXTW(stextc);
+ wstext = TEXTW(stextc) + LSPAD + RSPAD;
+ }
+ drawbar(selmon);
}