commit f36c830a493dff69725eb5cc84d9ae6d02226057
parent 7f57a9fd5a446d02b61f4432aefce340c76fd799
Author: Kris Maglione <kris@suckless.org>
Date: Thu, 27 May 2010 22:10:14 -0400
Fix some bugs.
Diffstat:
5 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c
@@ -314,7 +314,7 @@ client_destroy(Client *c) {
event("DestroyClient %#C\n", c);
event_flush(FocusChangeMask, true);
- free(c->w.hints);
+ cleanupwindow(&c->w);
free(c);
}
diff --git a/include/stuff/x11.h b/include/stuff/x11.h
@@ -239,6 +239,7 @@ void changeproperty(Window*, char*, char*, int width, uchar*, int);
void clientmessage(Window*, char*, long, int, ClientMessageData);
void copyimage(Image*, Rectangle, Image*, Point);
Window* createwindow(Window*, Rectangle, int depth, uint class, WinAttr*, int valuemask);
+void cleanupwindow(Window*);
Window* createwindow_visual(Window*, Rectangle, int depth, Visual*, uint class, WinAttr*, int);
void delproperty(Window*, char*);
void destroywindow(Window*);
diff --git a/lib/libstuff/x11/windows/destroywindow.c b/lib/libstuff/x11/windows/destroywindow.c
@@ -4,15 +4,21 @@
#include "../x11.h"
void
-destroywindow(Window *w) {
+cleanupwindow(Window *w) {
assert(w->type == WWindow);
sethandler(w, nil);
while(w->handler_link)
pophandler(w, w->handler_link->handler);
+ free(w->hints);
if(w->xft)
xft->drawdestroy(w->xft);
if(w->gc)
XFreeGC(display, w->gc);
+}
+
+void
+destroywindow(Window *w) {
+ cleanupwindow(w);
XDestroyWindow(display, w->xid);
free(w);
}
diff --git a/lib/libstuff/x11/windows/findwin.c b/lib/libstuff/x11/windows/findwin.c
@@ -2,13 +2,18 @@
* See LICENSE file for license details.
*/
#include "../x11.h"
+#include <assert.h>
Window*
-findwin(XWindow w) {
+findwin(XWindow xw) {
+ Window *w;
void **e;
- e = map_get(&windowmap, (ulong)w, false);
- if(e)
- return *e;
+ e = map_get(&windowmap, (ulong)xw, false);
+ if(e) {
+ w = *e;
+ assert(w->xid == xw);
+ return w;
+ }
return nil;
}
diff --git a/lib/libstuff/x11/windows/window.c b/lib/libstuff/x11/windows/window.c
@@ -7,7 +7,7 @@ Window*
window(XWindow xw) {
Window *w;
- w = malloc(sizeof *w);
+ w = emallocz(sizeof *w);
w->type = WWindow;
w->xid = xw;
return freelater(w);