commit 58abc0213b0e4b9a3e62bbdf83e9cd1288477472
Author: Dhaval Patel <[email protected]>
Date:   Tue Jun 23 12:46:36 2020 +0530

    added dwm patch aspectresize

diff --git a/dwm.suckless.org/patches/aspectresize/dwm-aspectresize-6.2.diff 
b/dwm.suckless.org/patches/aspectresize/dwm-aspectresize-6.2.diff
new file mode 100644
index 00000000..1a2a673f
--- /dev/null
+++ b/dwm.suckless.org/patches/aspectresize/dwm-aspectresize-6.2.diff
@@ -0,0 +1,56 @@
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..2fcc30d 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -72,6 +72,8 @@ static Key keys[] = {
+       { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} 
},
+       { MODKEY,                       XK_Return, zoom,           {0} },
+       { MODKEY,                       XK_Tab,    view,           {0} },
++      { MODKEY|ShiftMask,             XK_j,      aspectresize,   {.i = +24} },
++      { MODKEY|ShiftMask,             XK_k,      aspectresize,   {.i = -24} },
+       { MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
+       { MODKEY,                       XK_t,      setlayout,      {.v = 
&layouts[0]} },
+       { MODKEY,                       XK_f,      setlayout,      {.v = 
&layouts[1]} },
+diff --git a/dwm.c b/dwm.c
+index 9fd0286..6a02119 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -146,6 +146,7 @@ static void applyrules(Client *c);
+ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int 
interact);
+ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
++static void aspectresize(const Arg *arg);
+ static void attach(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+@@ -400,6 +401,30 @@ arrangemon(Monitor *m)
+               m->lt[m->sellt]->arrange(m);
+ }
+ 
++void
++aspectresize(const Arg *arg) {
++      /* only floating windows can be moved */
++      Client *c;
++      c = selmon->sel;
++      float ratio;
++      int w, h,nw, nh;
++
++      if (!c || !arg)
++              return;
++      if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
++              return;
++
++      ratio = (float)c->w / (float)c->h;
++      h = arg->i;
++      w = (int)(ratio * h);
++
++      nw = c->w + w;
++      nh = c->h + h;
++
++      XRaiseWindow(dpy, c->win);
++      resize(c, c->x, c->y, nw, nh, True);
++}
++
+ void
+ attach(Client *c)
+ {
diff --git a/dwm.suckless.org/patches/aspectresize/index.md 
b/dwm.suckless.org/patches/aspectresize/index.md
new file mode 100644
index 00000000..86377c2a
--- /dev/null
+++ b/dwm.suckless.org/patches/aspectresize/index.md
@@ -0,0 +1,54 @@
+aspectresize
+==========
+
+Description
+-----------
+This patch you to resize the window with its aspect ratio remain constant, use
+moveresize patch for manual resize.
+
+Usage
+-----
+1. Put the following `aspectresize()` function somewhere in your `dwm.c`,
+  **after** the line which includes the config.h file:
+
+        void
+        aspectresize(const Arg *arg) {
+               /* only floating windows can be moved */
+               Client *c;
+               c = selmon->sel;
+               float ratio;
+               int w, h,nw, nh;
+        
+               if (!c || !arg)
+                       return;
+               if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
+                       return;
+        
+               ratio = (float)c->w / (float)c->h;
+               h = arg->i;
+               w = (int)(ratio * h);
+        
+               nw = c->w + w;
+               nh = c->h + h;
+        
+               XRaiseWindow(dpy, c->win);
+               resize(c, c->x, c->y, nw, nh, True);
+        }
+ 
+
+2. Add a aspectresize() function definition in dwm.c below the line:
+       static void aspectresize(const Arg *arg);
+
+3. You can use Mod+Shift+j to increase size and Mod+Shift+k to decrease the 
size of client
+   which respects client's aspect ratio:
+
+       { MODKEY|ShiftMask,             XK_j,      aspectresize,   {.i = +24} },
+       { MODKEY|ShiftMask,             XK_k,      aspectresize,   {.i = -24} },
+
+Download
+--------
+* [dwm-aspectresize-6.2.diff](dwm-aspectresize-6.2.diff)
+
+Authors
+-------
+* Dhaval Patel - <[email protected]>


Reply via email to