mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 09:30:24 -07:00
sowm: fix crashes with cur
This commit is contained in:
parent
68257b329d
commit
e0bd38091a
15
sowm.c
15
sowm.c
@ -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;
|
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;
|
||||||
|
|
||||||
@ -180,10 +180,12 @@ void win_del(Window w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void win_kill() {
|
void win_kill() {
|
||||||
if (cur->w ^ root) XKillClient(d, cur->w);
|
if (cur) XKillClient(d, cur->w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_center(const Arg arg) {
|
void win_center(const Arg arg) {
|
||||||
|
if (!cur) return;
|
||||||
|
|
||||||
Window w = arg.w ? arg.w : cur->w;
|
Window w = arg.w ? arg.w : cur->w;
|
||||||
|
|
||||||
win_size(w, &(int){0}, &(int){0}, &ww, &wh);
|
win_size(w, &(int){0}, &(int){0}, &ww, &wh);
|
||||||
@ -192,6 +194,8 @@ void win_center(const Arg arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void win_fs() {
|
void win_fs() {
|
||||||
|
if (!cur) return;
|
||||||
|
|
||||||
if ((cur->f = cur->f == 0 ? 1 : 0)) {
|
if ((cur->f = cur->f == 0 ? 1 : 0)) {
|
||||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
||||||
@ -218,6 +222,8 @@ void win_to_ws(const Arg arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void win_next() {
|
void win_next() {
|
||||||
|
if (!list) return;
|
||||||
|
|
||||||
client *c = cur->next ? cur->next : list;
|
client *c = cur->next ? cur->next : list;
|
||||||
|
|
||||||
win_focus(c->w);
|
win_focus(c->w);
|
||||||
@ -260,13 +266,14 @@ void map_request(XEvent *e) {
|
|||||||
Window w = e->xmaprequest.window;
|
Window w = e->xmaprequest.window;
|
||||||
|
|
||||||
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);
|
||||||
|
win_focus(w);
|
||||||
|
|
||||||
if (wx == 0 && wy == 0) win_center((Arg){.i = w});
|
if (wx == 0 && wy == 0) win_center((Arg){.i = w});
|
||||||
|
|
||||||
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