[wiki] [sites] [patch][dwm] centeredmaster clients are all same size after increasing gaps, but horizontal gaps are half the size || Aaron Duxler

From: <git_AT_suckless.org>
Date: Tue, 25 Jun 2019 17:03:28 +0200

commit d7eb38e335abc2dd2724d7b27bd147a68e196ccc
Author: Aaron Duxler <aaron.duxler_AT_gmail.com>
Date: Tue Jun 25 17:06:18 2019 +0200

    [patch][dwm] centeredmaster clients are all same size after increasing gaps, but horizontal gaps are half the size

diff --git a/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff b/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff
index 4e119deb..cef9bc8f 100644
--- a/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff
+++ b/dwm.suckless.org/patches/ru_gaps/dwm-ru_centeredmaster-6.2.diff
_AT_@ -22,7 +22,7 @@ diff -up a/dwm.c b/dwm.c
  
  /* variables */
  static const char broken[] = "broken";
-_AT_@ -2147,3 +2149,127 @@ main(int argc, char *argv[])
+_AT_@ -2147,3 +2149,155 @@ main(int argc, char *argv[])
          XCloseDisplay(dpy);
          return EXIT_SUCCESS;
  }
_AT_@ -32,9 +32,24 @@ diff -up a/dwm.c b/dwm.c
 +{
 + unsigned int i, n, h, mw, mx, my, oty, ety, tw;
 + Client *c;
-+
++
++ unsigned int l_temp = 0, r_temp = 0, m_temp = 0 , lc = 0, rc = 0, mc = 0;
 + /* count number of clients in the selected monitor */
-+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
++ if (n < m->nmaster){
++ ++mc;
++ }
++ else if ((n - m->nmaster) % 2){
++ ++lc;
++ }
++ else{
++ ++rc;
++ }
++ }
++ l_temp = lc;
++ r_temp = rc;
++ m_temp = mc;
++
 + if (n == 0)
 + return;
 + if(n == 1){
_AT_@ -67,33 +82,36 @@ diff -up a/dwm.c b/dwm.c
 + if (i < m->nmaster) {
 + /* nmaster clients are stacked vertically, in the center
 + * of the screen */
-+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
++ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
 + if(m->nmaster >= n)
-+ resize(c, m->wx + mx + m->gappx, m->wy + my + m->gappx, mw - 2*(c->bw + m->gappx),
-+ h - (2*c->bw) - m->gappx, 0);
++ resize(c, m->wx + mx + m->gappx, m->wy + my + m_temp*m->gappx/mc, mw - 2*(c->bw + m->gappx),
++ h - (2*c->bw) - m->gappx - m->gappx/mc, 0);
 + else if(m->nmaster + 1 < n)
-+ resize(c, m->wx + mx, m->wy + my + m->gappx, mw - 2*(c->bw),
-+ h - (2*c->bw) - m->gappx, 0);
++ resize(c, m->wx + mx, m->wy + my + m_temp*m->gappx/mc, mw - 2*(c->bw),
++ h - (2*c->bw) - m->gappx - m->gappx/mc, 0);
 + else
-+ resize(c, m->wx + mx + m->gappx, m->wy + my + m->gappx, mw - 2*(c->bw) - m->gappx,
-+ h - (2*c->bw) - m->gappx, 0);
++ resize(c, m->wx + mx + m->gappx, m->wy + my + m_temp*m->gappx/mc, mw - 2*(c->bw) - m->gappx,
++ h - (2*c->bw) - m->gappx - m->gappx/mc/m_temp, 0);
 + my += HEIGHT(c) + m->gappx;
++ --m_temp;
 + } else {
 + /* stack clients are stacked vertically */
-+ if ((i - m->nmaster) % 2 ) {
-+ h = (m->wh - ety) / ( (1 + n - i) / 2) - m->gappx;
++ if ((i - m->nmaster) % 2) {
++ h = (m->wh - ety) / ( (1 + n - i) / 2);
 + if(m->nmaster == 0)
 + resize(c, m->wx + m->gappx, m->wy + ety + m->gappx, tw - 2*(c->bw) - m->gappx,
 + h - (2*c->bw) - m->gappx, 0);
 + else
-+ resize(c, m->wx + m->gappx, m->wy + ety + m->gappx, tw - 2*(c->bw + m->gappx),
-+ h - (2*c->bw) - m->gappx, 0);
++ resize(c, m->wx + m->gappx, m->wy + ety + l_temp*m->gappx/lc , tw - 2*(c->bw + m->gappx),
++ h - (2*c->bw) - m->gappx - m->gappx/lc/l_temp, 0);
 + ety += HEIGHT(c) + m->gappx;
++ --l_temp;
 + } else {
-+ h = (m->wh - oty) / ((1 + n - i) / 2) - m->gappx;
-+ resize(c, m->wx + mx + mw + m->gappx, m->wy + oty + m->gappx,
-+ tw - 2*(c->bw + m->gappx), h - (2*c->bw) - m->gappx, 0);
++ h = (m->wh - oty) / ((1 + n - i) / 2);
++ resize(c, m->wx + mx + mw + m->gappx, m->wy + oty + r_temp*m->gappx/rc,
++ tw - 2*(c->bw + m->gappx), h - (2*c->bw) - m->gappx - m->gappx/rc/r_temp, 0);
 + oty += HEIGHT(c) + m->gappx;
++ --r_temp;
 + }
 + }
 +}
_AT_@ -101,11 +119,19 @@ diff -up a/dwm.c b/dwm.c
 +void
 +centeredfloatingmaster(Monitor *m)
 +{
-+ unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
++ unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx, cc = 0, mc = 0;
++ unsigned int m_temp = 0, c_temp = 0;
 + Client *c;
 +
 + /* count number of clients in the selected monitor */
-+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
++ if (n < m->nmaster){
++ ++mc;
++ }
++ else{
++ ++cc;
++ }
++ }
 + if (n == 0)
 + return;
 + if(n == 1){
_AT_@ -138,15 +164,17 @@ diff -up a/dwm.c b/dwm.c
 + if (i < m->nmaster) {
 + /* nmaster clients are stacked horizontally, in the center
 + * of the screen */
-+ w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
-+ resize(c, m->wx + mx + m->gappx, m->wy + my + m->gappx, w - 2*(c->bw + m->gappx),
++ w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i) + m->gappx;
++ resize(c, m->wx + mx + m->gappx - (m_temp*m->gappx)/mc, m->wy + my + m->gappx, w - 2*(c->bw + m->gappx) - m->gappx/mc/(mc - m_temp),
 + mh - 2*(c->bw + m->gappx), 0);
 + mx += WIDTH(c) + m->gappx;
++ ++m_temp;
 + } else {
 + /* stack clients are stacked horizontally */
-+ w = (m->ww - tx) / (n - i);
-+ resize(c, m->wx + tx + m->gappx, m->wy + m->gappx, w - 2*(c->bw + m->gappx),
++ w = (m->ww - tx) / (n - i) + m->gappx;
++ resize(c, m->wx + tx + m->gappx - (c_temp*m->gappx)/cc, m->wy + m->gappx, w - 2*(c->bw + m->gappx) - m->gappx/cc/(cc - c_temp),
 + m->wh - 2*(c->bw + m->gappx), 0);
 + tx += WIDTH(c) + m->gappx;
++ ++c_temp;
 + }
 +}
Received on Tue Jun 25 2019 - 17:03:28 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 25 2019 - 17:12:29 CEST