sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-centretitle-20200907-61bb8b2.diff (1204B)


      1 From fe22e3d1434be1819fe0c0200d4a20967b02f3f6 Mon Sep 17 00:00:00 2001
      2 From: Felix Chen <sryvk.pura@protonmail.com>
      3 Date: Mon, 7 Sep 2020 11:45:01 +0800
      4 Subject: [PATCH] Place title in the middle of barwin
      5 
      6 ---
      7  dwm.c | 7 +++++--
      8  1 file changed, 5 insertions(+), 2 deletions(-)
      9 
     10 diff --git a/dwm.c b/dwm.c
     11 index 664c527..23e94f5 100644
     12 --- a/dwm.c
     13 +++ b/dwm.c
     14 @@ -697,6 +697,7 @@ void
     15  drawbar(Monitor *m)
     16  {
     17  	int x, w, tw = 0;
     18 +	int tlpad;
     19  	int boxs = drw->fonts->h / 9;
     20  	int boxw = drw->fonts->h / 6 + 2;
     21  	unsigned int i, occ = 0, urg = 0;
     22 @@ -732,9 +733,11 @@ drawbar(Monitor *m)
     23  	if ((w = m->ww - tw - x) > bh) {
     24  		if (m->sel) {
     25  			drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
     26 -			drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
     27 +			tlpad = MAX((m->ww - ((int)TEXTW(m->sel->name) - lrpad)) / 2 - x, lrpad / 2);
     28 +			drw_text(drw, x, 0, w, bh, tlpad, m->sel->name, 0);
     29  			if (m->sel->isfloating)
     30 -				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
     31 +				drw_rect(drw, x + boxs + tlpad - lrpad / 2, boxs,
     32 +					boxw, boxw, m->sel->isfixed, 0);
     33  		} else {
     34  			drw_setscheme(drw, scheme[SchemeNorm]);
     35  			drw_rect(drw, x, 0, w, bh, 1, 1);
     36 -- 
     37 2.28.0
     38