From 7ad579898f7b4289488e1545a80a5f897979dd37 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 6 Jan 2008 21:57:53 +0100 Subject: [PATCH] simplify unmanage code --- awesome.c | 2 +- awesome.h | 3 --- client.c | 22 ++++++++++++++-------- client.h | 2 +- event.c | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/awesome.c b/awesome.c index e8169cca..5511d2b6 100644 --- a/awesome.c +++ b/awesome.c @@ -171,7 +171,7 @@ exit_on_signal(int sig __attribute__ ((unused))) * ignored (especially on UnmapNotify's). Other types of errors call Xlibs * default error handler, which may call exit. */ -int +static int xerror(Display * edpy, XErrorEvent * ee) { if(ee->error_code == BadWindow diff --git a/awesome.h b/awesome.h index abe3d5f7..a970bb34 100644 --- a/awesome.h +++ b/awesome.h @@ -22,11 +22,8 @@ #ifndef AWESOME_AWESOME_H #define AWESOME_AWESOME_H -#include #include "uicb.h" -int xerror(Display *, XErrorEvent *); - Uicb uicb_quit; #endif diff --git a/client.c b/client.c index b9d56220..eb3db59b 100644 --- a/client.c +++ b/client.c @@ -25,7 +25,6 @@ #include #include "client.h" -#include "awesome.h" #include "tag.h" #include "rules.h" #include "util.h" @@ -567,28 +566,35 @@ client_unban(Client *c) } void -client_unmanage(Client *c, long state) +client_unmanage(Client *c) { XWindowChanges wc; Tag *tag; wc.border_width = c->oldborder; + /* The server grab construct avoids race conditions. */ XGrabServer(globalconf.display); + XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */ + + /* remove client everywhere */ client_detach(c); - if(globalconf.focus->client == c) - focus(NULL, True, c->screen); focus_delete_client(c); for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) untag_client(c, tag); + + if(globalconf.focus->client == c) + focus(NULL, True, c->screen); + + XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); - window_setstate(c->win, state); + window_setstate(c->win, WithdrawnState); + XSync(globalconf.display, False); - XSetErrorHandler(xerror); XUngrabServer(globalconf.display); - if(state != NormalState) - arrange(c->screen); + + arrange(c->screen); p_delete(&c); } diff --git a/client.h b/client.h index 04d50c52..9777efad 100644 --- a/client.h +++ b/client.h @@ -34,7 +34,7 @@ void focus(Client *, Bool, int); void client_manage(Window, XWindowAttributes *, int); Bool client_resize(Client *, Area, Bool); void client_unban(Client *); -void client_unmanage(Client *, long); +void client_unmanage(Client *); void client_updatewmhints(Client *); void client_updatesizehints(Client *); void client_updatetitle(Client *); diff --git a/event.c b/event.c index 49df30d2..9532c48c 100644 --- a/event.c +++ b/event.c @@ -227,7 +227,7 @@ handle_event_destroynotify(XEvent * e) XDestroyWindowEvent *ev = &e->xdestroywindow; if((c = get_client_bywin(globalconf.clients, ev->window))) - client_unmanage(c, WithdrawnState); + client_unmanage(c); } void @@ -395,7 +395,7 @@ handle_event_unmapnotify(XEvent * e) if((c = get_client_bywin(globalconf.clients, ev->window)) && ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen)) && ev->send_event && window_getstate(c->win) == NormalState) - client_unmanage(c, WithdrawnState); + client_unmanage(c); } void -- 2.11.4.GIT