Skip to content

Commit

Permalink
PATCH: Keyboard move/resize
Browse files Browse the repository at this point in the history
  • Loading branch information
ttr3dp committed Jan 26, 2021
1 parent 43aefe3 commit 9a508a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ static struct key keys[] = {
{MOD, XK_c, win_center, {0}},
{MOD, XK_f, win_fs, {0}},

{MOD, XK_k, win_move, {.com = (const char*[]){"move", "n"}, .i = 45}},
{MOD, XK_j, win_move, {.com = (const char*[]){"move", "s"}, .i = 45}},
{MOD, XK_l, win_move, {.com = (const char*[]){"move", "e"}, .i = 80}},
{MOD, XK_h, win_move, {.com = (const char*[]){"move", "w"}, .i = 80}},

{MOD|ShiftMask, XK_k, win_move, {.com = (const char*[]){"resize", "n"}, .i = 45}},
{MOD|ShiftMask, XK_j, win_move, {.com = (const char*[]){"resize", "s"}, .i = 45}},
{MOD|ShiftMask, XK_l, win_move, {.com = (const char*[]){"resize", "e"}, .i = 80}},
{MOD|ShiftMask, XK_h, win_move, {.com = (const char*[]){"resize", "w"}, .i = 80}},

{Mod1Mask, XK_Tab, win_next, {0}},
{Mod1Mask|ShiftMask, XK_Tab, win_prev, {0}},

Expand Down
13 changes: 13 additions & 0 deletions sowm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ static void (*events[LASTEvent])(XEvent *e) = {

#include "config.h"

void win_move(const Arg arg) {
int r = arg.com[0][0] == 'r';
char m = arg.com[1][0];

win_size(cur->w, &wx, &wy, &ww, &wh);

XMoveResizeWindow(d, cur->w, \
wx + (r ? 0 : m == 'e' ? arg.i : m == 'w' ? -arg.i : 0),
wy + (r ? 0 : m == 'n' ? -arg.i : m == 's' ? arg.i : 0),
MAX(10, ww + (r ? m == 'e' ? arg.i : m == 'w' ? -arg.i : 0 : 0)),
MAX(10, wh + (r ? m == 'n' ? -arg.i : m == 's' ? arg.i : 0 : 0)));
}

void win_focus(client *c) {
cur = c;
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
Expand Down
1 change: 1 addition & 0 deletions sowm.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void win_focus(client *c);
void win_kill(const Arg arg);
void win_prev(const Arg arg);
void win_next(const Arg arg);
void win_move(const Arg arg);
void win_to_ws(const Arg arg);
void ws_go(const Arg arg);

Expand Down

0 comments on commit 9a508a7

Please sign in to comment.