sites

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

dwm-truecenteredtitle-6.3.diff (1360B)


      1 From be8b8d6a0b864a7c6ca7e37a1df9f53ddd87916b Mon Sep 17 00:00:00 2001
      2 From: explosion-mental <explosion0mental@gmail.com>
      3 Date: Tue, 12 Apr 2022 12:10:14 -0500
      4 Subject: [PATCH] [PATCH][truecenteredtitle]Center the title with proportion to
      5  the area that the title has, unlike the [other center title](../centretitle)
      6  patch that center proportion to the screen size width (`m->ww`), which on
      7  smaller monitors doesn't get the effect.
      8 
      9 If the title name is to long (title area too small for the title string)
     10 it will back up to the default behaviour, which is to truncate the
     11 title.
     12 ---
     13  dwm.c | 5 ++++-
     14  1 file changed, 4 insertions(+), 1 deletion(-)
     15 
     16 diff --git a/dwm.c b/dwm.c
     17 index a96f33c..6198b29 100644
     18 --- a/dwm.c
     19 +++ b/dwm.c
     20 @@ -735,7 +735,10 @@ drawbar(Monitor *m)
     21  	if ((w = m->ww - tw - x) > bh) {
     22  		if (m->sel) {
     23  			drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
     24 -			drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
     25 +			if (TEXTW(m->sel->name) > w) /* title is bigger than the width of the title rectangle, don't center */
     26 +				drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
     27 +			else /* center window title */
     28 +				drw_text(drw, x, 0, w, bh, (w - TEXTW(m->sel->name)) / 2, m->sel->name, 0);
     29  			if (m->sel->isfloating)
     30  				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
     31  		} else {
     32 --
     33 2.35.1
     34