dwm-centerfirstwindow-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-centerfirstwindow-6.2.diff (2532B)
       ---
            1 diff -up dwm-6.2-orig/config.def.h dwm-6.2-modd/config.def.h
            2 --- dwm-6.2-orig/config.def.h        2019-02-02 16:55:28.000000000 +0400
            3 +++ dwm-6.2-modd/config.def.h        2021-04-25 16:05:22.569759243 +0400
            4 @@ -26,9 +26,10 @@ static const Rule rules[] = {
            5           *        WM_CLASS(STRING) = instance, class
            6           *        WM_NAME(STRING) = title
            7           */
            8 -        /* class      instance    title       tags mask     isfloating   monitor */
            9 -        { "Gimp",     NULL,       NULL,       0,            1,           -1 },
           10 -        { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
           11 +        /* class                   instance    title    tags mask     isfloating   CenterThisWindow?     monitor */
           12 +        { "st",              NULL,       NULL,    0,            0,                  1,                           -1 },
           13 +        { "Gimp",            NULL,       NULL,    0,            1,           0,                    -1 },
           14 +        { "Firefox",         NULL,       NULL,    1 << 8,       0,           0,                    -1 },
           15  };
           16  
           17  /* layout(s) */
           18 diff -up dwm-6.2-orig/dwm.c dwm-6.2-modd/dwm.c
           19 --- dwm-6.2-orig/dwm.c        2019-02-02 16:55:28.000000000 +0400
           20 +++ dwm-6.2-modd/dwm.c        2021-04-25 16:06:15.368310756 +0400
           21 @@ -92,7 +92,7 @@ struct Client {
           22          int basew, baseh, incw, inch, maxw, maxh, minw, minh;
           23          int bw, oldbw;
           24          unsigned int tags;
           25 -        int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
           26 +        int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;
           27          Client *next;
           28          Client *snext;
           29          Monitor *mon;
           30 @@ -138,6 +138,7 @@ typedef struct {
           31          const char *title;
           32          unsigned int tags;
           33          int isfloating;
           34 +        int CenterThisWindow;
           35          int monitor;
           36  } Rule;
           37  
           38 @@ -286,6 +287,7 @@ applyrules(Client *c)
           39  
           40          /* rule matching */
           41          c->isfloating = 0;
           42 +        c->CenterThisWindow = 0;
           43          c->tags = 0;
           44          XGetClassHint(dpy, c->win, &ch);
           45          class    = ch.res_class ? ch.res_class : broken;
           46 @@ -298,6 +300,7 @@ applyrules(Client *c)
           47                  && (!r->instance || strstr(instance, r->instance)))
           48                  {
           49                          c->isfloating = r->isfloating;
           50 +                        c->CenterThisWindow = r->CenterThisWindow;
           51                          c->tags |= r->tags;
           52                          for (m = mons; m && m->num != r->monitor; m = m->next);
           53                          if (m)
           54 @@ -1694,6 +1697,13 @@ tile(Monitor *m)
           55                          resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
           56                          ty += HEIGHT(c);
           57                  }
           58 +
           59 +        if (n == 1 && selmon->sel->CenterThisWindow)
           60 +        resizeclient(selmon->sel,
           61 +                (selmon->mw - selmon->mw * 0.5) / 2,
           62 +                (selmon->mh - selmon->mh * 0.5) / 2,
           63 +                selmon->mw * 0.5,
           64 +                selmon->mh * 0.5);
           65  }
           66  
           67  void