dwm-rulerefresher-6.2.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-rulerefresher-6.2.diff (2156B)
       ---
            1 From 5728e3bc46ef38cfcc0f2cbf04626a28ecc57379 Mon Sep 17 00:00:00 2001
            2 From: Lars Niesen <lars.niesen@gmx.de>
            3 Date: Thu, 9 Dec 2021 13:40:17 +0100
            4 Subject: [PATCH] rulerefresher
            5 
            6 ---
            7  dwm.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
            8  1 file changed, 50 insertions(+)
            9 
           10 diff --git a/dwm.c b/dwm.c
           11 index 4465af1..5f8ba9c 100644
           12 --- a/dwm.c
           13 +++ b/dwm.c
           14 @@ -223,6 +223,7 @@ static int updategeom(void);
           15  static void updatenumlockmask(void);
           16  static void updatesizehints(Client *c);
           17  static void updatestatus(void);
           18 +static void updaterules(Client *c);
           19  static void updatetitle(Client *c);
           20  static void updatewindowtype(Client *c);
           21  static void updatewmhints(Client *c);
           22 @@ -1237,6 +1238,7 @@ propertynotify(XEvent *e)
           23                  }
           24                  if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
           25                          updatetitle(c);
           26 +            updaterules(c);
           27                          if (c == c->mon->sel)
           28                                  drawbar(c->mon);
           29                  }
           30 @@ -1992,6 +1994,54 @@ updatestatus(void)
           31          drawbar(selmon);
           32  }
           33  
           34 +void
           35 +updaterules(Client *c)
           36 +{
           37 +    //applyrules(c)
           38 +        const char *class, *instance;
           39 +        unsigned int i;
           40 +        const Rule *r;
           41 +        Monitor *m;
           42 +        XClassHint ch = { NULL, NULL };
           43 +
           44 +        /* rule matching */
           45 +        XGetClassHint(dpy, c->win, &ch);
           46 +        class    = ch.res_class ? ch.res_class : broken;
           47 +        instance = ch.res_name  ? ch.res_name  : broken;
           48 +    char found_rule = 0;
           49 +
           50 +        for (i = 0; i < LENGTH(rules); i++) {
           51 +                r = &rules[i];
           52 +                if ((!r->title || strstr(c->name, r->title))
           53 +                && (!r->class || strstr(class, r->class))
           54 +                && (!r->instance || strstr(instance, r->instance)))
           55 +                {
           56 +                        c->isfloating = r->isfloating;
           57 +
           58 +            if(!found_rule)
           59 +            {
           60 +                c->tags=0;
           61 +                            found_rule=1;
           62 +            }    
           63 +            c->tags |= r->tags;
           64 +            for (m = mons; m && m->num != r->monitor; m = m->next);
           65 +                        if (m)
           66 +                                c->mon = m;
           67 +                }
           68 +        }
           69 +        if (ch.res_class)
           70 +                XFree(ch.res_class);
           71 +        if (ch.res_name)
           72 +                XFree(ch.res_name);
           73 +        c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
           74 +
           75 +    // end apply rules
           76 +        if (c->isfloating)
           77 +                resize(c, c->x, c->y,
           78 +                        c->w, c->h, 0);
           79 +        arrange(c->mon);
           80 +}
           81 +
           82  void
           83  updatetitle(Client *c)
           84  {
           85 -- 
           86 2.34.1
           87