mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-07-25 17:21:56 -07:00
Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e4965417f7 | ||
|
bc9a9b14a5 | ||
|
421f79c47b | ||
|
cb03ac9664 | ||
|
5b012c10be | ||
|
35b12c7969 | ||
|
e9df9ac570 | ||
|
f14acc3b68 | ||
|
117b04d4a6 | ||
|
0d4af0e4fa | ||
|
43c7194066 | ||
|
144c153844 | ||
|
2d1e5c2654 | ||
|
d70ecee07d | ||
|
fa3c276ce6 | ||
|
7316c149b8 | ||
|
589bb768d9 | ||
|
84119dd331 | ||
|
5c075a359a | ||
|
b48c9b6add | ||
|
a4293a63a7 | ||
|
e60a3bcb30 | ||
|
4ed0c0919f | ||
|
d6b7a98586 | ||
|
3f66256197 | ||
|
7fe47aefc1 | ||
|
0fa485eb7b | ||
|
d1e8ee5e67 | ||
|
ef61316b5f | ||
|
116ebcfc74 | ||
|
493302d38b | ||
|
f10cec8509 | ||
|
02b10e8585 | ||
|
8917b6ddb2 | ||
|
522defba1e | ||
|
e0bd38091a | ||
|
68257b329d | ||
|
009f1cd017 |
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
|
||||
CFLAGS+= -std=c99 -Wall -Wextra -pedantic
|
||||
LDADD+= -lX11
|
||||
LDFLAGS=
|
||||
PREFIX?= /usr
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
<a href="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg" width="43%" align="right"></a>
|
||||
|
||||
An itsy bitsy floating window manager (*240~ sloc / 24kb compiled!*).
|
||||
An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
|
||||
|
||||
- Floating only.
|
||||
- Fullscreen toggle.
|
||||
|
@@ -15,7 +15,7 @@ const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
|
||||
|
||||
static struct key keys[] = {
|
||||
{MOD, XK_q, win_kill, {0}},
|
||||
{MOD, XK_c, win_center, {.w = 0}},
|
||||
{MOD, XK_c, win_center, {0}},
|
||||
{MOD, XK_f, win_fs, {0}},
|
||||
{Mod1Mask, XK_Tab, win_next, {0}},
|
||||
|
||||
|
132
patches/sowm-almost-tags-0.3.diff
Normal file
132
patches/sowm-almost-tags-0.3.diff
Normal file
@@ -0,0 +1,132 @@
|
||||
diff -up a/config.def.h b/config.def.h
|
||||
--- a/config.def.h 2019-10-17 19:48:23.000000000 +0300
|
||||
+++ b/config.def.h 2019-10-20 15:12:05.510971991 +0300
|
||||
@@ -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
|
||||
Common subdirectories: a/patches and b/patches
|
||||
Only in b/: sowm-almost-tags-0.3.diff
|
||||
diff -up a/sowm.c b/sowm.c
|
||||
--- a/sowm.c 2019-10-17 19:48:23.000000000 +0300
|
||||
+++ b/sowm.c 2019-10-18 19:02:41.959290919 +0300
|
||||
@@ -43,11 +43,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};
|
||||
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 Window root, cur;
|
||||
@@ -235,24 +238,68 @@ 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);
|
||||
|
||||
- if (list) for win XMapWindow(d, c->w);
|
||||
-
|
||||
- ws_sel(tmp);
|
||||
-
|
||||
- if (list) 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->w);
|
||||
}
|
||||
|
||||
+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;
|
||||
|
@@ -1,51 +1,23 @@
|
||||
diff --git a/patches/sowm-normal-kill.patch b/patches/sowm-normal-kill.patch
|
||||
index 4b11cd4..e69de29 100644
|
||||
--- a/patches/sowm-normal-kill.patch
|
||||
+++ b/patches/sowm-normal-kill.patch
|
||||
@@ -1,23 +0,0 @@
|
||||
-diff --git a/sowm.c b/sowm.c
|
||||
-index 0d74d4b..ff70968 100644
|
||||
---- a/sowm.c
|
||||
-+++ b/sowm.c
|
||||
-@@ -326,7 +326,17 @@ void win_del(Window w) {
|
||||
- "Shoot first and don't ask questions later?.."
|
||||
- */
|
||||
- void win_kill() {
|
||||
-- if (win_current() != root) XKillClient(d, cur);
|
||||
-+ if (win_current() == root) return;
|
||||
-+
|
||||
-+ XEvent ev = { .type = ClientMessage };
|
||||
-+
|
||||
-+ ev.xclient.window = cur;
|
||||
-+ ev.xclient.format = 32;
|
||||
-+ ev.xclient.message_type = XInternAtom(d, "WM_PROTOCOLS", True);
|
||||
-+ ev.xclient.data.l[0] = XInternAtom(d, "WM_DELETE_WINDOW", True);
|
||||
-+ ev.xclient.data.l[1] = CurrentTime;
|
||||
-+
|
||||
-+ XSendEvent(d, cur, False, NoEventMask, &ev);
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
diff --git a/sowm.c b/sowm.c
|
||||
index 126aca0..cd8af6f 100644
|
||||
index d1b4c2a..49d8af2 100644
|
||||
--- a/sowm.c
|
||||
+++ b/sowm.c
|
||||
@@ -180,7 +180,17 @@ void win_del(Window w) {
|
||||
@@ -165,7 +165,17 @@ void win_del(Window w) {
|
||||
}
|
||||
|
||||
void win_kill() {
|
||||
- if (win_current() ^ root) XKillClient(d, cur);
|
||||
+ if (win_current() == root) return;
|
||||
- if (cur) XKillClient(d, cur->w);
|
||||
+ if (!cur) return;
|
||||
+
|
||||
+ XEvent ev = { .type = ClientMessage };
|
||||
+
|
||||
+ ev.xclient.window = cur;
|
||||
+ ev.xclient.window = cur->w;
|
||||
+ ev.xclient.format = 32;
|
||||
+ ev.xclient.message_type = XInternAtom(d, "WM_PROTOCOLS", True);
|
||||
+ ev.xclient.data.l[0] = XInternAtom(d, "WM_DELETE_WINDOW", True);
|
||||
+ ev.xclient.data.l[1] = CurrentTime;
|
||||
+
|
||||
+ XSendEvent(d, cur, False, NoEventMask, &ev);
|
||||
+ XSendEvent(d, cur->w, False, NoEventMask, &ev);
|
||||
}
|
||||
|
||||
void win_center(const Arg arg) {
|
||||
void win_center() {
|
||||
|
@@ -1,16 +1,16 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 3154a2f..243b744 100644
|
||||
index 8573837..738af94 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -1,5 +1,5 @@
|
||||
CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
|
||||
CFLAGS+= -std=c99 -Wall -Wextra -pedantic
|
||||
-LDADD+= -lX11
|
||||
+LDADD+= -lX11 -lXext
|
||||
LDFLAGS=
|
||||
PREFIX?= /usr
|
||||
BINDIR?= $(PREFIX)/bin
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 3cef34b..e7f1518 100644
|
||||
index aaaf38d..b25dc08 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -2,6 +2,7 @@
|
||||
@@ -22,18 +22,18 @@ index 3cef34b..e7f1518 100644
|
||||
const char* menu[] = {"dmenu_run", 0};
|
||||
const char* term[] = {"st", 0};
|
||||
diff --git a/sowm.c b/sowm.c
|
||||
index 126aca0..5c99c5c 100644
|
||||
index d1b4c2a..56bf509 100644
|
||||
--- a/sowm.c
|
||||
+++ b/sowm.c
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
+#include <X11/extensions/shape.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -41,6 +42,7 @@ static void win_del(Window w);
|
||||
@@ -43,6 +44,7 @@ static void win_del(Window w);
|
||||
static void win_fs();
|
||||
static void win_kill();
|
||||
static void win_next();
|
||||
@@ -51,15 +51,14 @@ index 126aca0..5c99c5c 100644
|
||||
}
|
||||
|
||||
void key_press(XEvent *e) {
|
||||
@@ -201,9 +206,44 @@ void win_fs() {
|
||||
@@ -185,6 +190,41 @@ void win_fs() {
|
||||
|
||||
} else
|
||||
XMoveResizeWindow(d, cur, c->wx, c->wy, c->ww, c->wh);
|
||||
} else
|
||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||
+
|
||||
+ win_round_corners(cur->w, cur->f ? 0 : ROUND_CORNERS);
|
||||
+}
|
||||
+
|
||||
+ win_round_corners(cur, c->f ? 0 : ROUND_CORNERS);
|
||||
}
|
||||
}
|
||||
|
||||
+void win_round_corners(Window w, int rad) {
|
||||
+ unsigned int ww, wh, dia = 2 * rad;
|
||||
+
|
||||
@@ -91,16 +90,23 @@ index 126aca0..5c99c5c 100644
|
||||
+ XShapeCombineMask(d, w, ShapeBounding, 0, 0, mask, ShapeSet);
|
||||
+ XFreePixmap(d, mask);
|
||||
+ XFreeGC(d, shape_gc);
|
||||
+}
|
||||
+
|
||||
void win_to_ws(const Arg arg) {
|
||||
int tmp = ws;
|
||||
win_current();
|
||||
@@ -275,6 +315,7 @@ void map_request(XEvent *e) {
|
||||
if (wx == 0 && wy == 0) win_center((Arg){.i = w});
|
||||
|
||||
XMapWindow(d, w);
|
||||
+ win_round_corners(w, ROUND_CORNERS);
|
||||
win_focus(w);
|
||||
win_add(w);
|
||||
}
|
||||
|
||||
void win_to_ws(const Arg arg) {
|
||||
@@ -241,6 +281,8 @@ void configure_request(XEvent *e) {
|
||||
.sibling = ev->above,
|
||||
.stack_mode = ev->detail
|
||||
});
|
||||
+
|
||||
+ win_round_corners(ev->window, ROUND_CORNERS);
|
||||
}
|
||||
|
||||
void map_request(XEvent *e) {
|
||||
@@ -253,6 +295,7 @@ void map_request(XEvent *e) {
|
||||
|
||||
if (wx + wy == 0) win_center();
|
||||
|
||||
+ win_round_corners(w, ROUND_CORNERS);
|
||||
XMapWindow(d, w);
|
||||
win_focus(list->prev);
|
||||
}
|
||||
|
160
sowm.c
160
sowm.c
@@ -3,6 +3,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -23,7 +24,8 @@ struct key {
|
||||
typedef struct client {
|
||||
struct client *next, *prev;
|
||||
int f, wx, wy;
|
||||
unsigned int w, ww, wh;
|
||||
unsigned int ww, wh;
|
||||
Window w;
|
||||
} client;
|
||||
|
||||
static void button_press(XEvent *e);
|
||||
@@ -36,7 +38,7 @@ static void notify_enter(XEvent *e);
|
||||
static void notify_motion(XEvent *e);
|
||||
static void run(const Arg arg);
|
||||
static void win_add(Window w);
|
||||
static void win_center(const Arg arg);
|
||||
static void win_center();
|
||||
static void win_del(Window w);
|
||||
static void win_fs();
|
||||
static void win_kill();
|
||||
@@ -45,12 +47,11 @@ static void win_to_ws(const Arg arg);
|
||||
static void ws_go(const Arg arg);
|
||||
static int xerror() { return 0;}
|
||||
|
||||
static client *list = {0}, *ws_list[10] = {0};
|
||||
static client *list = {0}, *ws_list[10] = {0}, *cur;
|
||||
static int ws = 1, sw, sh, wx, wy;
|
||||
static unsigned int ww, wh;
|
||||
|
||||
static Display *d;
|
||||
static Window root, cur;
|
||||
static XButtonEvent mouse;
|
||||
|
||||
static void (*events[LASTEvent])(XEvent *e) = {
|
||||
@@ -66,40 +67,39 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define win (client *c=list;c;c=c->next)
|
||||
#define win_focus(W) XSetInputFocus(d, W, RevertToParent, CurrentTime)
|
||||
#define ws_save(W) ws_list[W] = list
|
||||
#define ws_sel(W) list = ws_list[ws = W]
|
||||
#define win (client *t=0, *c=list; c && t!=list->prev; t=c, c=c->next)
|
||||
#define ws_save(W) ws_list[W] = list
|
||||
#define ws_sel(W) list = ws_list[ws = W]
|
||||
|
||||
#define win_size(W, gx, gy, gw, gh) \
|
||||
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
||||
&(unsigned int){0}, &(unsigned int){0})
|
||||
|
||||
Window win_current() {
|
||||
XGetInputFocus(d, &cur, (int[]){1});
|
||||
return cur;
|
||||
void win_focus(client *c) {
|
||||
cur = c;
|
||||
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
||||
}
|
||||
|
||||
void notify_destroy(XEvent *e) {
|
||||
win_del(e->xdestroywindow.window);
|
||||
|
||||
if (list) win_focus(win_current() == root ? list->w : cur);
|
||||
if (list) win_focus(list->prev);
|
||||
}
|
||||
|
||||
void notify_enter(XEvent *e) {
|
||||
while(XCheckTypedEvent(d, EnterNotify, e));
|
||||
|
||||
win_focus(e->xcrossing.window);
|
||||
for win if (c->w == e->xcrossing.window) win_focus(c);
|
||||
}
|
||||
|
||||
void notify_motion(XEvent *e) {
|
||||
if (mouse.subwindow == 0) return;
|
||||
if (!mouse.subwindow) return;
|
||||
|
||||
while(XCheckTypedEvent(d, MotionNotify, e));
|
||||
|
||||
int xd = e->xbutton.x_root - mouse.x_root;
|
||||
int yd = e->xbutton.y_root - mouse.y_root;
|
||||
|
||||
while(XCheckTypedEvent(d, MotionNotify, e));
|
||||
|
||||
XMoveResizeWindow(d, mouse.subwindow,
|
||||
wx + (mouse.button == 1 ? xd : 0),
|
||||
wy + (mouse.button == 1 ? yd : 0),
|
||||
@@ -108,15 +108,15 @@ void notify_motion(XEvent *e) {
|
||||
}
|
||||
|
||||
void key_press(XEvent *e) {
|
||||
KeySym keysym = XKeycodeToKeysym(d, e->xkey.keycode, 0);
|
||||
KeySym keysym = XkbKeycodeToKeysym(d, e->xkey.keycode, 0, 0);
|
||||
|
||||
for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
|
||||
if (keys[i].keysym == keysym && keys[i].mod == e->xkey.state)
|
||||
if (keys[i].mod == e->xkey.state && keys[i].keysym == keysym)
|
||||
keys[i].function(keys[i].arg);
|
||||
}
|
||||
|
||||
void button_press(XEvent *e) {
|
||||
if (e->xbutton.subwindow == 0) return;
|
||||
if (!e->xbutton.subwindow) return;
|
||||
|
||||
win_size(e->xbutton.subwindow, &wx, &wy, &ww, &wh);
|
||||
XRaiseWindow(d, e->xbutton.subwindow);
|
||||
@@ -124,114 +124,91 @@ void button_press(XEvent *e) {
|
||||
}
|
||||
|
||||
void button_release() {
|
||||
for win if (c->w == mouse.subwindow) c->f = 0;
|
||||
|
||||
mouse.subwindow = 0;
|
||||
cur->f = mouse.subwindow = 0;
|
||||
}
|
||||
|
||||
void win_add(Window w) {
|
||||
client *c, *t;
|
||||
client *c;
|
||||
|
||||
if (!(c = (client *)calloc(1, sizeof(client))))
|
||||
if (!(c = (client *) calloc(1, sizeof(client))))
|
||||
exit(1);
|
||||
|
||||
if (!list) {
|
||||
c->next = c->prev = 0;
|
||||
c->w = w;
|
||||
list = c;
|
||||
c->w = w;
|
||||
|
||||
if (list) {
|
||||
list->prev->next = c;
|
||||
c->prev = list->prev;
|
||||
list->prev = c;
|
||||
c->next = list;
|
||||
|
||||
} else {
|
||||
for (t=list;t->next;t=t->next);
|
||||
|
||||
c->next = 0;
|
||||
c->prev = t;
|
||||
c->w = w;
|
||||
t->next = c;
|
||||
list = c;
|
||||
list->prev = list->next = list;
|
||||
}
|
||||
|
||||
ws_save(ws);
|
||||
}
|
||||
|
||||
void win_del(Window w) {
|
||||
for win if (c->w == w) {
|
||||
if (!c->prev && !c->next) {
|
||||
free(list);
|
||||
list = 0;
|
||||
ws_save(ws);
|
||||
return;
|
||||
}
|
||||
client *x = 0;
|
||||
|
||||
if (!c->prev) {
|
||||
list = c->next;
|
||||
c->next->prev = 0;
|
||||
for win if (c->w == w) x = c;
|
||||
|
||||
} else if (!c->next) {
|
||||
c->prev->next = 0;
|
||||
if (!list || !x) return;
|
||||
if (x->prev == x) list = 0;
|
||||
if (list == x) list = x->next;
|
||||
if (x->next) x->next->prev = x->prev;
|
||||
if (x->prev) x->prev->next = x->next;
|
||||
|
||||
} else {
|
||||
c->prev->next = c->next;
|
||||
c->next->prev = c->prev;
|
||||
}
|
||||
|
||||
free(c);
|
||||
ws_save(ws);
|
||||
return;
|
||||
}
|
||||
free(x);
|
||||
ws_save(ws);
|
||||
}
|
||||
|
||||
void win_kill() {
|
||||
if (win_current() ^ root) XKillClient(d, cur);
|
||||
if (cur) XKillClient(d, cur->w);
|
||||
}
|
||||
|
||||
void win_center(const Arg arg) {
|
||||
Window w = arg.w ? arg.w : win_current();
|
||||
void win_center() {
|
||||
if (!cur) return;
|
||||
|
||||
win_size(w, &(int){0}, &(int){0}, &ww, &wh);
|
||||
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
||||
|
||||
XMoveWindow(d, w, (sw - ww) / 2, (sh - wh) / 2);
|
||||
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
|
||||
}
|
||||
|
||||
void win_fs() {
|
||||
win_current();
|
||||
if (!cur) return;
|
||||
|
||||
for win if (c->w == cur) {
|
||||
if ((c->f = c->f == 0 ? 1 : 0)) {
|
||||
win_size(cur, &c->wx, &c->wy, &c->ww, &c->wh);
|
||||
XMoveResizeWindow(d, cur, 0, 0, sw, sh);
|
||||
if ((cur->f = cur->f ? 0 : 1)) {
|
||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
||||
|
||||
} else
|
||||
XMoveResizeWindow(d, cur, c->wx, c->wy, c->ww, c->wh);
|
||||
}
|
||||
} else
|
||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||
}
|
||||
|
||||
void win_to_ws(const Arg arg) {
|
||||
int tmp = ws;
|
||||
win_current();
|
||||
|
||||
if (arg.i == tmp) return;
|
||||
|
||||
ws_sel(arg.i);
|
||||
win_add(cur);
|
||||
win_add(cur->w);
|
||||
ws_save(arg.i);
|
||||
|
||||
ws_sel(tmp);
|
||||
win_del(cur);
|
||||
XUnmapWindow(d, cur);
|
||||
win_del(cur->w);
|
||||
XUnmapWindow(d, cur->w);
|
||||
ws_save(tmp);
|
||||
|
||||
if (list) win_focus(list->w);
|
||||
if (list) win_focus(list);
|
||||
}
|
||||
|
||||
void win_next() {
|
||||
win_current();
|
||||
if (!cur) return;
|
||||
|
||||
for win if (c->w == cur) {
|
||||
c = c->next ? c->next : list;
|
||||
|
||||
win_focus(c->w);
|
||||
XRaiseWindow(d, c->w);
|
||||
return;
|
||||
}
|
||||
XRaiseWindow(d, cur->next->w);
|
||||
win_focus(cur->next);
|
||||
}
|
||||
|
||||
void ws_go(const Arg arg) {
|
||||
@@ -242,15 +219,15 @@ void ws_go(const Arg arg) {
|
||||
ws_save(ws);
|
||||
ws_sel(arg.i);
|
||||
|
||||
if (list) for win XMapWindow(d, c->w);
|
||||
for win XMapWindow(d, c->w);
|
||||
|
||||
ws_sel(tmp);
|
||||
|
||||
if (list) for win XUnmapWindow(d, c->w);
|
||||
for win XUnmapWindow(d, c->w);
|
||||
|
||||
ws_sel(arg.i);
|
||||
|
||||
if (list) win_focus(list->w);
|
||||
if (list) win_focus(list); else cur = 0;
|
||||
}
|
||||
|
||||
void configure_request(XEvent *e) {
|
||||
@@ -271,12 +248,13 @@ void map_request(XEvent *e) {
|
||||
|
||||
XSelectInput(d, w, StructureNotifyMask|EnterWindowMask);
|
||||
win_size(w, &wx, &wy, &ww, &wh);
|
||||
win_add(w);
|
||||
cur = list->prev;
|
||||
|
||||
if (wx == 0 && wy == 0) win_center((Arg){.i = w});
|
||||
if (wx + wy == 0) win_center();
|
||||
|
||||
XMapWindow(d, w);
|
||||
win_focus(w);
|
||||
win_add(w);
|
||||
win_focus(list->prev);
|
||||
}
|
||||
|
||||
void run(const Arg arg) {
|
||||
@@ -295,10 +273,10 @@ int main(void) {
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
XSetErrorHandler(xerror);
|
||||
|
||||
int s = DefaultScreen(d);
|
||||
root = RootWindow(d, s);
|
||||
sw = XDisplayWidth(d, s);
|
||||
sh = XDisplayHeight(d, s);
|
||||
int s = DefaultScreen(d);
|
||||
Window root = RootWindow(d, s);
|
||||
sw = XDisplayWidth(d, s);
|
||||
sh = XDisplayHeight(d, s);
|
||||
|
||||
XSelectInput(d, root, SubstructureRedirectMask);
|
||||
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
||||
|
Reference in New Issue
Block a user