-$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)
+
+Contributors:
+George Gensure (werkt at users sourceforge net)
+$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
-## $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)
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
/*
- * $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
#include "rb_ecore.h"
#include "rb_timer.h"
#include "rb_idler.h"
+#include "rb_event_handler.h"
VALUE mEcore;
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)
{
+ VALUE c;
+
mEcore = rb_define_module ("Ecore");
rb_define_module_function (mEcore, "main_loop_begin",
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);
}
/*
- * $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
--- /dev/null
+/*
+ * $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);
+}
--- /dev/null
+/*
+ * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
/*
- * $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
#include <ruby.h>
+#include <Ecore.h>
#include <Ecore_X.h>
+#include <X11/Xlib.h>
#include "../ecore/rb_ecore.h"
+#include "../ecore/rb_event_handler.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)
{
+ Ecore_X_Window w;
+ VALUE c;
+
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");
+ rb_define_module_function (mX, "default_root_window",
+ m_default_root_window_get, 0);
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);
+}
/*
- * $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
/*
- * $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
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;
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);
- /* 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);
}
/*
- * $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