sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-aspectresize-6.2.diff (1733B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 1c0b587..2fcc30d 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -72,6 +72,8 @@ static Key keys[] = {
      6  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
      7  	{ MODKEY,                       XK_Return, zoom,           {0} },
      8  	{ MODKEY,                       XK_Tab,    view,           {0} },
      9 +	{ MODKEY|ShiftMask,             XK_j,      aspectresize,   {.i = +24} },
     10 +	{ MODKEY|ShiftMask,             XK_k,      aspectresize,   {.i = -24} },
     11  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     12  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     13  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     14 diff --git a/dwm.c b/dwm.c
     15 index 9fd0286..6a02119 100644
     16 --- a/dwm.c
     17 +++ b/dwm.c
     18 @@ -146,6 +146,7 @@ static void applyrules(Client *c);
     19  static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
     20  static void arrange(Monitor *m);
     21  static void arrangemon(Monitor *m);
     22 +static void aspectresize(const Arg *arg);
     23  static void attach(Client *c);
     24  static void attachstack(Client *c);
     25  static void buttonpress(XEvent *e);
     26 @@ -400,6 +401,30 @@ arrangemon(Monitor *m)
     27  		m->lt[m->sellt]->arrange(m);
     28  }
     29  
     30 +void
     31 +aspectresize(const Arg *arg) {
     32 +	/* only floating windows can be moved */
     33 +	Client *c;
     34 +	c = selmon->sel;
     35 +	float ratio;
     36 +	int w, h,nw, nh;
     37 +
     38 +	if (!c || !arg)
     39 +		return;
     40 +	if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
     41 +		return;
     42 +
     43 +	ratio = (float)c->w / (float)c->h;
     44 +	h = arg->i;
     45 +	w = (int)(ratio * h);
     46 +
     47 +	nw = c->w + w;
     48 +	nh = c->h + h;
     49 +
     50 +	XRaiseWindow(dpy, c->win);
     51 +	resize(c, c->x, c->y, nw, nh, True);
     52 +}
     53 +
     54  void
     55  attach(Client *c)
     56  {