mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 09:30:24 -07:00
docs: update
This commit is contained in:
parent
d1e8ee5e67
commit
0fa485eb7b
@ -4,7 +4,7 @@ Note: Stick to tagged releases as master isn't currently in a stable state*!*
|
|||||||
|
|
||||||
<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>
|
<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 (*230~ sloc / 24kb compiled!*).
|
An itsy bitsy floating window manager (*240~ sloc / 24kb compiled!*).
|
||||||
|
|
||||||
- Floating only.
|
- Floating only.
|
||||||
- Fullscreen toggle.
|
- Fullscreen toggle.
|
||||||
|
121
sowm.c
121
sowm.c
@ -36,8 +36,8 @@ static void notify_enter(XEvent *e);
|
|||||||
static void notify_motion(XEvent *e);
|
static void notify_motion(XEvent *e);
|
||||||
static void run(const Arg arg);
|
static void run(const Arg arg);
|
||||||
static void win_add(Window w);
|
static void win_add(Window w);
|
||||||
static void win_center();
|
static void win_center(const Arg arg);
|
||||||
static void win_del(client *c);
|
static void win_del(Window w);
|
||||||
static void win_fs();
|
static void win_fs();
|
||||||
static void win_kill();
|
static void win_kill();
|
||||||
static void win_next();
|
static void win_next();
|
||||||
@ -45,12 +45,12 @@ static void win_to_ws(const Arg arg);
|
|||||||
static void ws_go(const Arg arg);
|
static void ws_go(const Arg arg);
|
||||||
static int xerror() { return 0;}
|
static int xerror() { return 0;}
|
||||||
|
|
||||||
static client *list = 0, *ws_list[10] = {0}, *cur = {0};
|
static client *list = {0}, *ws_list[10] = {0};
|
||||||
static int ws = 1, sw, sh, wx, wy;
|
static int ws = 1, sw, sh, wx, wy;
|
||||||
static unsigned int ww, wh;
|
static unsigned int ww, wh;
|
||||||
|
|
||||||
static Display *d;
|
static Display *d;
|
||||||
static Window root;
|
static Window root, cur;
|
||||||
static XButtonEvent mouse;
|
static XButtonEvent mouse;
|
||||||
|
|
||||||
static void (*events[LASTEvent])(XEvent *e) = {
|
static void (*events[LASTEvent])(XEvent *e) = {
|
||||||
@ -66,7 +66,8 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define win (client *t=0, *c=list; t!=list->prev; t=c, c=c->next)
|
#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_save(W) ws_list[W] = list
|
||||||
#define ws_sel(W) list = ws_list[ws = W]
|
#define ws_sel(W) list = ws_list[ws = W]
|
||||||
|
|
||||||
@ -74,15 +75,15 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
||||||
&(unsigned int){0}, &(unsigned int){0})
|
&(unsigned int){0}, &(unsigned int){0})
|
||||||
|
|
||||||
void win_focus(Window w) {
|
Window win_current() {
|
||||||
if (list) for win if (c->w == w) {
|
XGetInputFocus(d, &cur, &(int){1});
|
||||||
cur = c;
|
return cur;
|
||||||
XSetInputFocus(d, w, RevertToParent, CurrentTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify_destroy(XEvent *e) {
|
void notify_destroy(XEvent *e) {
|
||||||
if (list) for win if (c->w == e->xdestroywindow.window) win_del(c);
|
win_del(e->xdestroywindow.window);
|
||||||
|
|
||||||
|
if (list) win_focus(win_current() == root ? list->w : cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify_enter(XEvent *e) {
|
void notify_enter(XEvent *e) {
|
||||||
@ -123,87 +124,114 @@ void button_press(XEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void button_release() {
|
void button_release() {
|
||||||
if (list) for win if (c->w == mouse.subwindow) c->f = 0;
|
for win if (c->w == mouse.subwindow) c->f = 0;
|
||||||
|
|
||||||
mouse.subwindow = 0;
|
mouse.subwindow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_add(Window w) {
|
void win_add(Window w) {
|
||||||
client *c;
|
client *c, *t;
|
||||||
|
|
||||||
if (!(c = (client *)calloc(1, sizeof(client))))
|
if (!(c = (client *)calloc(1, sizeof(client))))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
if (!list) {
|
||||||
|
c->next = c->prev = 0;
|
||||||
c->w = w;
|
c->w = w;
|
||||||
|
list = c;
|
||||||
if (list) {
|
|
||||||
list->prev->next = c;
|
|
||||||
c->prev = list->prev;
|
|
||||||
list->prev = c;
|
|
||||||
c->next = list;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
list = c;
|
for (t=list;t->next;t=t->next);
|
||||||
list->prev = list->next = list;
|
|
||||||
|
c->next = 0;
|
||||||
|
c->prev = t;
|
||||||
|
c->w = w;
|
||||||
|
t->next = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_save(ws);
|
ws_save(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_del(client *c) {
|
void win_del(Window w) {
|
||||||
if (list || !c) return;
|
for win if (c->w == w) {
|
||||||
if (list == c) list = c->next;
|
if (!c->prev && !c->next) {
|
||||||
if (c->next) c->next->prev = c->prev;
|
free(list);
|
||||||
if (c->prev) c->prev->next = c->next;
|
list = 0;
|
||||||
|
ws_save(ws);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!c->prev) {
|
||||||
|
list = c->next;
|
||||||
|
c->next->prev = 0;
|
||||||
|
|
||||||
|
} else if (!c->next) {
|
||||||
|
c->prev->next = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
c->prev->next = c->next;
|
||||||
|
c->next->prev = c->prev;
|
||||||
|
}
|
||||||
|
|
||||||
free(c);
|
free(c);
|
||||||
ws_save(ws);
|
ws_save(ws);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_kill() {
|
void win_kill() {
|
||||||
if (cur) XKillClient(d, cur->w);
|
if (win_current() ^ root) XKillClient(d, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_center() {
|
void win_center(const Arg arg) {
|
||||||
if (!cur) return;
|
Window w = arg.w ? arg.w : win_current();
|
||||||
|
|
||||||
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
win_size(w, &(int){0}, &(int){0}, &ww, &wh);
|
||||||
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
|
|
||||||
|
XMoveWindow(d, w, (sw - ww) / 2, (sh - wh) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_fs() {
|
void win_fs() {
|
||||||
if (!cur) return;
|
win_current();
|
||||||
|
|
||||||
if ((cur->f = cur->f == 0 ? 1 : 0)) {
|
for win if (c->w == cur) {
|
||||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
if ((c->f = c->f == 0 ? 1 : 0)) {
|
||||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
win_size(cur, &c->wx, &c->wy, &c->ww, &c->wh);
|
||||||
|
XMoveResizeWindow(d, cur, 0, 0, sw, sh);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
XMoveResizeWindow(d, cur, c->wx, c->wy, c->ww, c->wh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_to_ws(const Arg arg) {
|
void win_to_ws(const Arg arg) {
|
||||||
int tmp = ws;
|
int tmp = ws;
|
||||||
|
win_current();
|
||||||
|
|
||||||
if (arg.i == tmp) return;
|
if (arg.i == tmp) return;
|
||||||
|
|
||||||
ws_sel(arg.i);
|
ws_sel(arg.i);
|
||||||
win_add(cur->w);
|
win_add(cur);
|
||||||
ws_save(arg.i);
|
ws_save(arg.i);
|
||||||
|
|
||||||
ws_sel(tmp);
|
ws_sel(tmp);
|
||||||
win_del(cur);
|
win_del(cur);
|
||||||
XUnmapWindow(d, cur->w);
|
XUnmapWindow(d, cur);
|
||||||
ws_save(tmp);
|
ws_save(tmp);
|
||||||
|
|
||||||
if (list) win_focus(list->prev->w);
|
if (list) win_focus(list->w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_next() {
|
void win_next() {
|
||||||
if (!list) return;
|
win_current();
|
||||||
|
|
||||||
win_focus(cur->next->w);
|
for win if (c->w == cur) {
|
||||||
XRaiseWindow(d, cur->next->w);
|
c = c->next ? c->next : list;
|
||||||
|
|
||||||
|
win_focus(c->w);
|
||||||
|
XRaiseWindow(d, c->w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ws_go(const Arg arg) {
|
void ws_go(const Arg arg) {
|
||||||
@ -222,7 +250,7 @@ void ws_go(const Arg arg) {
|
|||||||
|
|
||||||
ws_sel(arg.i);
|
ws_sel(arg.i);
|
||||||
|
|
||||||
if (list) win_focus(list->prev->w);
|
if (list) win_focus(list->w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void configure_request(XEvent *e) {
|
void configure_request(XEvent *e) {
|
||||||
@ -244,12 +272,11 @@ void map_request(XEvent *e) {
|
|||||||
XSelectInput(d, w, StructureNotifyMask|EnterWindowMask);
|
XSelectInput(d, w, StructureNotifyMask|EnterWindowMask);
|
||||||
win_size(w, &wx, &wy, &ww, &wh);
|
win_size(w, &wx, &wy, &ww, &wh);
|
||||||
|
|
||||||
win_add(w);
|
if (wx == 0 && wy == 0) win_center((Arg){.i = w});
|
||||||
win_focus(w);
|
|
||||||
|
|
||||||
if (wx == 0 && wy == 0) win_center();
|
|
||||||
|
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
|
win_focus(w);
|
||||||
|
win_add(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const Arg arg) {
|
void run(const Arg arg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user