From 36b574eff68239db35df97035118b614cc79d307 Mon Sep 17 00:00:00 2001 From: SalahDin Rezk Date: Thu, 4 Apr 2024 16:51:13 +0200 Subject: [PATCH 1/2] Add bar padding smart patch (#419) --- dwm.c | 23 +++++++++++++++++++++++ patches.def.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/dwm.c b/dwm.c index 543b721..927f253 100644 --- a/dwm.c +++ b/dwm.c @@ -1108,6 +1108,11 @@ arrange(Monitor *m) void arrangemon(Monitor *m) { + #if BAR_PADDING_SMART_PATCH + updatebarpos(selmon); + for (Bar *bar = selmon->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); + #endif // BAR_PADDING_SMART_PATCH #if TAB_PATCH updatebarpos(m); XMoveResizeWindow(dpy, m->tabwin, m->wx, m->ty, m->ww, th); @@ -4664,12 +4669,30 @@ updatebarpos(Monitor *m) if (enablegaps) #endif // PERTAG_VANITYGAPS_PATCH { + #if BAR_PADDING_SMART_PATCH + unsigned int n; Client *c; + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n > 1) { + y_pad = gappoh; + x_pad = gappov; + } + #else y_pad = gappoh; x_pad = gappov; + #endif // BAR_PADDING_SMART_PATCH } #elif BAR_PADDING_PATCH + #if BAR_PADDING_SMART_PATCH + unsigned int n; Client *c; + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n > 1) { + y_pad = vertpad; + x_pad = sidepad; + } + #else y_pad = vertpad; x_pad = sidepad; + #endif // BAR_PADDING_SMART_PATCH #endif // BAR_PADDING_PATCH | BAR_PADDING_VANITYGAPS_PATCH #if INSETS_PATCH diff --git a/patches.def.h b/patches.def.h index 968eb75..1af92cf 100644 --- a/patches.def.h +++ b/patches.def.h @@ -369,6 +369,12 @@ */ #define BAR_PADDING_VANITYGAPS_PATCH 0 +/* Smart bar padding patch that automatically adjusts the padding when there is + * only one client on the monitor. Works well with vanitygaps and barpadding + * patches. + */ +#define BAR_PADDING_SMART_PATCH 0 + /* This patch adds simple markup for status messages using pango markup. * This depends on the pango library v1.44 or greater. * You need to uncomment the corresponding lines in config.mk to use the pango libraries From a18f3ef370110c85d9001aced4b0cb1c96a075bf Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 16 Apr 2024 15:51:55 +0200 Subject: [PATCH 2/2] noborder: refactoring implementation and adding same logic to configure function --- dwm.c | 86 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 25 deletions(-) diff --git a/dwm.c b/dwm.c index 927f253..f4e52f0 100644 --- a/dwm.c +++ b/dwm.c @@ -688,6 +688,9 @@ static void maprequest(XEvent *e); static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); +#if NOBORDER_PATCH +static int noborder(Client *c); +#endif // NOBORDER_PATCH #if !ZOOMSWAP_PATCH || TAGINTOSTACK_ALLMASTER_PATCH || TAGINTOSTACK_ONEMASTER_PATCH static void pop(Client *c); #endif // !ZOOMSWAP_PATCH / TAGINTOSTACK_ALLMASTER_PATCH / TAGINTOSTACK_ONEMASTER_PATCH @@ -1466,6 +1469,15 @@ configure(Client *c) ce.width = c->w; ce.height = c->h; ce.border_width = c->bw; + + #if NOBORDER_PATCH + if (noborder(c)) { + ce.width += c->bw * 2; + ce.height += c->bw * 2; + ce.border_width = 0; + } + #endif // NOBORDER_PATCH + ce.above = None; ce.override_redirect = False; XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); @@ -2862,6 +2874,52 @@ nexttiled(Client *c) return c; } +#if NOBORDER_PATCH +int +noborder(Client *c) +{ + int monocle_layout = 0; + + #if MONOCLE_LAYOUT + if (&monocle == c->mon->lt[c->mon->sellt]->arrange) + monocle_layout = 1; + #endif // MONOCLE_LAYOUT + + #if DECK_LAYOUT + if (&deck == c->mon->lt[c->mon->sellt]->arrange && c->mon->nmaster == 0) + monocle_layout = 1; + #endif // DECK_LAYOUT + + #if FLEXTILE_DELUXE_LAYOUT + if (&flextile == c->mon->lt[c->mon->sellt]->arrange && ( + (c->mon->ltaxis[LAYOUT] == NO_SPLIT && c->mon->ltaxis[MASTER] == MONOCLE) || + (c->mon->ltaxis[STACK] == MONOCLE && c->mon->nmaster == 0) + )) { + monocle_layout = 1; + } + #endif //FLEXTILE_DELUXE_LAYOUT + + if (!monocle_layout && (nexttiled(c->mon->clients) != c || nexttiled(c->next))) + return 0; + + if (c->isfloating) + return 0; + + if (!c->mon->lt[c->mon->sellt]->arrange) + return 0; + + #if FAKEFULLSCREEN_CLIENT_PATCH && !FAKEFULLSCREEN_PATCH + if (c->fakefullscreen != 1 && c->isfullscreen) + return 0; + #elif !FAKEFULLSCREEN_PATCH + if (c->isfullscreen) + return 0; + #endif // FAKEFULLSCREEN_CLIENT_PATCH + + return 1; +} +#endif // NOBORDER_PATCH + #if !ZOOMSWAP_PATCH || TAGINTOSTACK_ALLMASTER_PATCH || TAGINTOSTACK_ONEMASTER_PATCH void pop(Client *c) @@ -3016,31 +3074,9 @@ resizeclient(Client *c, int x, int y, int w, int h) drawroundedcorners(c); #endif // ROUNDED_CORNERS_PATCH #if NOBORDER_PATCH - if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) - #if MONOCLE_LAYOUT - || &monocle == c->mon->lt[c->mon->sellt]->arrange - #endif // MONOCLE_LAYOUT - #if DECK_LAYOUT - || (&deck == c->mon->lt[c->mon->sellt]->arrange && - c->mon->nmaster == 0) - #endif // DECK_LAYOUT - #if FLEXTILE_DELUXE_LAYOUT - || (&flextile == c->mon->lt[c->mon->sellt]->arrange && ( - (c->mon->ltaxis[LAYOUT] == NO_SPLIT && - c->mon->ltaxis[MASTER] == MONOCLE) || - (c->mon->ltaxis[STACK] == MONOCLE && - c->mon->nmaster == 0))) - #endif //FLEXTILE_DELUXE_LAYOUT - ) - #if FAKEFULLSCREEN_CLIENT_PATCH && !FAKEFULLSCREEN_PATCH - && (c->fakefullscreen == 1 || !c->isfullscreen) - #else - && !c->isfullscreen - #endif // FAKEFULLSCREEN_CLIENT_PATCH - && !c->isfloating - && c->mon->lt[c->mon->sellt]->arrange) { - c->w = wc.width += c->bw * 2; - c->h = wc.height += c->bw * 2; + if (noborder(c)) { + wc.width += c->bw * 2; + wc.height += c->bw * 2; wc.border_width = 0; } #endif // NOBORDER_PATCH