Updated copyright notice. Added event handler code.
authorTilman Sauerbeck <tilman@code-monkey.de>
Thu, 19 Aug 2004 17:39:29 +0000 (17:39 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Thu, 19 Aug 2004 17:39:29 +0000 (17:39 +0000)
29 files changed:
AUTHORS
ChangeLog
src/ecore/Makefile.am
src/ecore/rb_ecore.c
src/ecore/rb_ecore.h
src/ecore/rb_event_handler.c [new file with mode: 0644]
src/ecore/rb_event_handler.h [new file with mode: 0644]
src/ecore/rb_idler.c
src/ecore/rb_idler.h
src/ecore/rb_timer.c
src/ecore/rb_timer.h
src/ecore_evas/rb_ecore_evas.c
src/ecore_evas/rb_ecore_evas.h
src/ecore_evas/rb_ecore_evas_main.c
src/ecore_evas/rb_ecore_evas_main.h
src/ecore_evas/rb_fb.c
src/ecore_evas/rb_fb.h
src/ecore_evas/rb_gl_x11.c
src/ecore_evas/rb_gl_x11.h
src/ecore_evas/rb_software_x11.c
src/ecore_evas/rb_software_x11.h
src/ecore_job/rb_ecore_job.c
src/ecore_job/rb_ecore_job.h
src/ecore_job/rb_job.c
src/ecore_job/rb_job.h
src/ecore_x/rb_ecore_x.c
src/ecore_x/rb_ecore_x.h
src/ecore_x/rb_window.c
src/ecore_x/rb_window.h

diff --git a/AUTHORS b/AUTHORS
index f46966f258830efdc9afb899fd071270065d9761..2de2408e6f35028c774e6853559da36cd92c4db6 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,6 @@
-$Id: AUTHORS 9 2004-06-19 19:53:47Z tilman $
+$Id: AUTHORS 77 2004-08-19 17:39:29Z tilman $
 
 Tilman Sauerbeck (tilman at code-monkey de)
 
 Tilman Sauerbeck (tilman at code-monkey de)
+
+Contributors:
+George Gensure (werkt at users sourceforge net)
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9462ea197df40fc81c1adc3ed47c6b8514b1caf7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,9 @@
+$Id: ChangeLog 77 2004-08-19 17:39:29Z tilman $
+
+2004-08-19 Tilman Sauerbeck (tilman at code-monkey de)
+        * src/ecore/Makefile.am, src/ecore/rb_event_handler.[ch]:
+          Added event handler, based on code by George Gensure
+        * src/ecore/rb_ecore.[ch]: Added events
+        * src/ecore_x/rb_ecore_x.c: Added events and eventmask
+          constants
+        * src/ecore_x/rb_window.c: Implemented more methods
index 7c85427d3c4391b6f7ef87f2f3f342f48a058b7c..f3c8a0869b12c6d62ce42292faea6d3e859c6c18 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am 72 2004-08-16 18:10:27Z tilman $
+## $Id: Makefile.am 77 2004-08-19 17:39:29Z tilman $
 
 AM_CFLAGS = $(ECORE_CFLAGS)
 INCLUDES = -I$(RUBYDIR)
 
 AM_CFLAGS = $(ECORE_CFLAGS)
 INCLUDES = -I$(RUBYDIR)
@@ -8,7 +8,8 @@ extdir = $(RUBYSITEDIR)
 
 ecore_la_SOURCES = rb_ecore.c rb_ecore.h \
                    rb_idler.c rb_idler.h \
 
 ecore_la_SOURCES = rb_ecore.c rb_ecore.h \
                    rb_idler.c rb_idler.h \
-                   rb_timer.c rb_timer.h
+                   rb_timer.c rb_timer.h \
+                   rb_event_handler.c rb_event_handler.h
 
 ecore_la_LIBADD = -L$(RUBYLIBDIR) -lruby $(ECORE_LIBS)
 ecore_la_LDFLAGS = -module -avoid-version
 
 ecore_la_LIBADD = -L$(RUBYLIBDIR) -lruby $(ECORE_LIBS)
 ecore_la_LDFLAGS = -module -avoid-version
index 3487662a5f446d1ae8edd6660891db7baab76a16..7e673feaaa95f29a015d36c6adccc983a1b89cbd 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore.c 60 2004-08-10 14:12:36Z tilman $
+ * $Id: rb_ecore.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,7 @@
 #include "rb_ecore.h"
 #include "rb_timer.h"
 #include "rb_idler.h"
 #include "rb_ecore.h"
 #include "rb_timer.h"
 #include "rb_idler.h"
+#include "rb_event_handler.h"
 
 VALUE mEcore;
 
 
 VALUE mEcore;
 
@@ -68,8 +69,52 @@ static VALUE m_main_loop_quit (VALUE self)
        return Qnil;
 }
 
        return Qnil;
 }
 
+static VALUE c_ev_exe_exit_init (VALUE self, VALUE event)
+{
+       Ecore_Event_Exe_Exit *e = (void *) event;
+
+       rb_iv_set (self, "@pid", INT2FIX (e->pid));
+       rb_iv_set (self, "@exit_code", INT2FIX (e->exit_code));
+       rb_iv_set (self, "@exit_signal", INT2FIX (e->exit_signal));
+       rb_iv_set (self, "@exited", e->exited ? Qtrue : Qfalse);
+       rb_iv_set (self, "@signalled", e->signalled ? Qtrue : Qfalse);
+
+       return self;
+}
+
+static VALUE c_ev_sig_user_init (VALUE self, VALUE event)
+{
+       Ecore_Event_Signal_User *e = (void *) event;
+
+       rb_iv_set (self, "@number", INT2FIX (e->number));
+
+       return self;
+}
+
+static VALUE c_ev_sig_exit_init (VALUE self, VALUE event)
+{
+       Ecore_Event_Signal_Exit *e = (void *) event;
+
+       rb_iv_set (self, "@interrupt", e->interrupt ? Qtrue : Qfalse);
+       rb_iv_set (self, "@quit", e->quit ? Qtrue : Qfalse);
+       rb_iv_set (self, "@terminate", e->terminate ? Qtrue : Qfalse);
+
+       return self;
+}
+
+static VALUE c_ev_sig_rt_init (VALUE self, VALUE event)
+{
+       Ecore_Event_Signal_Realtime *e = (void *) event;
+
+       rb_iv_set (self, "@number", INT2FIX (e->num));
+
+       return self;
+}
+
 void Init_ecore (void)
 {
 void Init_ecore (void)
 {
+       VALUE c;
+
        mEcore = rb_define_module ("Ecore");
 
        rb_define_module_function (mEcore, "main_loop_begin",
        mEcore = rb_define_module ("Ecore");
 
        rb_define_module_function (mEcore, "main_loop_begin",
@@ -81,5 +126,49 @@ void Init_ecore (void)
 
        Init_Timer ();
        Init_Idler ();
 
        Init_Timer ();
        Init_Idler ();
+       Init_EventHandler ();
+
+       /* SIGNAL_HUP */
+       ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_HUP,
+                  "SignalHup", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       /* SIGNAL_POWER */
+       ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_POWER,
+                  "SignalPower", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       /* EXE_EXIT */
+       ADD_EVENT (mEcore, ECORE_EVENT_, EXE_EXIT, "ExeExit", c);
+       rb_define_private_method (c, "initialize", c_ev_exe_exit_init, 1);
+
+       rb_define_attr (c, "pid", 1, 0);
+       rb_define_attr (c, "exit_code", 1, 0);
+       rb_define_attr (c, "exit_signal", 1, 0);
+       rb_define_attr (c, "exited", 1, 0);
+       rb_define_attr (c, "signalled", 1, 0);
+
+       /* SIGNAL_USER */
+       ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_USER,
+                  "SignalUser", c);
+       rb_define_private_method (c, "initialize", c_ev_sig_user_init, 1);
+
+       rb_define_attr (c, "number", 1, 0);
+
+       /* SIGNAL_EXIT */
+       ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_EXIT,
+                  "SignalExit", c);
+       rb_define_private_method (c, "initialize", c_ev_sig_exit_init, 1);
+
+       rb_define_attr (c, "interrupt", 1, 0);
+       rb_define_attr (c, "quit", 1, 0);
+       rb_define_attr (c, "terminate", 1, 0);
+
+       /* SIGNAL_REALTIME */
+       ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_REALTIME,
+                  "SignalRealtime", c);
+       rb_define_private_method (c, "initialize", c_ev_sig_rt_init, 1);
+
+       rb_define_attr (c, "number", 1, 0);
 }
 
 }
 
index 0c46a434f8f33f247b4391a58e9cd2e9a26490fc..5afbc03c9a9f42434aded7dadb31783a67d60544 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore.h 50 2004-08-01 10:18:39Z tilman $
+ * $Id: rb_ecore.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/ecore/rb_event_handler.c b/src/ecore/rb_event_handler.c
new file mode 100644 (file)
index 0000000..63c5016
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * $Id: rb_event_handler.c 77 2004-08-19 17:39:29Z tilman $
+ *
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <ruby.h>
+#include <stdbool.h>
+
+#include <Ecore.h>
+
+#define __RB_EVENT_HANDLER_C
+#include "rb_ecore.h"
+#include "rb_event_handler.h"
+
+VALUE event_classes, cEcoreEvent;
+static VALUE handlers;
+
+static VALUE c_init (VALUE self, VALUE type)
+{
+       int t;
+
+       if (!rb_block_given_p ())
+               return Qnil;
+
+       t = NUM2INT (type);
+
+       if (t <= ECORE_EVENT_NONE)
+               return Qnil;
+
+       rb_iv_set (self, "@type", type);
+       rb_iv_set (self, "handler", rb_block_proc ());
+
+       rb_ary_push (handlers, self);
+
+       return self;
+}
+
+static VALUE c_delete (VALUE self)
+{
+       int len = RARRAY (handlers)->len, i;
+       VALUE el;
+
+       for (i = 0; i < len; i++) {
+               el = rb_ary_shift (handlers);
+               if (el == self)
+                       return Qnil;
+
+               rb_ary_push (handlers, el);
+       }
+
+       return Qnil;
+}
+
+int on_ecore_event (void *data, int type, void *event)
+{
+       VALUE handler, klass, obj, argv[1], res;
+       int handler_type, len, i;
+       bool called = false;
+
+       /* instantiate the event object
+        * first, find the class we're gonna use
+        */
+       if (NIL_P (klass = rb_hash_aref (event_classes, INT2NUM (type)))) {
+               rb_raise (rb_eException, "Cannot find event class "
+                                        "for event %i\n", type);
+               return 0;
+       }
+
+       /* now create and init the object */
+       obj = rb_obj_alloc (klass);
+       argv[0] = (VALUE) event;
+       rb_obj_call_init (obj, 1, argv);
+
+       len = RARRAY (handlers)->len;
+
+       for (i = 0; i < len; i++) {
+               handler = rb_ary_entry (handlers, i);
+               handler_type = NUM2INT (rb_iv_get (handler, "@type"));
+
+               if (handler_type == type) {
+                       res = rb_funcall (rb_iv_get (handler, "handler"),
+                                         rb_intern ("call"), 1, obj);
+                       called = true;
+
+                       /* if the block returned false, don't call the other
+                        * event handlers
+                        */
+                       if (res == Qfalse)
+                               break;
+               }
+       }
+
+       if (type == ECORE_EVENT_SIGNAL_EXIT && !called)
+               ecore_main_loop_quit ();
+
+       return 0;
+}
+
+VALUE c_ev_generic_init (VALUE self, VALUE event)
+{
+       /* dummy */
+       return self;
+}
+
+void Init_EventHandler (void)
+{
+       VALUE cEventHandler;
+
+       cEventHandler = rb_define_class_under (mEcore, "EventHandler",
+                                              rb_cObject);
+
+       rb_define_method (cEventHandler, "initialize", c_init, 1);
+       rb_define_method (cEventHandler, "delete", c_delete, 0);
+
+       handlers = rb_ary_new ();
+       rb_global_variable (&handlers);
+
+       event_classes = rb_hash_new ();
+       rb_global_variable (&event_classes);
+
+       /* define a base event class */
+       cEcoreEvent = rb_define_class_under (mEcore, "Event", rb_cObject);
+       rb_define_private_method (rb_singleton_class (cEcoreEvent),
+                                 "new", NULL, 0);
+}
diff --git a/src/ecore/rb_event_handler.h b/src/ecore/rb_event_handler.h
new file mode 100644 (file)
index 0000000..a0fa0e1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * $Id: rb_event_handler.h 77 2004-08-19 17:39:29Z tilman $
+ *
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __RB_EVENT_HANDLER_H
+#define __RB_EVENT_HANDLER_H
+
+#define ADD_EVENT(mod, prefix, constname, clsname, obj) \
+       rb_define_const ((mod), #constname, \
+                        INT2FIX (prefix##constname)); \
+       ecore_event_handler_add (prefix##constname, on_ecore_event, \
+                                NULL); \
+\
+       (obj) = rb_define_class_under ((mod), #clsname, cEcoreEvent); \
+       rb_define_private_method (rb_singleton_class ((obj)), \
+                                 "new", NULL, 0); \
+\
+       rb_hash_aset (event_classes, INT2FIX (prefix##constname), (obj));
+
+void Init_EventHandler (void);
+
+int on_ecore_event (void *data, int type, void *event);
+VALUE c_ev_generic_init (VALUE self, VALUE event);
+
+#ifndef __RB_EVENT_HANDLER_C
+extern VALUE event_classes, cEcoreEvent;
+#endif
+
+#endif
index 2549c71b85126ff7bb571202538b57e14a5e1453..263b7149b4561349ed567e5f6500cd8f04e90315 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_idler.c 67 2004-08-12 20:08:13Z tilman $
+ * $Id: rb_idler.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 2c817062291ec8578a72d8aa5d9742fc261c6ddc..c0affed0d881164e703b5abdcf3dac257e9473e2 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_idler.h 9 2004-06-19 19:53:47Z tilman $
+ * $Id: rb_idler.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index a021106f2cc5d7bcfe917cfac8e2619280e27425..28ef41c6c1010d9e7056e6db00a69d7edebba993 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_timer.c 67 2004-08-12 20:08:13Z tilman $
+ * $Id: rb_timer.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index eccdf3f72f4d345a945bca7a5848357bb58a1a3a..c74b7e4697a7947f9c967527ce8ff28938194279 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_timer.h 9 2004-06-19 19:53:47Z tilman $
+ * $Id: rb_timer.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 07ec2b1bba809f204c4c2d723c775a60b938acea..2cd312577dcffd45d8596c4ba3e90c58f52d0a7d 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_evas.c 65 2004-08-12 19:37:37Z tilman $
+ * $Id: rb_ecore_evas.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 8f9bff0f416c2c6d5d1b34239d5ffe2d755e22d3..8e5849ac789e74c00bbe7ccade5b4cc5fdc8db3b 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_evas.h 50 2004-08-01 10:18:39Z tilman $
+ * $Id: rb_ecore_evas.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 71b5146e1e9d0082056622bf70ac5d949a5fdc5a..432f64a99b7e08f6ad92cb3d9affa42b9090131a 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_evas_main.c 71 2004-08-16 18:08:48Z tilman $
+ * $Id: rb_ecore_evas_main.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 626b5dbaf9d3e8349ca816c88e42e155ff166428..8817478af64debb02fe89f08d44daf7a33b1209f 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_evas_main.h 9 2004-06-19 19:53:47Z tilman $
+ * $Id: rb_ecore_evas_main.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 2f49e5d4788320cd41f9a6175d9e11ef5eb0f8ad..8192169278ec4ff6e4f409276e7cb3a27b113828 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_fb.c 60 2004-08-10 14:12:36Z tilman $
+ * $Id: rb_fb.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 4e11bbd9db706a3887647762e56fd09ad820531e..25146fcabb100d73ab26e2b576847923f0554151 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_fb.h 25 2004-06-26 23:07:01Z tilman $
+ * $Id: rb_fb.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index c5375888259f0b4d56e4be6151ec132c2a20a65d..e3ceb30fb238198d59033c13588e37405b91bd0d 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_gl_x11.c 60 2004-08-10 14:12:36Z tilman $
+ * $Id: rb_gl_x11.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 5e52755f16460271e871f63e058de4324d56c0f3..b40cc2eb5fa53e610405d3b99ab89d27cda584e9 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_gl_x11.h 15 2004-06-20 13:23:07Z tilman $
+ * $Id: rb_gl_x11.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 0b480196acd4c2be46fadbb5f75b868fe0f83e75..cbaa9f498a42581fc893f40a64d4b5d1f9d3a463 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_software_x11.c 60 2004-08-10 14:12:36Z tilman $
+ * $Id: rb_software_x11.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 4a867631284b8215b280c7ba8936fd90c44a3a77..a49509e5528477056d5b5045da64b22e6f9987d7 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_software_x11.h 15 2004-06-20 13:23:07Z tilman $
+ * $Id: rb_software_x11.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index cecd5651a24fc061058f5932bfe2359699c44eaf..02218449193858a38dcd9e8c6257278b0a03b008 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_job.c 9 2004-06-19 19:53:47Z tilman $
+ * $Id: rb_ecore_job.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 0f249d746f92e97e4e7ffece0b48e82d1e6ae587..0f268df6fed48d315b22f813ed607d158702de11 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_job.h 9 2004-06-19 19:53:47Z tilman $
+ * $Id: rb_ecore_job.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 516ceccc1a60e888c99505a94165bdc63e2541a6..71fe1e3143308f28ed545fc34396b65c6f0c3447 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_job.c 67 2004-08-12 20:08:13Z tilman $
+ * $Id: rb_job.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index 9da78d01e5f3eef21890dfa7b0055ab5006a9f27..a5aa0780799c76da01c0921843c1e8a49be36bed 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_job.h 9 2004-06-19 19:53:47Z tilman $
+ * $Id: rb_job.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index c90daecaf064c946843b34125b6eb7f5e3a25851..5df711ed2aec94aa492a501ea8ddc08ec4598c49 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_x.c 53 2004-08-07 11:22:00Z tilman $
+ * $Id: rb_ecore_x.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 
 #include <ruby.h>
 
 
 #include <ruby.h>
 
+#include <Ecore.h>
 #include <Ecore_X.h>
 #include <Ecore_X.h>
+#include <X11/Xlib.h>
 
 #include "../ecore/rb_ecore.h"
 
 #include "../ecore/rb_ecore.h"
+#include "../ecore/rb_event_handler.h"
 #include "rb_ecore_x.h"
 #include "rb_window.h"
 
 #include "rb_ecore_x.h"
 #include "rb_window.h"
 
+#define DEF_CONST(mod, prefix, name) \
+       rb_define_const ((mod), #name, \
+                        INT2FIX (prefix##name));
+
+static VALUE default_root;
+
+static void at_exit ()
+{
+       ecore_x_shutdown ();
+       ecore_shutdown ();
+}
+
+static VALUE m_default_root_window_get (VALUE self)
+{
+       return default_root;
+}
+
+static VALUE c_ev_win_show_req_init (VALUE self, VALUE event)
+{
+       Ecore_X_Event_Window_Show_Request *e = (void *) event;
+
+       rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win));
+       rb_iv_set (self, "@parent", TO_ECORE_X_WINDOW (Qnil, e->parent));
+       rb_iv_set (self, "@time", UINT2NUM (e->time));
+
+       return self;
+}
+
 void Init_ecore_x (void)
 {
 void Init_ecore_x (void)
 {
+       Ecore_X_Window w;
+       VALUE c;
+
        rb_require ("ecore");
 
        rb_require ("ecore");
 
+       /* we need to call ecore_x_init () here, to make sure the
+        * event ids are set properly
+        */
+       ecore_init ();
+       ecore_x_init (getenv ("DISPLAY"));
+       atexit (at_exit);
+
        mX = rb_define_module_under (mEcore, "X");
        mX = rb_define_module_under (mEcore, "X");
+       rb_define_module_function (mX, "default_root_window",
+                                  m_default_root_window_get, 0);
 
        Init_Window ();
 
        Init_Window ();
-}
 
 
+       /* now create the default root window object */
+       w = DefaultRootWindow (ecore_x_display_get ());
+       default_root = TO_ECORE_X_WINDOW (Qnil, w);
+       OBJ_FREEZE (default_root);
+       rb_global_variable (&default_root);
+
+       /* event mask values */
+       c = rb_define_class_under (mX, "EventMask", rb_cObject);
+       rb_define_private_method (rb_singleton_class (c), "new", NULL, 0);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, KEY_DOWN);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, KEY_UP);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, MOUSE_DOWN);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, MOUSE_UP);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, MOUSE_IN);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, MOUSE_OUT);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, MOUSE_MOVE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_DAMAGE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_VISIBILITY);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_CONFIGURE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_RESIZE_MANAGE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_MANAGE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_CHILD_CONFIGURE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_FOCUS_CHANGE);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_PROPERTY);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_COLORMAP);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_GRAB);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, MOUSE_WHEEL);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_FOCUS_IN);
+       DEF_CONST (c, ECORE_X_EVENT_MASK_, WINDOW_FOCUS_OUT);
+
+       /* wm protocols */
+       c = rb_define_class_under (mX, "WmProtocol", rb_cObject);
+       rb_define_private_method (rb_singleton_class (c), "new", NULL, 0);
+       DEF_CONST (c, ECORE_X_WM_PROTOCOL_, DELETE_REQUEST);
+       DEF_CONST (c, ECORE_X_WM_PROTOCOL_, TAKE_FOCUS);
+
+       /* events */
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_FOCUS_IN,
+                  "WindowFocusIn", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_FOCUS_OUT,
+                  "WindowFocusOut", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_DELETE_REQUEST,
+                  "WindowDeleteRequest", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_CONFIGURE_REQUEST,
+                  "WindowConfigureRequest", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_CONFIGURE,
+                  "WindowConfigure", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_VISIBILITY_CHANGE,
+                  "WindowVisibilityChange", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_SHOW, "WindowShow", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_HIDE, "WindowHide", c);
+       rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_SHOW_REQUEST,
+                  "WindowShowRequest", c);
+       rb_define_private_method (c, "initialize",
+                                 c_ev_win_show_req_init, 1);
+
+       rb_define_attr (c, "window", 1, 0);
+       rb_define_attr (c, "parent", 1, 0);
+       rb_define_attr (c, "time", 1, 0);
+}
index 7c02194c7cb4627eba4fabb03961ac50132cdac2..4179c02621b03026821d990c500fec2186273483 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_ecore_x.h 39 2004-07-25 13:13:57Z tilman $
+ * $Id: rb_ecore_x.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index e046b6f37f67d1bc81ba511cea111a5beb6910f1..04bb1166e8dd42c1c2c52394593035285add0b0b 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_window.c 50 2004-08-01 10:18:39Z tilman $
+ * $Id: rb_window.c 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -36,6 +36,14 @@ static void c_mark (RbWindow *w)
                rb_gc_mark (w->parent);
 }
 
                rb_gc_mark (w->parent);
 }
 
+static void c_free (RbWindow *w)
+{
+       if (w->real)
+               ecore_x_window_del (w->real);
+
+       free (w);
+}
+
 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
 {
        VALUE self;
 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
 {
        VALUE self;
@@ -54,11 +62,196 @@ VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
        return self;
 }
 
        return self;
 }
 
+static VALUE c_new (int argc, VALUE *argv, VALUE klass)
+{
+       VALUE self, parent, geom[4];
+       RbWindow *window = NULL, *p = NULL;
+       int i, igeom[4] = {0, 0, 0, 0};
+       Ecore_X_Window pwin = 0;
+
+       self = Data_Make_Struct (cWindow, RbWindow, c_mark, c_free, window);
+
+       rb_scan_args (argc, argv, "05",
+                     &parent, &geom[0], &geom[1], &geom[2], &geom[3]);
+
+       if (!NIL_P (parent)) {
+               CHECK_CLASS (parent, cWindow);
+               Data_Get_Struct (parent, RbWindow, p);
+               pwin = p->real;
+       }
+
+       for (i = 0; i < 4; i++)
+               if (!NIL_P (geom[i])) {
+                       Check_Type (geom[i], T_FIXNUM);
+                       igeom[i] = FIX2INT (geom[i]);
+               }
+
+       window->real = ecore_x_window_new (pwin, igeom[0], igeom[1],
+                                          igeom[2], igeom[3]);
+       window->parent = parent;
+
+       rb_obj_call_init (self, 0, NULL);
+
+       return self;
+}
+
+static VALUE c_equal_value (VALUE self, VALUE other)
+{
+       GET_OBJ (self, RbWindow, w1);
+
+       CHECK_CLASS (other, cWindow);
+       GET_OBJ (other, RbWindow, w2);
+
+       return w1->real == w2->real ? Qtrue : Qfalse;
+}
+
+static VALUE c_show (VALUE self)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       ecore_x_window_show (win->real);
+
+       return Qnil;
+}
+
+static VALUE c_hide (VALUE self)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       ecore_x_window_hide (win->real);
+
+       return Qnil;
+}
+
+static VALUE c_delete (VALUE self)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       if (win->real) {
+               ecore_x_window_del (win->real);
+               win->real = 0;
+       }
+
+       return Qnil;
+}
+
+static VALUE c_raise (VALUE self)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       ecore_x_window_raise (win->real);
+
+       return Qnil;
+}
+
+static VALUE c_lower (VALUE self)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       ecore_x_window_lower (win->real);
+
+       return Qnil;
+}
+
+static VALUE c_move (VALUE self, VALUE x, VALUE y)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       Check_Type (x, T_FIXNUM);
+       Check_Type (y, T_FIXNUM);
+
+       ecore_x_window_move (win->real, FIX2INT (x), FIX2INT (y));
+
+       return Qnil;
+}
+
+static VALUE c_resize (VALUE self, VALUE w, VALUE h)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       Check_Type (w, T_FIXNUM);
+       Check_Type (h, T_FIXNUM);
+
+       ecore_x_window_move (win->real, FIX2INT (w), FIX2INT (h));
+
+       return Qnil;
+}
+
+static VALUE c_get_size (VALUE self)
+{
+       int x = 0, y = 0;
+
+       GET_OBJ (self, RbWindow, win);
+
+       ecore_x_window_size_get (win->real, &x, &y);
+
+       return rb_ary_new3 (2, INT2FIX (x), INT2FIX (y));
+}
+
+static VALUE c_get_geometry (VALUE self)
+{
+       int x = 0, y = 0, w = 0, h = 0;
+
+       GET_OBJ (self, RbWindow, win);
+
+       ecore_x_window_geometry_get (win->real, &x, &y, &w, &h);
+
+       return rb_ary_new3 (4, INT2FIX (x), INT2FIX (y),
+                           INT2FIX (w), INT2FIX (h));
+}
+
+static VALUE c_set_event_mask (VALUE self, VALUE val)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       Check_Type (val, T_FIXNUM);
+
+       ecore_x_event_mask_set (win->real, FIX2INT (val));
+
+       return Qnil;
+}
+
+static VALUE c_unset_event_mask (VALUE self, VALUE val)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       Check_Type (val, T_FIXNUM);
+
+       ecore_x_event_mask_unset (win->real, FIX2INT (val));
+
+       return Qnil;
+}
+
+static VALUE c_set_protocol (VALUE self, VALUE proto, VALUE on)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       Check_Type (proto, T_FIXNUM);
+       CHECK_BOOL (on);
+
+       ecore_x_window_prop_protocol_set (win->real, FIX2INT (proto),
+                                         on == Qtrue);
+
+       return Qnil;
+}
+
 void Init_Window (void)
 {
        cWindow = rb_define_class_under (mX, "Window", rb_cObject);
 
 void Init_Window (void)
 {
        cWindow = rb_define_class_under (mX, "Window", rb_cObject);
 
-       /* not publically instantiable yet */
-       rb_define_private_method (rb_singleton_class (cWindow),
-                                 "new", NULL, 0);
+       rb_define_singleton_method (cWindow, "new", c_new, -1);
+       rb_define_method (cWindow, "==", c_equal_value, 1);
+       rb_define_method (cWindow, "show", c_show, 0);
+       rb_define_method (cWindow, "hide", c_hide, 0);
+       rb_define_method (cWindow, "delete", c_delete, 0);
+       rb_define_method (cWindow, "raise", c_raise, 0);
+       rb_define_method (cWindow, "lower", c_lower, 0);
+       rb_define_method (cWindow, "move", c_move, 2);
+       rb_define_method (cWindow, "resize", c_resize, 2);
+       rb_define_method (cWindow, "get_size", c_get_size, 0);
+       rb_define_method (cWindow, "get_geometry", c_get_geometry, 0);
+       rb_define_method (cWindow, "set_event_mask", c_set_event_mask, 1);
+       rb_define_method (cWindow, "unset_event_mask",
+                         c_unset_event_mask, 1);
+       rb_define_method (cWindow, "set_protocol", c_set_protocol, 2);
 }
 }
index 3dd8e3e40811880e6bc9fc49883d9d61b60f347f..f9f04e5b66935220b80118683b2aa07262ac1be1 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
- * $Id: rb_window.h 50 2004-08-01 10:18:39Z tilman $
+ * $Id: rb_window.h 77 2004-08-19 17:39:29Z tilman $
  *
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public