diff --git a/config.def.h b/config.def.h index cae2009..13352ca 100644 --- a/config.def.h +++ b/config.def.h @@ -18,6 +18,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 = 10}}, + {MOD, XK_j, win_move, {.com = (const char*[]){"move", "s"}, .i = 10}}, + {MOD, XK_l, win_move, {.com = (const char*[]){"move", "e"}, .i = 10}}, + {MOD, XK_h, win_move, {.com = (const char*[]){"move", "w"}, .i = 10}}, + + {MOD|ShiftMask, XK_k, win_move, {.com = (const char*[]){"resize", "n"}, .i = 10}}, + {MOD|ShiftMask, XK_j, win_move, {.com = (const char*[]){"resize", "s"}, .i = 10}}, + {MOD|ShiftMask, XK_l, win_move, {.com = (const char*[]){"resize", "e"}, .i = 10}}, + {MOD|ShiftMask, XK_h, win_move, {.com = (const char*[]){"resize", "w"}, .i = 10}}, + {Mod1Mask, XK_Tab, win_next, {0}}, {Mod1Mask|ShiftMask, XK_Tab, win_prev, {0}}, diff --git a/sowm.c b/sowm.c index b4a39dd..e7b783e 100644 --- a/sowm.c +++ b/sowm.c @@ -31,6 +31,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); diff --git a/sowm.h b/sowm.h index 455ed93..26f2754 100644 --- a/sowm.h +++ b/sowm.h @@ -51,6 +51,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);