[wiki] [sites] [dwm][PATCH] sizehints-ruled updated and working as intended || MLquest8

From: <git_AT_suckless.org>
Date: Sun, 14 Jun 2020 11:25:52 +0200

commit 31c4d0abc8b74150b9f6a9c5fd66ead8d149e120
Author: MLquest8 <miskuzius_AT_gmail.com>
Date: Sun Jun 14 13:23:55 2020 +0400

    [dwm][PATCH] sizehints-ruled updated and working as intended

diff --git a/dwm.suckless.org/patches/sizehints/dwm-sizehints-ruled-6.2.diff b/dwm.suckless.org/patches/sizehints/dwm-sizehints-ruled-6.2.diff
index 78b04bba..787eb41f 100644
--- a/dwm.suckless.org/patches/sizehints/dwm-sizehints-ruled-6.2.diff
+++ b/dwm.suckless.org/patches/sizehints/dwm-sizehints-ruled-6.2.diff
_AT_@ -1,24 +1,73 @@
-From 0ddf28f0fa3285d7c75cb9493ce82075b7819564 Mon Sep 17 00:00:00 2001
+From c605c7f4c3f421ef5b6f12031b07abe713cd8183 Mon Sep 17 00:00:00 2001
 From: MLquest8 <miskuzius_AT_gmail.com>
-Date: Fri, 12 Jun 2020 17:28:03 +0400
-Subject: [PATCH] sizehints version which obeys "isfloating" rule. Version 6.2
+Date: Sun, 14 Jun 2020 13:06:31 +0400
+Subject: [PATCH] resizehints-ruled. Modified to properly read the rules and
+ apply as needed. Behavior for clients that aren't found in rules struct is
+ remains the same.
 
 ---
- dwm.c | 12 +++++++++++-
- 1 file changed, 11 insertions(+), 1 deletion(-)
+ config.def.h | 2 ++
+ dwm.c | 34 +++++++++++++++++++++++++++++++++-
+ 2 files changed, 35 insertions(+), 1 deletion(-)
 
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..1d55286 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -29,6 +29,8 @@ static const Rule rules[] = {
+ /* class instance title tags mask isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
++ { "st", NULL, NULL, 0, 0, -1 },
++ { "St", NULL, NULL, 0, 0, -1 }, /* if Xresources[st] is patched in */
+ };
+
+ /* layout(s) */
 diff --git a/dwm.c b/dwm.c
-index 9fd0286..0205e29 100644
+index 9fd0286..f0f569e 100644
 --- a/dwm.c
 +++ b/dwm.c
-_AT_@ -1947,12 +1947,14 @@ updatenumlockmask(void)
+_AT_@ -149,6 +149,7 @@ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
++static void checkfloatingrules(Client *c);
+ static void checkotherwm(void);
+ static void cleanup(void);
+ static void cleanupmon(Monitor *mon);
+_AT_@ -456,6 +457,31 @@ buttonpress(XEvent *e)
+ buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
+ }
+
++void
++checkfloatingrules(Client *c)
++{
++ const char *class, *instance;
++ unsigned int i;
++ const Rule *r;
++ XClassHint ch = { NULL, NULL };
++
++ XGetClassHint(dpy, c->win, &ch);
++ class = ch.res_class ? ch.res_class : broken;
++ instance = ch.res_name ? ch.res_name : broken;
++
++ for (i = 0; i < LENGTH(rules); i++) {
++ r = &rules[i];
++ if ((!r->title || strstr(c->name, r->title))
++ && (!r->class || strstr(class, r->class))
++ && (!r->instance || strstr(instance, r->instance)))
++ c->isfloating = r->isfloating;
++ }
++ if (ch.res_class)
++ XFree(ch.res_class);
++ if (ch.res_name)
++ XFree(ch.res_name);
++}
++
  void
- updatesizehints(Client *c)
+ checkotherwm(void)
  {
-+ int i;
- long msize;
-+ const Rule *r;
- XSizeHints size;
+_AT_@ -1952,7 +1978,7 @@ updatesizehints(Client *c)
  
          if (!XGetWMNormalHints(dpy, c->win, &size, &msize))
                  /* size is uninitialized, ensure that size.flags aren't used */
_AT_@ -27,18 +76,16 @@ index 9fd0286..0205e29 100644
          if (size.flags & PBaseSize) {
                  c->basew = size.base_width;
                  c->baseh = size.base_height;
-_AT_@ -1984,6 +1986,14 @@ updatesizehints(Client *c)
+_AT_@ -1984,6 +2010,12 @@ updatesizehints(Client *c)
                  c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
          } else
                  c->maxa = c->mina = 0.0;
-+ for (i = 0; i < LENGTH(rules); i++) {
-+ r = &rules[i];
-+ if((size.flags & PSize) && (r->isfloating != 0)) {
-+ c->basew = size.base_width;
-+ c->baseh = size.base_height;
-+ c->isfloating = True;
-+ }
++ if(size.flags & PSize) {
++ c->basew = size.base_width;
++ c->baseh = size.base_height;
++ c->isfloating = 1;
 + }
++ checkfloatingrules(c);
          c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
  }
  
diff --git a/dwm.suckless.org/patches/sizehints/index.md b/dwm.suckless.org/patches/sizehints/index.md
index 333f3c10..e735c336 100644
--- a/dwm.suckless.org/patches/sizehints/index.md
+++ b/dwm.suckless.org/patches/sizehints/index.md
_AT_@ -22,7 +22,8 @@ There is no configuration for this version of the patch.
 
 Download
 --------
-* [dwm-sizehints-ruled-6.2.diff](dwm-sizehints-ruled-6.2.diff) (12/06/2020)
+* [dwm-sizehints-ruled-6.2.diff](dwm-sizehints-ruled-6.2.diff) (14/06/2020)
+* dwm-sizehints-ruled-6.2.diff (deprecated) (12/06/2020)
 * [dwm-sizehints-6.2.diff](dwm-sizehints-6.2.diff) (12/06/2020)
 * [dwm-sizehints-5.7.2.diff](dwm-sizehints-5.7.2.diff) (695B) (20091221)
 
Received on Sun Jun 14 2020 - 11:25:52 CEST

This archive was generated by hypermail 2.3.0 : Sun Jun 14 2020 - 11:36:43 CEST