[hackers] [wmii] Fix some bugs. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Fri, 28 May 2010 02:10:22 +0000 (UTC)

changeset: 2662:7c6dc01d4d1d
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Thu May 27 22:10:14 2010 -0400
files: cmd/wmii/client.c include/stuff/x11.h lib/libstuff/x11/windows/destroywindow.c lib/libstuff/x11/windows/findwin.c lib/libstuff/x11/windows/window.c
description:
Fix some bugs.

diff -r 2929806f4c88 -r 7c6dc01d4d1d cmd/wmii/client.c
--- a/cmd/wmii/client.c Thu May 27 21:30:13 2010 -0400
+++ b/cmd/wmii/client.c Thu May 27 22:10:14 2010 -0400
@@ -314,7 +314,7 @@
                 event("DestroyClient %#C\n", c);
 
         event_flush(FocusChangeMask, true);
- free(c->w.hints);
+ cleanupwindow(&c->w);
         free(c);
 }
 
diff -r 2929806f4c88 -r 7c6dc01d4d1d include/stuff/x11.h
--- a/include/stuff/x11.h Thu May 27 21:30:13 2010 -0400
+++ b/include/stuff/x11.h Thu May 27 22:10:14 2010 -0400
@@ -239,6 +239,7 @@
 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 -r 2929806f4c88 -r 7c6dc01d4d1d lib/libstuff/x11/windows/destroywindow.c
--- a/lib/libstuff/x11/windows/destroywindow.c Thu May 27 21:30:13 2010 -0400
+++ b/lib/libstuff/x11/windows/destroywindow.c Thu May 27 22:10:14 2010 -0400
@@ -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 -r 2929806f4c88 -r 7c6dc01d4d1d lib/libstuff/x11/windows/findwin.c
--- a/lib/libstuff/x11/windows/findwin.c Thu May 27 21:30:13 2010 -0400
+++ b/lib/libstuff/x11/windows/findwin.c Thu May 27 22:10:14 2010 -0400
@@ -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 -r 2929806f4c88 -r 7c6dc01d4d1d lib/libstuff/x11/windows/window.c
--- a/lib/libstuff/x11/windows/window.c Thu May 27 21:30:13 2010 -0400
+++ b/lib/libstuff/x11/windows/window.c Thu May 27 22:10:14 2010 -0400
@@ -7,7 +7,7 @@
 window(XWindow xw) {
         Window *w;
 
- w = malloc(sizeof *w);
+ w = emallocz(sizeof *w);
         w->type = WWindow;
         w->xid = xw;
         return freelater(w);
Received on Fri May 28 2010 - 02:10:22 UTC

This archive was generated by hypermail 2.2.0 : Fri May 28 2010 - 02:12:04 UTC