/*
- * $Id: rb_window.c 39 2004-07-25 13:13:57Z tilman $
+ * $Id: rb_window.c 50 2004-08-01 10:18:39Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include <Ecore.h>
#include <Ecore_X.h>
+#define __RB_WINDOW_C
+#include "../ecore/rb_ecore.h"
#include "rb_ecore_x.h"
+#include "rb_window.h"
-static VALUE cWindow, parents;
+VALUE cWindow;
-static void c_mark (Ecore_X_Window *w)
+static void c_mark (RbWindow *w)
{
- VALUE parent;
-
- parent = rb_hash_aref (parents, INT2NUM ((long) (w)));
- if (parent != Qnil)
- rb_gc_mark (parent);
-}
-
-static void c_free (Ecore_X_Window *w)
-{
- rb_hash_aset (parents, INT2NUM ((long) w), Qnil);
-
- free (w);
+ if (!NIL_P (w->parent))
+ rb_gc_mark (w->parent);
}
VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
{
VALUE self;
- Ecore_X_Window *my_w = NULL;
+ RbWindow *window = NULL;
- if (NIL_P (parent) || !w)
+ if (!w)
return Qnil;
- self = Data_Make_Struct (cWindow, Ecore_X_Window,
- c_mark, c_free, my_w);
- *my_w = w;
+ self = Data_Make_Struct (cWindow, RbWindow, c_mark, free, window);
- rb_hash_aset (parents, INT2NUM ((long) my_w), parent);
+ window->real = w;
+ window->parent = parent;
rb_obj_call_init (self, 0, NULL);
/* not publically instantiable yet */
rb_define_private_method (rb_singleton_class (cWindow),
"new", NULL, 0);
-
- parents = rb_hash_new ();
- rb_global_variable (&parents);
}