Fix some bugs.

This commit is contained in:
Kris Maglione 2010-05-27 22:10:14 -04:00
parent 7f57a9fd5a
commit f36c830a49
5 changed files with 19 additions and 7 deletions

View File

@ -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);
}

View File

@ -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*);

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);