X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=blobdiff_plain;f=src%2Fecore_x%2Frb_ecore_x.c;h=3e54992e2fe00678fb7d3699865a2e7739b692fe;hp=c30eef24e89c1b0f20c6e68ee0100eeee3de646b;hb=f8c0f815b18adf3d1ea53bd177df636ffd532b08;hpb=0a51e32c75ca4cad74738ce4dab88b7d6ea6ce81 diff --git a/src/ecore_x/rb_ecore_x.c b/src/ecore_x/rb_ecore_x.c index c30eef2..3e54992 100644 --- a/src/ecore_x/rb_ecore_x.c +++ b/src/ecore_x/rb_ecore_x.c @@ -1,6 +1,4 @@ /* - * $Id: rb_ecore_x.c 90 2004-08-22 16:23:19Z tilman $ - * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * * This library is free software; you can redistribute it and/or @@ -22,17 +20,18 @@ #include #include +#include +#include #include "../ecore/rb_ecore.h" #include "../ecore/rb_event_handler.h" #include "rb_ecore_x.h" #include "rb_window.h" +#include "rb_cursor.h" -#define DEF_CONST(mod, prefix, name) \ - rb_define_const ((mod), #name, \ - INT2FIX (prefix##name)); - +#if 0 static VALUE default_root; +#endif static void at_exit () { @@ -40,35 +39,80 @@ static void at_exit () ecore_shutdown (); } +#if 0 static VALUE m_default_root_window_get (VALUE self) { return default_root; } +#endif static VALUE c_ev_key_down_init (VALUE self, VALUE event) { VALUE c = CLASS_OF (self); - Ecore_X_Event_Key_Down *e = (void *) event; + Ecore_Event_Key *e = (void *) event; rb_define_attr (c, "keyname", 1, 0); - rb_define_attr (c, "keysymbol", 1, 0); - rb_define_attr (c, "key_compose", 1, 0); + rb_define_attr (c, "key", 1, 0); + rb_define_attr (c, "string", 1, 0); + rb_define_attr (c, "compose", 1, 0); rb_define_attr (c, "modifiers", 1, 0); rb_define_attr (c, "window", 1, 0); + rb_define_attr (c, "root_window", 1, 0); rb_define_attr (c, "event_window", 1, 0); - rb_define_attr (c, "time", 1, 0); + rb_define_attr (c, "timestamp", 1, 0); rb_iv_set (self, "@keyname", e->keyname ? rb_str_new2 (e->keyname) : Qnil); - rb_iv_set (self, "@keysymbol", - e->keysymbol ? rb_str_new2 (e->keysymbol) : Qnil); - rb_iv_set (self, "@key_compose", - e->key_compose ? rb_str_new2 (e->key_compose) : Qnil); + rb_iv_set (self, "@key", + e->key ? rb_str_new2 (e->key) : Qnil); + rb_iv_set (self, "@string", + e->string ? rb_str_new2 (e->string) : Qnil); + rb_iv_set (self, "@compose", + e->compose ? rb_str_new2 (e->compose) : Qnil); rb_iv_set (self, "@modifiers", INT2FIX (e->modifiers)); - rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win)); + rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->window)); + rb_iv_set (self, "@root_window", + TO_ECORE_X_WINDOW (Qnil, e->root_window)); rb_iv_set (self, "@event_window", - TO_ECORE_X_WINDOW (Qnil, e->event_win)); - rb_iv_set (self, "@time", UINT2NUM (e->time)); + TO_ECORE_X_WINDOW (Qnil, e->event_window)); + rb_iv_set (self, "@timestamp", UINT2NUM (e->timestamp)); + + return self; +} + +static VALUE c_ev_mouse_button_down_init (VALUE self, VALUE event) +{ + VALUE c = CLASS_OF (self); + Ecore_Event_Mouse_Button *e = (void *) event; + + rb_define_attr (c, "buttons", 1, 0); + 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, "root_window", 1, 0); + rb_define_attr (c, "event_window", 1, 0); + rb_define_attr (c, "timestamp", 1, 0); + rb_define_attr (c, "double_click", 1, 0); + rb_define_attr (c, "triple_click", 1, 0); + + rb_iv_set (self, "@buttons", INT2FIX (e->buttons)); + rb_iv_set (self, "@modifiers", INT2FIX (e->modifiers)); + rb_iv_set (self, "@x", INT2FIX (e->x)); + rb_iv_set (self, "@y", INT2FIX (e->x)); + 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->window)); + rb_iv_set (self, "@root_window", + TO_ECORE_X_WINDOW (Qnil, e->root_window)); + rb_iv_set (self, "@event_window", + TO_ECORE_X_WINDOW (Qnil, e->event_window)); + rb_iv_set (self, "@timestamp", UINT2NUM (e->timestamp)); + rb_iv_set (self, "@double_click", + e->double_click ? Qtrue : Qfalse); + rb_iv_set (self, "@triple_click", + e->triple_click ? Qtrue : Qfalse); return self; } @@ -76,25 +120,28 @@ static VALUE c_ev_key_down_init (VALUE self, VALUE event) static VALUE c_ev_mouse_move_init (VALUE self, VALUE event) { VALUE c = CLASS_OF (self); - Ecore_X_Event_Mouse_Move *e = (void *) event; + Ecore_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, "root_window", 1, 0); rb_define_attr (c, "event_window", 1, 0); - rb_define_attr (c, "time", 1, 0); + rb_define_attr (c, "timestamp", 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, "@window", TO_ECORE_X_WINDOW (Qnil, e->window)); + rb_iv_set (self, "@root_window", + TO_ECORE_X_WINDOW (Qnil, e->root_window)); rb_iv_set (self, "@event_window", - TO_ECORE_X_WINDOW (Qnil, e->event_win)); - rb_iv_set (self, "@time", UINT2NUM (e->time)); + TO_ECORE_X_WINDOW (Qnil, e->event_window)); + rb_iv_set (self, "@timestamp", UINT2NUM (e->timestamp)); return self; } @@ -161,6 +208,37 @@ static VALUE c_ev_win_delete_request_init (VALUE self, VALUE event) return self; } +static VALUE c_ev_win_configure_request_init (VALUE self, VALUE event) +{ + VALUE c = CLASS_OF (self); + Ecore_X_Event_Window_Configure_Request *e = (void *) event; + + rb_define_attr (c, "window", 1, 0); + rb_define_attr (c, "window_above", 1, 0); + rb_define_attr (c, "x", 1, 0); + rb_define_attr (c, "y", 1, 0); + rb_define_attr (c, "w", 1, 0); + rb_define_attr (c, "h", 1, 0); + rb_define_attr (c, "border", 1, 0); + rb_define_attr (c, "detail", 1, 0); + rb_define_attr (c, "value_mask", 1, 0); + rb_define_attr (c, "time", 1, 0); + + rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win)); + rb_iv_set (self, "@window_above", TO_ECORE_X_WINDOW (Qnil, + e->abovewin)); + rb_iv_set (self, "@x", INT2FIX (e->x)); + rb_iv_set (self, "@y", INT2FIX (e->y)); + rb_iv_set (self, "@w", INT2FIX (e->w)); + rb_iv_set (self, "@h", INT2FIX (e->h)); + rb_iv_set (self, "@border", INT2FIX (e->border)); + rb_iv_set (self, "@detail", INT2FIX (e->detail)); + rb_iv_set (self, "@value_mask", INT2FIX (e->value_mask)); + rb_iv_set (self, "@time", UINT2NUM (e->time)); + + return self; +} + static VALUE c_ev_win_configure_init (VALUE self, VALUE event) { VALUE c = CLASS_OF (self); @@ -192,6 +270,46 @@ static VALUE c_ev_win_configure_init (VALUE self, VALUE event) return self; } +static VALUE c_ev_win_resize_request_init (VALUE self, VALUE event) +{ + VALUE c = CLASS_OF (self); + Ecore_X_Event_Window_Resize_Request *e = (void *) event; + + rb_define_attr (c, "window", 1, 0); + rb_define_attr (c, "w", 1, 0); + rb_define_attr (c, "h", 1, 0); + rb_define_attr (c, "time", 1, 0); + + rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win)); + rb_iv_set (self, "@w", INT2FIX (e->w)); + rb_iv_set (self, "@h", INT2FIX (e->h)); + rb_iv_set (self, "@time", UINT2NUM (e->time)); + + return self; +} + +static VALUE c_ev_win_damage_init (VALUE self, VALUE event) +{ + VALUE c = CLASS_OF (self); + Ecore_X_Event_Window_Damage *e = (void *) event; + + rb_define_attr (c, "window", 1, 0); + rb_define_attr (c, "x", 1, 0); + rb_define_attr (c, "y", 1, 0); + rb_define_attr (c, "w", 1, 0); + rb_define_attr (c, "h", 1, 0); + rb_define_attr (c, "time", 1, 0); + + rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win)); + rb_iv_set (self, "@x", INT2FIX (e->x)); + rb_iv_set (self, "@y", INT2FIX (e->y)); + rb_iv_set (self, "@w", INT2FIX (e->w)); + rb_iv_set (self, "@h", INT2FIX (e->h)); + rb_iv_set (self, "@time", UINT2NUM (e->time)); + + return self; +} + static VALUE c_ev_win_visibility_change_init (VALUE self, VALUE event) { VALUE c = CLASS_OF (self); @@ -243,6 +361,7 @@ static VALUE c_ev_win_show_request_init (VALUE self, VALUE event) void Init_ecore_x (void) { VALUE c; + Ecore_X_Window w; rb_require ("ecore"); @@ -254,15 +373,21 @@ void Init_ecore_x (void) atexit (at_exit); mX = rb_define_module_under (mEcore, "X"); + +#if 0 rb_define_module_function (mX, "default_root_window", m_default_root_window_get, 0); +#endif Init_Window (); + Init_Cursor (); +#if 0 /* now create the default root window object */ - default_root = TO_ECORE_X_WINDOW (Qnil, 0); - OBJ_FREEZE (default_root); + w = DefaultRootWindow (ecore_x_display_get ()); + default_root = TO_ECORE_X_WINDOW (Qnil, w); rb_global_variable (&default_root); +#endif /* event mask values */ c = rb_define_class_under (mX, "EventMask", rb_cObject); @@ -317,80 +442,99 @@ void Init_ecore_x (void) /* key modifiers */ c = rb_define_class_under (mX, "Modifier", rb_cObject); rb_define_private_method (rb_singleton_class (c), "new", NULL, 0); - DEF_CONST (c, ECORE_X_MODIFIER_, SHIFT); - DEF_CONST (c, ECORE_X_MODIFIER_, CTRL); - DEF_CONST (c, ECORE_X_MODIFIER_, ALT); - DEF_CONST (c, ECORE_X_MODIFIER_, WIN); + DEF_CONST (c, ECORE_EVENT_MODIFIER_, SHIFT); + DEF_CONST (c, ECORE_EVENT_MODIFIER_, CTRL); + DEF_CONST (c, ECORE_EVENT_MODIFIER_, ALT); + DEF_CONST (c, ECORE_EVENT_MODIFIER_, WIN); /* events */ - ADD_EVENT (mX, ECORE_X_EVENT_, KEY_DOWN, "KeyDown", c); + ADD_EVENT (mX, ECORE_EVENT_KEY_DOWN, "KeyDownEvent", c); rb_define_private_method (c, "initialize", c_ev_key_down_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, KEY_UP, "KeyUp", c); + ADD_EVENT (mX, ECORE_EVENT_KEY_UP, "KeyUpEvent", c); rb_define_private_method (c, "initialize", c_ev_key_down_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_MOVE, "MouseMove", c); + ADD_EVENT (mX, ECORE_EVENT_MOUSE_BUTTON_DOWN, + "MouseButtonDownEvent", c); + rb_define_private_method (c, "initialize", + c_ev_mouse_button_down_init, 1); + + ADD_EVENT (mX, ECORE_EVENT_MOUSE_BUTTON_UP, + "MouseButtonUpEvent", c); + rb_define_private_method (c, "initialize", + c_ev_mouse_button_down_init, 1); + + ADD_EVENT (mX, ECORE_EVENT_MOUSE_MOVE, "MouseMoveEvent", c); rb_define_private_method (c, "initialize", c_ev_mouse_move_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_IN, "MouseIn", c); + ADD_EVENT (mX, ECORE_EVENT_MOUSE_IN, "MouseInEvent", c); rb_define_private_method (c, "initialize", c_ev_mouse_in_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_OUT, "MouseOut", c); + ADD_EVENT (mX, ECORE_EVENT_MOUSE_OUT, "MouseOutEvent", c); rb_define_private_method (c, "initialize", c_ev_mouse_in_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_FOCUS_IN, - "WindowFocusIn", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_FOCUS_IN, + "WindowFocusInEvent", c); rb_define_private_method (c, "initialize", c_ev_win_focus_change_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_FOCUS_OUT, - "WindowFocusOut", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_FOCUS_OUT, + "WindowFocusOutEvent", c); rb_define_private_method (c, "initialize", c_ev_win_focus_change_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_DELETE_REQUEST, - "WindowDeleteRequest", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_DELETE_REQUEST, + "WindowDeleteRequestEvent", c); rb_define_private_method (c, "initialize", c_ev_win_delete_request_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_CONFIGURE_REQUEST, - "WindowConfigureRequest", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST, + "WindowConfigureRequestEvent", c); rb_define_private_method (c, "initialize", - c_ev_win_delete_request_init, 1); + c_ev_win_configure_request_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_CONFIGURE, - "WindowConfigure", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_CONFIGURE, + "WindowConfigureEvent", c); rb_define_private_method (c, "initialize", c_ev_win_configure_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_VISIBILITY_CHANGE, - "WindowVisibilityChange", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_RESIZE_REQUEST, + "WindowResizeRequestEvent", c); + rb_define_private_method (c, "initialize", + c_ev_win_resize_request_init, 1); + + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_DAMAGE, "WindowDamageEvent", c); + rb_define_private_method (c, "initialize", + c_ev_win_damage_init, 1); + + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, + "WindowVisibilityChangeEvent", c); rb_define_private_method (c, "initialize", c_ev_win_visibility_change_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_CREATE, "WindowCreate", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_CREATE, "WindowCreateEvent", c); rb_define_private_method (c, "initialize", c_ev_win_create_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_DESTROY, "WindowDestroy", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_DESTROY, "WindowDestroyEvent", c); rb_define_private_method (c, "initialize", c_ev_win_delete_request_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_SHOW, "WindowShow", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_SHOW, "WindowShowEvent", c); rb_define_private_method (c, "initialize", c_ev_win_delete_request_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_HIDE, "WindowHide", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_HIDE, "WindowHideEvent", c); rb_define_private_method (c, "initialize", c_ev_win_delete_request_init, 1); - ADD_EVENT (mX, ECORE_X_EVENT_, WINDOW_SHOW_REQUEST, - "WindowShowRequest", c); + ADD_EVENT (mX, ECORE_X_EVENT_WINDOW_SHOW_REQUEST, + "WindowShowRequestEvent", c); rb_define_private_method (c, "initialize", c_ev_win_show_request_init, 1); }