Implemented the following events: MOUSE_MOVE, MOUSE_IN, MOUSE_OUT.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sun, 22 Aug 2004 14:52:37 +0000 (14:52 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sun, 22 Aug 2004 14:52:37 +0000 (14:52 +0000)
src/ecore_x/rb_ecore_x.c

index 0acba6b698c8a54324b59a4d5de39752a9becbb4..3ef0b1e1fcb4beefa55a7b8d6fcd3d8f3e5b9e93 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_ecore_x.c 84 2004-08-21 20:16:25Z tilman $
+ * $Id: rb_ecore_x.c 88 2004-08-22 14:52:37Z tilman $
  *
  * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
@@ -45,6 +45,62 @@ static VALUE m_default_root_window_get (VALUE self)
        return default_root;
 }
 
+static VALUE c_ev_mouse_move_init (VALUE self, VALUE event)
+{
+       VALUE c = CLASS_OF (self);
+       Ecore_X_Event_Mouse_Move *e = (void *) event;
+
+       rb_define_attr (c, "modifiers", 1, 0);
+       rb_define_attr (c, "x", 1, 0);
+       rb_define_attr (c, "y", 1, 0);
+       rb_define_attr (c, "root", 1, 0);
+       rb_define_attr (c, "window", 1, 0);
+       rb_define_attr (c, "event_window", 1, 0);
+       rb_define_attr (c, "time", 1, 0);
+
+       rb_iv_set (self, "@modifiers", INT2FIX (e->modifiers));
+       rb_iv_set (self, "@x", INT2FIX (e->x));
+       rb_iv_set (self, "@y", INT2FIX (e->y));
+       rb_iv_set (self, "@root", rb_ary_new3 (2, INT2FIX (e->root.x),
+                                              INT2FIX (e->root.y)));
+       rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win));
+       rb_iv_set (self, "@event_window",
+                  TO_ECORE_X_WINDOW (Qnil, e->event_win));
+       rb_iv_set (self, "@time", UINT2NUM (e->time));
+
+       return self;
+}
+
+static VALUE c_ev_mouse_in_init (VALUE self, VALUE event)
+{
+       VALUE c = CLASS_OF (self);
+       Ecore_X_Event_Mouse_In *e = (void *) event;
+
+       rb_define_attr (c, "modifiers", 1, 0);
+       rb_define_attr (c, "x", 1, 0);
+       rb_define_attr (c, "y", 1, 0);
+       rb_define_attr (c, "root", 1, 0);
+       rb_define_attr (c, "window", 1, 0);
+       rb_define_attr (c, "event_window", 1, 0);
+       rb_define_attr (c, "mode", 1, 0);
+       rb_define_attr (c, "detail", 1, 0);
+       rb_define_attr (c, "time", 1, 0);
+
+       rb_iv_set (self, "@modifiers", INT2FIX (e->modifiers));
+       rb_iv_set (self, "@x", INT2FIX (e->x));
+       rb_iv_set (self, "@y", INT2FIX (e->y));
+       rb_iv_set (self, "@root", rb_ary_new3 (2, INT2FIX (e->root.x),
+                                              INT2FIX (e->root.y)));
+       rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win));
+       rb_iv_set (self, "@event_window",
+                  TO_ECORE_X_WINDOW (Qnil, e->event_win));
+       rb_iv_set (self, "@mode", INT2FIX (e->mode));
+       rb_iv_set (self, "@detail", INT2FIX (e->detail));
+       rb_iv_set (self, "@time", UINT2NUM (e->time));
+
+       return self;
+}
+
 static VALUE c_ev_win_focus_change_init (VALUE self, VALUE event)
 {
        VALUE c = CLASS_OF (self);
@@ -231,6 +287,18 @@ void Init_ecore_x (void)
        DEF_CONST (c, ECORE_X_EVENT_DETAIL_, DETAIL_NONE);
 
        /* events */
+       ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_MOVE, "MouseMove", c);
+       rb_define_private_method (c, "initialize",
+                                 c_ev_mouse_move_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_IN, "MouseIn", c);
+       rb_define_private_method (c, "initialize",
+                                 c_ev_mouse_in_init, 1);
+
+       ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_OUT, "MouseOut", c);
+       rb_define_private_method (c, "initialize",
+                                 c_ev_mouse_in_init, 1);
+
        ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_FOCUS_IN,
                   "WindowFocusIn", c);
        rb_define_private_method (c, "initialize",