mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 09:30:24 -07:00
sowm: we circular now (we also a little broken too)
This commit is contained in:
parent
116ebcfc74
commit
ef61316b5f
66
sowm.c
66
sowm.c
@ -37,7 +37,7 @@ 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();
|
||||||
static void win_del(Window w);
|
static void win_del(client *c);
|
||||||
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,7 +45,7 @@ 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}, *cur = {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;
|
||||||
|
|
||||||
@ -66,7 +66,8 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define win (client *c=list;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]
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ void win_focus(Window w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void notify_destroy(XEvent *e) {
|
void notify_destroy(XEvent *e) {
|
||||||
win_del(e->xdestroywindow.window);
|
for win if (c->w == e->xdestroywindow.window) win_del(c);
|
||||||
|
|
||||||
if (list) win_focus(list->w);
|
if (list) win_focus(list->w);
|
||||||
}
|
}
|
||||||
@ -130,7 +131,7 @@ void button_release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void win_add(Window w) {
|
void win_add(Window w) {
|
||||||
client *c, *t = list;
|
client *c;
|
||||||
|
|
||||||
if (!(c = (client *) calloc(1, sizeof(client))))
|
if (!(c = (client *) calloc(1, sizeof(client))))
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -138,42 +139,27 @@ void win_add(Window w) {
|
|||||||
c->w = w;
|
c->w = w;
|
||||||
|
|
||||||
if (list) {
|
if (list) {
|
||||||
while (t->next) t = t->next;
|
list->prev->next = c;
|
||||||
|
c->prev = list->prev;
|
||||||
|
list->prev = c;
|
||||||
|
c->next = list;
|
||||||
|
|
||||||
t->next = c;
|
} else {
|
||||||
c->prev = t;
|
|
||||||
|
|
||||||
} else
|
|
||||||
list = c;
|
list = c;
|
||||||
|
list->prev = list->next = list;
|
||||||
ws_save(ws);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_del(Window w) {
|
void win_del(client *c) {
|
||||||
for win if (c->w == w) {
|
struct client **head = &list;
|
||||||
if (!c->prev && !c->next) {
|
|
||||||
free(list);
|
|
||||||
list = 0;
|
|
||||||
ws_save(ws);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!c->prev) {
|
if (!*head || !c) return;
|
||||||
list = c->next;
|
if (*head == c) *head = c->next;
|
||||||
c->next->prev = 0;
|
if (c->next) c->next->prev = c->prev;
|
||||||
|
if (c->prev) c->prev->next = c->next;
|
||||||
|
|
||||||
} else if (!c->next) {
|
free(c);
|
||||||
c->prev->next = 0;
|
ws_save(ws);
|
||||||
|
|
||||||
} else {
|
|
||||||
c->prev->next = c->next;
|
|
||||||
c->next->prev = c->prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(c);
|
|
||||||
ws_save(ws);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_kill() {
|
void win_kill() {
|
||||||
@ -208,7 +194,7 @@ void win_to_ws(const Arg arg) {
|
|||||||
ws_save(arg.i);
|
ws_save(arg.i);
|
||||||
|
|
||||||
ws_sel(tmp);
|
ws_sel(tmp);
|
||||||
win_del(cur->w);
|
win_del(cur);
|
||||||
XUnmapWindow(d, cur->w);
|
XUnmapWindow(d, cur->w);
|
||||||
ws_save(tmp);
|
ws_save(tmp);
|
||||||
|
|
||||||
@ -216,12 +202,8 @@ void win_to_ws(const Arg arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void win_next() {
|
void win_next() {
|
||||||
if (!list) return;
|
win_focus(cur->next->w);
|
||||||
|
XRaiseWindow(d, cur->next->w);
|
||||||
client *c = cur->next ? cur->next : list;
|
|
||||||
|
|
||||||
win_focus(c->w);
|
|
||||||
XRaiseWindow(d, c->w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ws_go(const Arg arg) {
|
void ws_go(const Arg arg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user