Improved dwm patches

This commit is contained in:
Ashish Kumar Yadav 2020-09-23 20:37:49 +05:30
parent ccf5da003a
commit 1ed75f8f15
2 changed files with 80 additions and 122 deletions

View file

@ -51,7 +51,7 @@ diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c 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-ori/dwm.c 2019-02-02 18:25:28.000000000 +0530
+++ dwm-6.2/dwm.c 2020-08-21 23:44:18.270571490 +0530 +++ dwm-6.2/dwm.c 2020-09-23 20:13:50.516133820 +0530
@@ -40,6 +40,8 @@ @@ -40,6 +40,8 @@
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */ #endif /* XINERAMA */
@ -87,19 +87,15 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
@@ -216,9 +224,11 @@ @@ -219,6 +227,7 @@
static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
+static void updatebarcursor(int cursorpos);
static void updatebarpos(Monitor *m); static void updatebarpos(Monitor *m);
static void updatebars(void); static void updatebars(void);
static void updateclientlist(void); static void updateclientlist(void);
+static void updatedwmblockssig(int x, int e); +static void updatedwmblockssig(int x);
static int updategeom(void); static int updategeom(void);
static void updatenumlockmask(void); static void updatenumlockmask(void);
static void updatesizehints(Client *c); static void updatesizehints(Client *c);
@@ -236,7 +246,10 @@ @@ -236,7 +245,11 @@
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
@ -108,6 +104,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+static char stexts[256]; +static char stexts[256];
+static int wstext; +static int wstext;
+static unsigned int dwmblockssig; +static unsigned int dwmblockssig;
+static int statushandcursor;
static int screen; static int screen;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */ static int bh, blw = 0; /* bar geometry */
@ -121,10 +118,10 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
- click = ClkWinTitle; - click = ClkWinTitle;
+ else if (ev->x < selmon->ww - wstext) + else if (ev->x < selmon->ww - wstext)
+ click = ClkWinTitle; + click = ClkWinTitle;
+// else if (ev->x < selmon->ww - lrpad / 2 && ev->x >= (x = selmon->ww - wstext + lrpad / 2)) { + else if (ev->x < selmon->ww - lrpad / 2
+ else if (ev->x < selmon->ww - lrpad / 2 && ev->x >= selmon->ww - wstext + lrpad / 2) { + && (x = selmon->ww - wstext + lrpad / 2 - ev->x) <= 0) {
+ updatedwmblockssig(x);
+ click = ClkStatusText; + click = ClkStatusText;
+// updatedwmblockssig(x, ev->x);
+ } else + } else
+ return; + return;
} else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
@ -182,20 +179,29 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
if (m->sel) { if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -1122,8 +1160,11 @@ @@ -1122,8 +1160,20 @@
Monitor *m; Monitor *m;
XMotionEvent *ev = &e->xmotion; XMotionEvent *ev = &e->xmotion;
- if (ev->window != root) - if (ev->window != root)
+ if (ev->window != root) { + if (ev->window != root) {
+ if (ev->window == selmon->barwin) + if (ev->window == selmon->barwin) {
+ updatebarcursor(ev->x); + int x;
+
+ if (ev->x < selmon->ww - lrpad / 2
+ && (x = selmon->ww - wstext + lrpad / 2 - ev->x) <= 0)
+ updatedwmblockssig(x);
+ else if (statushandcursor) {
+ statushandcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ }
return; return;
+ } + }
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
unfocus(selmon->sel, 1); unfocus(selmon->sel, 1);
selmon = m; selmon = m;
@@ -1564,6 +1605,7 @@ @@ -1564,6 +1614,7 @@
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
/* init cursors */ /* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
@ -203,7 +209,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur); cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */ /* init appearance */
@@ -1637,6 +1679,28 @@ @@ -1637,6 +1688,28 @@
} }
void void
@ -232,7 +238,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
spawn(const Arg *arg) spawn(const Arg *arg)
{ {
if (arg->v == dmenucmd) if (arg->v == dmenucmd)
@@ -1805,7 +1869,7 @@ @@ -1805,7 +1878,7 @@
XSetWindowAttributes wa = { XSetWindowAttributes wa = {
.override_redirect = True, .override_redirect = True,
.background_pixmap = ParentRelative, .background_pixmap = ParentRelative,
@ -241,46 +247,12 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
}; };
XClassHint ch = {"dwm", "dwm"}; XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
@@ -1821,6 +1885,33 @@ @@ -1847,6 +1920,42 @@
}
void
+updatebarcursor(int cursorpos)
+{
+ static int currentcursor = 0;
+ int x;
+
+ if (cursorpos < selmon->ww - lrpad / 2 && cursorpos >= (x = selmon->ww - wstext + lrpad / 2)) {
+ updatedwmblockssig(x, cursorpos);
+ if (currentcursor) {
+ if (!dwmblockssig) {
+ currentcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ } else {
+ if (dwmblockssig) {
+ currentcursor = 1;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
+ }
+ }
+ } else {
+ if (currentcursor) {
+ currentcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ }
+}
+
+void
updatebarpos(Monitor *m)
{
m->wy = m->my;
@@ -1847,6 +1938,34 @@
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
} }
+void +void
+updatedwmblockssig(int x, int e) +updatedwmblockssig(int x)
+{ +{
+ char *ts = stexts; + char *ts = stexts;
+ char *tp = stexts; + char *tp = stexts;
@ -295,22 +267,30 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ *ts = '\0'; + *ts = '\0';
+ x += TTEXTW(tp); + x += TTEXTW(tp);
+ *ts = ctmp; + *ts = ctmp;
+ if (x >= e) { + if (x >= 0) {
+ if (ctmp != 10) + if (ctmp == 10)
+ dwmblockssig = ctmp; + goto cursorondelimiter;
+ else + if (!statushandcursor) {
+ dwmblockssig = 0; + statushandcursor = 1;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
+ }
+ dwmblockssig = ctmp;
+ return; + return;
+ } + }
+ tp = ++ts; + tp = ++ts;
+ } + }
+cursorondelimiter:
+ if (statushandcursor) {
+ statushandcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ dwmblockssig = 0; + dwmblockssig = 0;
+} +}
+ +
int int
updategeom(void) updategeom(void)
{ {
@@ -1987,9 +2106,27 @@ @@ -1987,9 +2096,27 @@
void void
updatestatus(void) updatestatus(void)
{ {

View file

@ -51,7 +51,7 @@ diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c 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-ori/dwm.c 2020-08-17 23:51:19.057243495 +0530
+++ dwm-6.2/dwm.c 2020-08-21 23:45:04.927946432 +0530 +++ dwm-6.2/dwm.c 2020-09-23 20:34:40.620032555 +0530
@@ -40,6 +40,8 @@ @@ -40,6 +40,8 @@
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */ #endif /* XINERAMA */
@ -100,19 +100,15 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static Monitor *systraytomon(Monitor *m); static Monitor *systraytomon(Monitor *m);
static void tag(const Arg *arg); static void tag(const Arg *arg);
@@ -246,9 +253,11 @@ @@ -249,6 +256,7 @@
static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
+static void updatebarcursor(int cursorpos);
static void updatebarpos(Monitor *m); static void updatebarpos(Monitor *m);
static void updatebars(void); static void updatebars(void);
static void updateclientlist(void); static void updateclientlist(void);
+static void updatedwmblockssig(int x, int e); +static void updatedwmblockssig(int x);
static int updategeom(void); static int updategeom(void);
static void updatenumlockmask(void); static void updatenumlockmask(void);
static void updatesizehints(Client *c); static void updatesizehints(Client *c);
@@ -271,10 +280,13 @@ @@ -271,10 +279,14 @@
/* variables */ /* variables */
static Systray *systray = NULL; static Systray *systray = NULL;
static const char broken[] = "broken"; static const char broken[] = "broken";
@ -120,6 +116,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+static char stextc[256]; +static char stextc[256];
+static char stexts[256]; +static char stexts[256];
+static int wstext; +static int wstext;
+static int statushandcursor;
+static unsigned int dwmblockssig; +static unsigned int dwmblockssig;
static int screen; static int screen;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
@ -128,7 +125,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
static int lrpad; /* sum of left and right padding for text */ static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *); static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0; static unsigned int numlockmask = 0;
@@ -475,10 +487,14 @@ @@ -475,10 +487,13 @@
arg.ui = 1 << i; arg.ui = 1 << i;
} else if (ev->x < x + blw) } else if (ev->x < x + blw)
click = ClkLtSymbol; click = ClkLtSymbol;
@ -138,16 +135,15 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
- click = ClkWinTitle; - click = ClkWinTitle;
+ else if (ev->x < selmon->ww - wstext) + else if (ev->x < selmon->ww - wstext)
+ click = ClkWinTitle; + click = ClkWinTitle;
+// else if (ev->x < (x = selmon->ww - stw - lrpad / 2) && ev->x >= (x -= wstext - lrpad)) { + else if ((x = selmon->ww - stw - lrpad / 2 - ev->x) > 0 && (x -= wstext - lrpad) <= 0) {
+ else if (ev->x < (x = selmon->ww - stw - lrpad / 2) && ev->x >= x - wstext + lrpad) { + updatedwmblockssig(x);
+ click = ClkStatusText; + click = ClkStatusText;
+// updatedwmblockssig(x, ev->x);
+ } else + } else
+ return; + return;
} else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
focus(c); focus(c);
restack(selmon); restack(selmon);
@@ -789,23 +805,45 @@ @@ -789,23 +804,45 @@
void void
drawbar(Monitor *m) drawbar(Monitor *m)
{ {
@ -201,7 +197,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
occ |= c->tags; occ |= c->tags;
if (c->isurgent) if (c->isurgent)
@@ -826,7 +864,7 @@ @@ -826,7 +863,7 @@
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
@ -210,7 +206,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
if (m->sel) { if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -837,7 +875,7 @@ @@ -837,7 +874,7 @@
drw_rect(drw, x, 0, w, bh, 1, 1); drw_rect(drw, x, 0, w, bh, 1, 1);
} }
} }
@ -219,20 +215,28 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
} }
void void
@@ -1246,8 +1284,11 @@ @@ -1246,8 +1283,19 @@
Monitor *m; Monitor *m;
XMotionEvent *ev = &e->xmotion; XMotionEvent *ev = &e->xmotion;
- if (ev->window != root) - if (ev->window != root)
+ if (ev->window != root) { + if (ev->window != root) {
+ if (ev->window == selmon->barwin) + if (ev->window == selmon->barwin) {
+ updatebarcursor(ev->x); + int x;
+
+ if ((x = selmon->ww - stw - lrpad / 2 - ev->x) > 0 && (x -= wstext - lrpad) <= 0)
+ updatedwmblockssig(x);
+ else if (statushandcursor) {
+ statushandcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ }
return; return;
+ } + }
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
unfocus(selmon->sel, 1); unfocus(selmon->sel, 1);
selmon = m; selmon = m;
@@ -1750,6 +1791,7 @@ @@ -1750,6 +1798,7 @@
xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False); xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
/* init cursors */ /* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
@ -240,7 +244,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur); cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */ /* init appearance */
@@ -1825,6 +1867,28 @@ @@ -1825,6 +1874,28 @@
} }
void void
@ -269,7 +273,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
spawn(const Arg *arg) spawn(const Arg *arg)
{ {
if (arg->v == dmenucmd) if (arg->v == dmenucmd)
@@ -2011,7 +2075,7 @@ @@ -2011,7 +2082,7 @@
XSetWindowAttributes wa = { XSetWindowAttributes wa = {
.override_redirect = True, .override_redirect = True,
.background_pixmap = ParentRelative, .background_pixmap = ParentRelative,
@ -278,46 +282,12 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
}; };
XClassHint ch = {"dwm", "dwm"}; XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
@@ -2032,6 +2096,33 @@ @@ -2058,6 +2129,42 @@
}
void
+updatebarcursor(int cursorpos)
+{
+ static int currentcursor = 0;
+ int x;
+
+ if (cursorpos < (x = selmon->ww - stw - lrpad / 2) && cursorpos >= (x -= wstext - lrpad)) {
+ updatedwmblockssig(x, cursorpos);
+ if (currentcursor) {
+ if (!dwmblockssig) {
+ currentcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ } else {
+ if (dwmblockssig) {
+ currentcursor = 1;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
+ }
+ }
+ } else {
+ if (currentcursor) {
+ currentcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ }
+}
+
+void
updatebarpos(Monitor *m)
{
m->wy = m->my;
@@ -2058,6 +2149,34 @@
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
} }
+void +void
+updatedwmblockssig(int x, int e) +updatedwmblockssig(int x)
+{ +{
+ char *ts = stexts; + char *ts = stexts;
+ char *tp = stexts; + char *tp = stexts;
@ -332,22 +302,30 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
+ *ts = '\0'; + *ts = '\0';
+ x += TTEXTW(tp); + x += TTEXTW(tp);
+ *ts = ctmp; + *ts = ctmp;
+ if (x >= e) { + if (x >= 0) {
+ if (ctmp != 10) + if (ctmp == 10)
+ dwmblockssig = ctmp; + goto cursorondelimiter;
+ else + if (!statushandcursor) {
+ dwmblockssig = 0; + statushandcursor = 1;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
+ }
+ dwmblockssig = ctmp;
+ return; + return;
+ } + }
+ tp = ++ts; + tp = ++ts;
+ } + }
+cursorondelimiter:
+ if (statushandcursor) {
+ statushandcursor = 0;
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
+ }
+ dwmblockssig = 0; + dwmblockssig = 0;
+} +}
+ +
int int
updategeom(void) updategeom(void)
{ {
@@ -2198,10 +2317,27 @@ @@ -2198,10 +2305,27 @@
void void
updatestatus(void) updatestatus(void)
{ {