mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 09:30:24 -07:00
clean up
This commit is contained in:
parent
e53f49cc2d
commit
f5f3c4aa06
30
sowm.c
30
sowm.c
@ -97,21 +97,19 @@ void win_add(Window w) {
|
||||
exit(1);
|
||||
|
||||
if (head == NULL) {
|
||||
c->next = NULL;
|
||||
c->prev = NULL;
|
||||
c->win = w;
|
||||
head = c;
|
||||
}
|
||||
|
||||
else {
|
||||
for(t=head;t->next;t=t->next);
|
||||
for (t=head;t->next;t=t->next);
|
||||
|
||||
c->next = NULL;
|
||||
c->prev = t;
|
||||
c->win = w;
|
||||
t->next = c;
|
||||
}
|
||||
|
||||
c->next = NULL;
|
||||
c->win = w;
|
||||
cur = c;
|
||||
}
|
||||
|
||||
@ -190,10 +188,10 @@ void destroy_notify(XEvent *e) {
|
||||
|
||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||
|
||||
for(c=head;c;c=c->next)
|
||||
for (c=head;c;c=c->next)
|
||||
if(ev->window == c->win) i++;
|
||||
|
||||
if(i == 0)
|
||||
if (i == 0)
|
||||
return;
|
||||
|
||||
win_del(ev->window);
|
||||
@ -228,11 +226,10 @@ void key_grab() {
|
||||
int i;
|
||||
KeyCode code;
|
||||
|
||||
for(i=0;i<TABLENGTH(keys);++i) {
|
||||
for(i=0;i<TABLENGTH(keys);++i)
|
||||
if ((code = XKeysymToKeycode(dis, keys[i].keysym)))
|
||||
XGrabKey(dis, code, keys[i].mod, root,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
|
||||
void key_press(XEvent *e) {
|
||||
@ -241,10 +238,9 @@ void key_press(XEvent *e) {
|
||||
KeySym keysym = XkbKeycodeToKeysym(dis,ke.keycode,0,0);
|
||||
|
||||
for(i=0;i<TABLENGTH(keys);++i) {
|
||||
if(keys[i].keysym == keysym && keys[i].mod == ke.state) {
|
||||
if (keys[i].keysym == keysym && keys[i].mod == ke.state)
|
||||
keys[i].function(keys[i].arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void button_press(XEvent *e) {
|
||||
@ -278,8 +274,7 @@ void button_release(XEvent *e) {
|
||||
}
|
||||
|
||||
void win_kill() {
|
||||
if(cur != NULL)
|
||||
XKillClient(dis, cur->win);
|
||||
if (cur != NULL) XKillClient(dis, cur->win);
|
||||
}
|
||||
|
||||
void map_request(XEvent *e) {
|
||||
@ -287,7 +282,7 @@ void map_request(XEvent *e) {
|
||||
client *c;
|
||||
|
||||
// For fullscreen mplayer (and maybe some other program)
|
||||
for(c=head;c;c=c->next)
|
||||
for (c=head;c;c=c->next)
|
||||
if(ev->window == c->win) {
|
||||
XMapWindow(dis,ev->window);
|
||||
return;
|
||||
@ -317,7 +312,8 @@ void win_del(Window w) {
|
||||
client *c;
|
||||
|
||||
for(c=head;c;c=c->next) {
|
||||
if(c->win == w) {
|
||||
if (c->win != w) continue;
|
||||
|
||||
if (c->prev == NULL && c->next == NULL) {
|
||||
free(head);
|
||||
|
||||
@ -350,7 +346,6 @@ void win_del(Window w) {
|
||||
win_update();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ws_save(int i) {
|
||||
@ -422,7 +417,7 @@ void wm_init() {
|
||||
if (events[ev.type]) events[ev.type](&ev);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main() {
|
||||
if ((dis = XOpenDisplay(NULL))) {
|
||||
wm_setup();
|
||||
wm_init();
|
||||
@ -432,4 +427,3 @@ int main(int argc, char **argv) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user