Merge branch 'master' of github.com:dylanaraps/sowm

This commit is contained in:
Dylan Araps 2019-11-24 14:24:28 +00:00
commit d37d04ef32
2 changed files with 135 additions and 1 deletions

View File

@ -17,7 +17,7 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
- All windows die on exit.
- No window borders.
- [No ICCCM](https://web.archive.org/web/20190617214524/https://raw.githubusercontent.com/kfish/xsel/1a1c5edf0dc129055f7764c666da2dd468df6016/rant.txt).
- No EMWH.
- No EWMH.
- etc etc etc

View File

@ -0,0 +1,134 @@
diff -up a/config.def.h b/config.def.h
--- a/config.def.h 2019-10-28 23:55:17.000000000 +0200
+++ b/config.def.h 2019-11-09 22:30:45.057057111 +0200
@@ -32,16 +32,29 @@ static struct key keys[] = {
{MOD, XK_1, ws_go, {.i = 1}},
{MOD|ShiftMask, XK_1, win_to_ws, {.i = 1}},
+ {MOD|ControlMask,XK_1,ws_toggle, {.i = 1}},
+
{MOD, XK_2, ws_go, {.i = 2}},
{MOD|ShiftMask, XK_2, win_to_ws, {.i = 2}},
+ {MOD|ControlMask,XK_2,ws_toggle, {.i = 2}},
+
{MOD, XK_3, ws_go, {.i = 3}},
{MOD|ShiftMask, XK_3, win_to_ws, {.i = 3}},
+ {MOD|ControlMask,XK_3,ws_toggle, {.i = 3}},
+
{MOD, XK_4, ws_go, {.i = 4}},
{MOD|ShiftMask, XK_4, win_to_ws, {.i = 4}},
+ {MOD|ControlMask,XK_4,ws_toggle, {.i = 4}},
+
{MOD, XK_5, ws_go, {.i = 5}},
{MOD|ShiftMask, XK_5, win_to_ws, {.i = 5}},
+ {MOD|ControlMask,XK_5,ws_toggle, {.i = 5}},
+
{MOD, XK_6, ws_go, {.i = 6}},
{MOD|ShiftMask, XK_6, win_to_ws, {.i = 6}},
+ {MOD|ControlMask,XK_6,ws_toggle, {.i = 6}},
+
+ {MOD, XK_0, ws_toggle_all, {.i = 0}},
};
#endif
Only in b/: config.h
Common subdirectories: a/patches and b/patches
Only in b/: sowm
diff -up a/sowm.c b/sowm.c
--- a/sowm.c 2019-10-28 23:55:17.000000000 +0200
+++ b/sowm.c 2019-11-09 22:34:10.660379162 +0200
@@ -45,11 +45,14 @@ static void win_kill();
static void win_next();
static void win_to_ws(const Arg arg);
static void ws_go(const Arg arg);
+static void ws_toggle(const Arg arg);
+static void ws_toggle_all(const Arg arg);
static int xerror() { return 0;}
static client *list = {0}, *ws_list[10] = {0}, *cur;
static int ws = 1, sw, sh, wx, wy;
static unsigned int ww, wh;
+static int is_ws_enabled[10] = {0}; /* +1 the amount of ws */
static Display *d;
static XButtonEvent mouse;
@@ -212,24 +215,69 @@ void win_next() {
}
void ws_go(const Arg arg) {
- int tmp = ws;
-
- if (arg.i == ws) return;
+ int i;
ws_save(ws);
- ws_sel(arg.i);
- for win XMapWindow(d, c->w);
-
- ws_sel(tmp);
-
- for win XUnmapWindow(d, c->w);
+ for (i = 1; i <= 9; i++) {
+ if (i != arg.i) {
+ ws_sel(i);
+ if (list) for win XUnmapWindow(d, c->w);
+ is_ws_enabled[i] = 0;
+ }
+ }
ws_sel(arg.i);
+ if (list) for win XMapWindow(d, c->w);
if (list) win_focus(list); else cur = 0;
}
+void
+ws_toggle(const Arg arg)
+{
+ int i, tmp = -1;
+
+ if (arg.i == ws) {
+ for (i = 1; i <= 9; i++) {
+ if (is_ws_enabled[i] && i != ws) {
+ tmp = i;
+ break;
+ }
+ }
+
+ if (tmp > 0)
+ ws_sel(tmp);
+ else
+ return;
+ }
+
+ tmp = ws;
+
+ ws_sel(arg.i);
+ if (is_ws_enabled[arg.i]) {
+ is_ws_enabled[arg.i] = 0;
+ if (list) for win XUnmapWindow(d, c->w);
+ } else {
+ is_ws_enabled[arg.i] = 1;
+ if (list) for win XMapWindow(d, c->w);
+ }
+ ws_sel(tmp);
+}
+
+void
+ws_toggle_all(const Arg arg)
+{
+ int i, tmp = ws;
+ for (i = 1; i <= 6; i++) {
+ ws_sel(i);
+ if (list) for win XMapWindow(d, c->w);
+ is_ws_enabled[i] = 1;
+ }
+ ws_sel(tmp);
+}
+
+
void configure_request(XEvent *e) {
XConfigureRequestEvent *ev = &e->xconfigurerequest;
Only in b/: sowm.o