This repository has been archived on 2021-03-07. You can view files and clone it, but cannot push or open issues or pull requests.
sowm/patches/sowm-2bswm-style.patch

77 lines
2.7 KiB
Diff

diff --git a/config.def.h b/config.def.h
index cae2009..f787cbd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,6 +26,20 @@ static struct key keys[] = {
{MOD, XK_p, run, {.com = scrot}},
{MOD, XK_Return, run, {.com = term}},
+ /*
+ * 2bswm-patch.
+ * .i => Increment/Decrement size
+ * .com => {(move/resize), (direction)}
+ */
+ {MOD, XK_h, move, {.com=(char*[]){"move", "left"}, .i=10}},
+ {MOD, XK_j, move, {.com=(char*[]){"move", "down"}, .i=10}},
+ {MOD, XK_k, move, {.com=(char*[]){"move", "up"}, .i=10}},
+ {MOD, XK_l, move, {.com=(char*[]){"move", "right"}, .i=10}},
+ {MOD|ShiftMask, XK_h, move, {.com=(char*[]){"resize", "left"}, .i=10}},
+ {MOD|ShiftMask, XK_j, move, {.com=(char*[]){"resize", "down"}, .i=10}},
+ {MOD|ShiftMask, XK_k, move, {.com=(char*[]){"resize", "up"}, .i=10}},
+ {MOD|ShiftMask, XK_l, move, {.com=(char*[]){"resize", "right"}, .i=10}},
+
{0, XF86XK_AudioLowerVolume, run, {.com = voldown}},
{0, XF86XK_AudioRaiseVolume, run, {.com = volup}},
{0, XF86XK_AudioMute, run, {.com = volmute}},
diff --git a/sowm.c b/sowm.c
index 90ae3bc..7c76571 100644
--- a/sowm.c
+++ b/sowm.c
@@ -8,7 +8,7 @@
#include <signal.h>
#include <unistd.h>
-typedef union {
+typedef struct {
const char** com;
const int i;
const Window w;
@@ -46,6 +46,8 @@ static void win_prev();
static void win_next();
static void win_to_ws(const Arg arg);
static void ws_go(const Arg arg);
+static void apply(int x, int y, int w, int h);
+static void move(const Arg arg);
static int xerror() { return 0;}
static client *list = {0}, *ws_list[10] = {0}, *cur;
@@ -80,6 +82,28 @@ static void (*events[LASTEvent])(XEvent *e) = {
#define mod_clean(mask) (mask & ~(numlock|LockMask) & \
(ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
+void apply(int x, int y, int w, int h) {
+ win_size(cur->w, &wx, &wy, &ww, &wh);
+ XMoveResizeWindow(d, cur->w,
+ wx + x, wy + y,
+ ww + w, wh + h);
+}
+
+void move(const Arg arg) {
+ if(arg.com[1]=="left") {
+ apply((arg.com[0]=="resize")?0:-arg.i, 0, (arg.com[0]=="resize")?-arg.i:0, 0);
+ }
+ else if(arg.com[1]=="right"){
+ apply((arg.com[0]=="resize")?0:arg.i, 0, (arg.com[0]=="resize")?arg.i:0, 0);
+ }
+ else if(arg.com[1]=="up"){
+ apply(0, (arg.com[0]=="resize")?0:-arg.i, 0, (arg.com[0]=="resize")?-arg.i:0);
+ }
+ else if(arg.com[1]=="down"){
+ apply(0, (arg.com[0]=="resize")?0:arg.i, 0, (arg.com[0]=="resize")?arg.i:0);
+ }
+}
+
void win_focus(client *c) {
cur = c;
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);