mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 01:20:23 -07:00
Patch: 2bswm-style fixed
This commit is contained in:
parent
e0d0415d06
commit
facbfcf061
@ -1,11 +1,16 @@
|
|||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index cae2009..9ad7175 100644
|
index cae2009..f787cbd 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -26,6 +26,26 @@ static struct key keys[] = {
|
@@ -26,6 +26,20 @@ static struct key keys[] = {
|
||||||
{MOD, XK_p, run, {.com = scrot}},
|
{MOD, XK_p, run, {.com = scrot}},
|
||||||
{MOD, XK_Return, run, {.com = term}},
|
{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_h, move, {.com=(char*[]){"move", "left"}, .i=10}},
|
||||||
+ {MOD, XK_j, move, {.com=(char*[]){"move", "down"}, .i=10}},
|
+ {MOD, XK_j, move, {.com=(char*[]){"move", "down"}, .i=10}},
|
||||||
+ {MOD, XK_k, move, {.com=(char*[]){"move", "up"}, .i=10}},
|
+ {MOD, XK_k, move, {.com=(char*[]){"move", "up"}, .i=10}},
|
||||||
@ -14,83 +19,58 @@ index cae2009..9ad7175 100644
|
|||||||
+ {MOD|ShiftMask, XK_j, move, {.com=(char*[]){"resize", "down"}, .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_k, move, {.com=(char*[]){"resize", "up"}, .i=10}},
|
||||||
+ {MOD|ShiftMask, XK_l, move, {.com=(char*[]){"resize", "right"}, .i=10}},
|
+ {MOD|ShiftMask, XK_l, move, {.com=(char*[]){"resize", "right"}, .i=10}},
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ {MOD, XK_h, move_left, {.com = {"move"},.i=10}},
|
|
||||||
+ {MOD, XK_j, move_down, {.com = {"move"},.i=10}},
|
|
||||||
+ {MOD, XK_k, move_up, {.com = {"move"},.i=10}},
|
|
||||||
+ {MOD, XK_l, move_right, {.com = {"move"},.i=10}},
|
|
||||||
+ {MOD|ShiftMask, XK_h, resize_left, {.com = {"resize"},.i=10}},
|
|
||||||
+ {MOD|ShiftMask, XK_j, resize_down, {.com = {"resize"},.i=10}},
|
|
||||||
+ {MOD|ShiftMask, XK_k, resize_up, {.com = {"resize"},.i=10}},
|
|
||||||
+ {MOD|ShiftMask, XK_l, resize_right, {.com = {"resize"},.i=10}},
|
|
||||||
+ */
|
|
||||||
+
|
+
|
||||||
{0, XF86XK_AudioLowerVolume, run, {.com = voldown}},
|
{0, XF86XK_AudioLowerVolume, run, {.com = voldown}},
|
||||||
{0, XF86XK_AudioRaiseVolume, run, {.com = volup}},
|
{0, XF86XK_AudioRaiseVolume, run, {.com = volup}},
|
||||||
{0, XF86XK_AudioMute, run, {.com = volmute}},
|
{0, XF86XK_AudioMute, run, {.com = volmute}},
|
||||||
diff --git a/sowm.c b/sowm.c
|
diff --git a/sowm.c b/sowm.c
|
||||||
index 48222c6..00e2e80 100644
|
index 90ae3bc..7c76571 100644
|
||||||
--- a/sowm.c
|
--- a/sowm.c
|
||||||
+++ b/sowm.c
|
+++ b/sowm.c
|
||||||
@@ -7,8 +7,9 @@
|
@@ -8,7 +8,7 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
+#include <stdio.h>
|
|
||||||
|
|
||||||
-typedef union {
|
-typedef union {
|
||||||
+typedef struct {
|
+typedef struct {
|
||||||
const char** com;
|
const char** com;
|
||||||
const int i;
|
const int i;
|
||||||
const Window w;
|
const Window w;
|
||||||
@@ -46,6 +47,9 @@ static void win_prev();
|
@@ -46,6 +46,8 @@ static void win_prev();
|
||||||
static void win_next();
|
static void win_next();
|
||||||
static void win_to_ws(const Arg arg);
|
static void win_to_ws(const Arg arg);
|
||||||
static void ws_go(const Arg arg);
|
static void ws_go(const Arg arg);
|
||||||
+static void apply(int x, int y, int w, int h);
|
+static void apply(int x, int y, int w, int h);
|
||||||
+static void move(const Arg arg);
|
+static void move(const Arg arg);
|
||||||
+
|
|
||||||
static int xerror() { return 0;}
|
static int xerror() { return 0;}
|
||||||
|
|
||||||
static client *list = {0}, *ws_list[10] = {0}, *cur;
|
static client *list = {0}, *ws_list[10] = {0}, *cur;
|
||||||
@@ -77,6 +81,31 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
@@ -80,6 +82,28 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
||||||
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
#define mod_clean(mask) (mask & ~(numlock|LockMask) & \
|
||||||
&(unsigned int){0}, &(unsigned int){0})
|
(ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
|
|
||||||
+void apply(int x,int y,int w,int h) {
|
+void apply(int x, int y, int w, int h) {
|
||||||
+ win_size(cur->w, &wx, &wy, &ww, &wh);
|
+ win_size(cur->w, &wx, &wy, &ww, &wh);
|
||||||
+ XMoveResizeWindow(d, cur->w,
|
+ XMoveResizeWindow(d, cur->w,
|
||||||
+ wx + x,
|
+ wx + x, wy + y,
|
||||||
+ wy + y,
|
+ ww + w, wh + h);
|
||||||
+ ww + w,
|
|
||||||
+ wh + h);
|
|
||||||
+ win_size(cur->w, &wx, &wy, &ww, &wh);
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+void move(const Arg arg) {
|
+void move(const Arg arg) {
|
||||||
+ if(arg.com[1]=="left") {
|
+ if(arg.com[1]=="left") {
|
||||||
+ apply((arg.com[0]=="resize")?arg.i:-arg.i, 0, (arg.com[0]=="resize")?-arg.i:0, 0);
|
+ apply((arg.com[0]=="resize")?0:-arg.i, 0, (arg.com[0]=="resize")?-arg.i:0, 0);
|
||||||
+ }
|
+ }
|
||||||
+ else if(arg.com[1]=="right"){
|
+ else if(arg.com[1]=="right"){
|
||||||
+ apply((arg.com[0]=="resize")?-arg.i:arg.i, 0, (arg.com[0]=="resize")?arg.i:0, 0);
|
+ apply((arg.com[0]=="resize")?0:arg.i, 0, (arg.com[0]=="resize")?arg.i:0, 0);
|
||||||
+ }
|
+ }
|
||||||
+ else if(arg.com[1]=="up"){
|
+ else if(arg.com[1]=="up"){
|
||||||
+ apply(0, (arg.com[0]=="resize")?arg.i:-arg.i, 0, (arg.com[0]=="resize")?-arg.i:0);
|
+ apply(0, (arg.com[0]=="resize")?0:-arg.i, 0, (arg.com[0]=="resize")?-arg.i:0);
|
||||||
+ }
|
+ }
|
||||||
+ else if(arg.com[1]=="down"){
|
+ else if(arg.com[1]=="down"){
|
||||||
+ apply(0, (arg.com[0]=="resize")?-arg.i:arg.i, 0, (arg.com[0]=="resize")?arg.i:0);
|
+ apply(0, (arg.com[0]=="resize")?0:arg.i, 0, (arg.com[0]=="resize")?arg.i:0);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
void win_focus(client *c) {
|
void win_focus(client *c) {
|
||||||
cur = c;
|
cur = c;
|
||||||
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
||||||
@@ -130,6 +159,7 @@ void button_press(XEvent *e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void button_release() {
|
|
||||||
+ win_size(cur->w, &wx, &wy, &ww, &wh);
|
|
||||||
mouse.subwindow = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user