diff --git a/docs/bindlist b/docs/bindlist index 9d5be17..ed88a27 100644 --- a/docs/bindlist +++ b/docs/bindlist @@ -81,6 +81,7 @@ - Super+Control+Shift+n | Connect to wifi (Requires iwd) - Super+Control+Shift+b | Connect to a bluetooth device (Requires bluez and bluez-utils) - Super+Control+Shift+e | Open up a list of dotfiles in dmenu that you can edit. + - Alt+Super+Up/Down | Resize the window keeping the aspect ratio of it. - Alt+Tab | Switch windows quickly and easily - Alt+Control+j/k | Change window size vertically (cfact) diff --git a/keybinds.h b/keybinds.h index 0147919..ed90b18 100644 --- a/keybinds.h +++ b/keybinds.h @@ -108,6 +108,8 @@ static const Key keys[] = { { MODIFIER1|ShiftMask, -1, XK_Up, moveresize, {.v = "0x 0y 0w -25h" } }, { MODIFIER1|ShiftMask, -1, XK_Right, moveresize, {.v = "0x 0y 25w 0h" } }, { MODIFIER1|ShiftMask, -1, XK_Left, moveresize, {.v = "0x 0y -25w 0h" } }, + { MODIFIER2|ShiftMask, -1, XK_Down, moveresizeaspect, {.i = +24} }, + { MODIFIER2|ShiftMask, -1, XK_Up, moveresizeaspect, {.i = -24} }, { MODIFIER1|ControlMask, -1, XK_Up, moveresizeedge, {.v = "t"} }, { MODIFIER1|ControlMask, -1, XK_Down, moveresizeedge, {.v = "b"} }, { MODIFIER1|ControlMask, -1, XK_Left, moveresizeedge, {.v = "l"} }, diff --git a/speedwm.c b/speedwm.c index 9448f8e..9293ce8 100644 --- a/speedwm.c +++ b/speedwm.c @@ -302,6 +302,7 @@ static void setnumdesktops(void); static void setviewport(void); static void arrange(Monitor *m); static void arrangemon(Monitor *m); +static void moveresizeaspect(const Arg *arg); static void attach(Client *c); static void attachabove(Client *c); static void attachaside(Client *c); @@ -865,6 +866,29 @@ arrangemon(Monitor *m) } } +void +moveresizeaspect(const Arg *arg) { + 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) {