sowm: more broken (for now)

This commit is contained in:
Dylan Araps 2019-10-18 19:55:26 +03:00
parent ef61316b5f
commit d1e8ee5e67
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 20 additions and 20 deletions

View File

@ -15,7 +15,7 @@ const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
static struct key keys[] = { static struct key keys[] = {
{MOD, XK_q, win_kill, {0}}, {MOD, XK_q, win_kill, {0}},
{MOD, XK_c, win_center, {0}}, {MOD, XK_c, win_center, {.w = 0}},
{MOD, XK_f, win_fs, {0}}, {MOD, XK_f, win_fs, {0}},
{Mod1Mask, XK_Tab, win_next, {0}}, {Mod1Mask, XK_Tab, win_next, {0}},

38
sowm.c
View File

@ -66,25 +66,23 @@ 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 *t=0, *c=list; t!=list->prev; t=c, c=c->next)
#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]
#define win_size(W, gx, gy, gw, gh) \ #define win_size(W, gx, gy, gw, gh) \
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) { void win_focus(Window w) {
XSetInputFocus(d, w, RevertToParent, CurrentTime); if (list) for win if (c->w == w) {
cur = c;
for win if (c->w == w) cur = c; XSetInputFocus(d, w, RevertToParent, CurrentTime);
}
} }
void notify_destroy(XEvent *e) { void notify_destroy(XEvent *e) {
for win if (c->w == e->xdestroywindow.window) win_del(c); if (list) for win if (c->w == e->xdestroywindow.window) win_del(c);
if (list) win_focus(list->w);
} }
void notify_enter(XEvent *e) { void notify_enter(XEvent *e) {
@ -125,7 +123,7 @@ void button_press(XEvent *e) {
} }
void button_release() { void button_release() {
for win if (c->w == mouse.subwindow) c->f = 0; if (list) for win if (c->w == mouse.subwindow) c->f = 0;
mouse.subwindow = 0; mouse.subwindow = 0;
} }
@ -148,15 +146,15 @@ void win_add(Window w) {
list = c; list = c;
list->prev = list->next = list; list->prev = list->next = list;
} }
ws_save(ws);
} }
void win_del(client *c) { void win_del(client *c) {
struct client **head = &list; if (list || !c) return;
if (list == c) list = c->next;
if (!*head || !c) return; if (c->next) c->next->prev = c->prev;
if (*head == c) *head = c->next; if (c->prev) c->prev->next = c->next;
if (c->next) c->next->prev = c->prev;
if (c->prev) c->prev->next = c->next;
free(c); free(c);
ws_save(ws); ws_save(ws);
@ -198,10 +196,12 @@ void win_to_ws(const Arg arg) {
XUnmapWindow(d, cur->w); XUnmapWindow(d, cur->w);
ws_save(tmp); ws_save(tmp);
if (list) win_focus(list->w); if (list) win_focus(list->prev->w);
} }
void win_next() { void win_next() {
if (!list) return;
win_focus(cur->next->w); win_focus(cur->next->w);
XRaiseWindow(d, cur->next->w); XRaiseWindow(d, cur->next->w);
} }
@ -222,7 +222,7 @@ void ws_go(const Arg arg) {
ws_sel(arg.i); ws_sel(arg.i);
if (list) win_focus(list->w); if (list) win_focus(list->prev->w);
} }
void configure_request(XEvent *e) { void configure_request(XEvent *e) {