extend floating mode keybinds

This commit is contained in:
speediegq 2022-09-11 14:06:29 +02:00
parent 20b83d151b
commit adcb8fc79e
3 changed files with 27 additions and 0 deletions

View file

@ -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)

View file

@ -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"} },

View file

@ -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)
{