Macro tweaks.
[ruby-ecore.git] / src / ecore_evas / rb_software_x11.c
index d61c66fd95f5b916d160cc48e592a7a30f3745ce..055c17e1a357a6c55f0c95de89784e33675a7295 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_software_x11.c 27 2004-07-08 18:25:05Z tilman $
+ * $Id: rb_software_x11.c 40 2004-07-25 13:14:34Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include <Ecore.h>
 #include <Ecore_Evas.h>
 
+#include "../ecore/rb_ecore.h"
+#include "../ecore_x/rb_window.h"
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
+static VALUE windows;
+
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, parent, geom[4];
@@ -62,11 +66,33 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass)
        return self;
 }
 
+static VALUE c_window_get (VALUE self)
+{
+       VALUE o;
+       Ecore_X_Window w;
+
+       GET_OBJ (self, Ecore_Evas *, ee);
+
+       if (NIL_P (o = rb_hash_aref (windows, INT2NUM ((long) (ee))))) {
+               w = ecore_evas_software_x11_window_get (*ee);
+               o = TO_ECORE_X_WINDOW (self, w);
+               rb_hash_aset (windows, INT2NUM ((long) ee), o);
+       }
+
+       return o;
+}
+
 void Init_SoftwareX11 (void)
 {
-       VALUE cSoftwareX11 = rb_define_class_under (mEvas,
-                                                   "SoftwareX11",
-                                                   cEcoreEvas);
+       VALUE c;
+
+       rb_require ("ecore_x");
+
+       c = rb_define_class_under (mEvas, "SoftwareX11", cEcoreEvas);
+
+       rb_define_singleton_method (c, "new", c_new, -1);
+       rb_define_method (c, "window", c_window_get, 0);
 
-       rb_define_singleton_method (cSoftwareX11, "new", c_new, -1);
+       windows = rb_hash_new ();
+       rb_global_variable (&windows);
 }