simplify unmanage code

This commit is contained in:
Julien Danjou 2008-01-06 21:57:53 +01:00
parent cc871d3391
commit 7ad579898f
5 changed files with 18 additions and 15 deletions

View File

@ -171,7 +171,7 @@ exit_on_signal(int sig __attribute__ ((unused)))
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
* default error handler, which may call exit. * default error handler, which may call exit.
*/ */
int static int
xerror(Display * edpy, XErrorEvent * ee) xerror(Display * edpy, XErrorEvent * ee)
{ {
if(ee->error_code == BadWindow if(ee->error_code == BadWindow

View File

@ -22,11 +22,8 @@
#ifndef AWESOME_AWESOME_H #ifndef AWESOME_AWESOME_H
#define AWESOME_AWESOME_H #define AWESOME_AWESOME_H
#include <X11/Xlib.h>
#include "uicb.h" #include "uicb.h"
int xerror(Display *, XErrorEvent *);
Uicb uicb_quit; Uicb uicb_quit;
#endif #endif

View File

@ -25,7 +25,6 @@
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#include "client.h" #include "client.h"
#include "awesome.h"
#include "tag.h" #include "tag.h"
#include "rules.h" #include "rules.h"
#include "util.h" #include "util.h"
@ -567,27 +566,34 @@ client_unban(Client *c)
} }
void void
client_unmanage(Client *c, long state) client_unmanage(Client *c)
{ {
XWindowChanges wc; XWindowChanges wc;
Tag *tag; Tag *tag;
wc.border_width = c->oldborder; wc.border_width = c->oldborder;
/* The server grab construct avoids race conditions. */ /* The server grab construct avoids race conditions. */
XGrabServer(globalconf.display); XGrabServer(globalconf.display);
XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */ XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */
/* remove client everywhere */
client_detach(c); client_detach(c);
if(globalconf.focus->client == c)
focus(NULL, True, c->screen);
focus_delete_client(c); focus_delete_client(c);
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
untag_client(c, tag); untag_client(c, tag);
if(globalconf.focus->client == c)
focus(NULL, True, c->screen);
XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win);
window_setstate(c->win, state); window_setstate(c->win, WithdrawnState);
XSync(globalconf.display, False); XSync(globalconf.display, False);
XSetErrorHandler(xerror);
XUngrabServer(globalconf.display); XUngrabServer(globalconf.display);
if(state != NormalState)
arrange(c->screen); arrange(c->screen);
p_delete(&c); p_delete(&c);
} }

View File

@ -34,7 +34,7 @@ void focus(Client *, Bool, int);
void client_manage(Window, XWindowAttributes *, int); void client_manage(Window, XWindowAttributes *, int);
Bool client_resize(Client *, Area, Bool); Bool client_resize(Client *, Area, Bool);
void client_unban(Client *); void client_unban(Client *);
void client_unmanage(Client *, long); void client_unmanage(Client *);
void client_updatewmhints(Client *); void client_updatewmhints(Client *);
void client_updatesizehints(Client *); void client_updatesizehints(Client *);
void client_updatetitle(Client *); void client_updatetitle(Client *);

View File

@ -227,7 +227,7 @@ handle_event_destroynotify(XEvent * e)
XDestroyWindowEvent *ev = &e->xdestroywindow; XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = get_client_bywin(globalconf.clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
client_unmanage(c, WithdrawnState); client_unmanage(c);
} }
void void
@ -395,7 +395,7 @@ handle_event_unmapnotify(XEvent * e)
if((c = get_client_bywin(globalconf.clients, ev->window)) if((c = get_client_bywin(globalconf.clients, ev->window))
&& ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen)) && ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen))
&& ev->send_event && window_getstate(c->win) == NormalState) && ev->send_event && window_getstate(c->win) == NormalState)
client_unmanage(c, WithdrawnState); client_unmanage(c);
} }
void void