diff --git a/src/client.c b/src/client.c index 006f46d..eef0f7e 100644 --- a/src/client.c +++ b/src/client.c @@ -310,6 +310,7 @@ uicb_client_kill(uicb_t cmd) XSendEvent(dpy, sel->win, False, NoEventMask, &ev); client_unmanage(sel); + XSetErrorHandler(errorhandler); return; } @@ -565,9 +566,6 @@ client_unmanage(Client *c) XGrabServer(dpy); XSetErrorHandler(errorhandlerdummy); - /* Some ******* require that... */ - XReparentWindow(dpy, c->win, root, 0, 0); - if(sel == c) client_focus(NULL); @@ -575,9 +573,8 @@ client_unmanage(Client *c) XUngrabButton(dpy, AnyButton, AnyModifier, c->win); setwinstate(c->win, WithdrawnState); XSync(dpy, False); - frame_delete(c); - XSetErrorHandler(errorhandler); XUngrabServer(dpy); + frame_delete(c); arrange(); XFree(c->title); efree(c); @@ -593,13 +590,13 @@ client_unmap(Client *c) { CHECK(c); - XUnmapWindow(dpy, c->frame); - XUnmapSubwindows(dpy, c->frame); if(TBARH) { bar_unmap_subwin(c->titlebar); bar_unmap(c->titlebar); } + XUnmapWindow(dpy, c->frame); + XUnmapSubwindows(dpy, c->frame); return; } diff --git a/src/event.c b/src/event.c index a7fec00..822da4b 100644 --- a/src/event.c +++ b/src/event.c @@ -165,7 +165,10 @@ destroynotify(XDestroyWindowEvent *ev) Client *c; if((c = client_gb_win(ev->window))) + { client_unmanage(c); + XSetErrorHandler(errorhandler); + } return; } @@ -346,7 +349,11 @@ unmapnotify(XUnmapEvent *ev) && ev->send_event && getwinstate(c->win) == NormalState && !c->hide) + { + XReparentWindow(dpy, c->win, root, 0, 0); client_unmanage(c); + XSetErrorHandler(errorhandler); + } return; } diff --git a/src/layout.c b/src/layout.c index 2a9cb54..3bfec67 100644 --- a/src/layout.c +++ b/src/layout.c @@ -297,7 +297,7 @@ multi_tile(Position type) { if(type == Top) mastergeo.y = (n <= nmaster) ? sgeo.y : sgeo.y + (sgeo.height - mwfact) - border; - mastergeo.width = (sgeo.width / nmaster) - BORDH; + mastergeo.width = (sgeo.width / nmaster) - (border * 2); mastergeo.height = (n <= nmaster) ? sgeo.height - border : mwfact; } else diff --git a/src/structs.h b/src/structs.h index 0f67ff3..43c9721 100644 --- a/src/structs.h +++ b/src/structs.h @@ -40,7 +40,7 @@ #define NUM_OF_LAYOUT 7 /* Typedef */ -typedef const char* uicb_t; +typedef const char* uicb_t; typedef unsigned int uint; typedef unsigned long ulong; typedef unsigned short ushort; @@ -50,7 +50,7 @@ typedef unsigned char uchar; enum { CurNormal, CurResize, CurMove, CurLast }; enum { WMState, WMProtocols, WMName, WMDelete, WMLast }; enum { NetSupported, NetWMName, NetLast }; -typedef enum { Top = 0, Bottom, Right, Left, Center, PositionLast } Position; +typedef enum { Top, Bottom, Right, Left, Center, PositionLast } Position; /* * BarWindow Structure diff --git a/src/wmfs.c b/src/wmfs.c index 66f62d9..a2c01b5 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -67,7 +67,18 @@ errorhandlerdummy(Display *d, XErrorEvent *event) void quit(void) { - /* Exiting WMFS :'( */ + Client *c; + + /* Set the silent error handler */ + XSetErrorHandler(errorhandlerdummy); + + /* Unmanage all clients */ + for(c = clients; c; c = c->next) + { + XReparentWindow(dpy, c->win, root, c->frame_geo.x, c->frame_geo.y); + client_unmanage(c); + } + XftFontClose(dpy, font); XFreeCursor(dpy, cursor[CurNormal]); XFreeCursor(dpy, cursor[CurMove]); @@ -197,17 +208,8 @@ scan(void) void handle_signal(int signum) { - Client *c; - if(signum == SIGTERM || signum == SIGINT) { - XSetErrorHandler(errorhandlerdummy); - for(c = clients; c; c = c->next) - { - XReparentWindow(dpy, c->win, root, c->frame_geo.x, c->frame_geo.y); - client_unmanage(c); - } - fprintf(stderr, "\nExit WMFS... Bye !!\n"); quit(); exit(EXIT_FAILURE); }