Author: miguel
Date: 2007-06-19 11:09:56 -0400 (Tue, 19 Jun 2007)
New Revision: 80172
Modified:
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
trunk/moon/src/clock.cpp
trunk/moon/src/control.cpp
trunk/moon/src/runtime.cpp
trunk/moon/src/runtime.h
Log:
Revert 80113 it breaks the managed samples with segfaults
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-06-19 15:09:33 UTC (rev 80171)
+++ trunk/moon/src/animation.cpp 2007-06-19 15:09:56 UTC (rev 80172)
@@ -38,9 +38,9 @@
}
void
-AnimationStorage::update_property_value (DependencyObject *sender, gpointer
event_data, gpointer closure)
+AnimationStorage::update_property_value (gpointer data)
{
- ((AnimationStorage*)closure)->UpdatePropertyValue ();
+ ((AnimationStorage*)data)->UpdatePropertyValue ();
}
void
@@ -147,10 +147,9 @@
}
void
-Storyboard::invoke_completed (DependencyObject *sender, gpointer event_data,
gpointer closure)
+Storyboard::invoke_completed (gpointer data)
{
- Storyboard *sb = (Storyboard*)closure;
- sb->events->Emit (sb, "Completed");
+ ((Storyboard*)data)->events->Emit ("Completed");
}
void
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-06-19 15:09:33 UTC (rev 80171)
+++ trunk/moon/src/animation.h 2007-06-19 15:09:56 UTC (rev 80172)
@@ -107,7 +107,7 @@
private:
void UpdatePropertyValue ();
- static void update_property_value (DependencyObject *sender, gpointer
event_data, gpointer closure);
+ static void update_property_value (gpointer data);
AnimationClock *clock;
Animation/*Timeline*/* timeline;
@@ -487,7 +487,9 @@
void HookupAnimationsRecurse (Clock *clock);
Clock *root_clock;
- static void invoke_completed (DependencyObject *sender, gpointer
event_data, gpointer data);
+ gboolean Tick ();
+ static gboolean storyboard_tick (gpointer data);
+ static void invoke_completed (gpointer data);
};
Storyboard *storyboard_new (void);
Modified: trunk/moon/src/clock.cpp
===================================================================
--- trunk/moon/src/clock.cpp 2007-06-19 15:09:33 UTC (rev 80171)
+++ trunk/moon/src/clock.cpp 2007-06-19 15:09:56 UTC (rev 80172)
@@ -162,7 +162,7 @@
if (flags & TIME_MANAGER_RENDER) {
STARTTICKTIMER (tick_render, "TimeManager::Tick - Render");
- Emit (NULL/* XXX */, "render");
+ Emit ("render");
ENDTICKTIMER (tick_render, "TimeManager::Tick - Render");
}
@@ -346,12 +346,12 @@
Clock::RaiseAccumulatedEvents ()
{
if ((queued_events & CURRENT_TIME_INVALIDATED) != 0) {
- events->Emit (this, "CurrentTimeInvalidated");
+ events->Emit (/*this,*/ "CurrentTimeInvalidated");
}
if ((queued_events & CURRENT_STATE_INVALIDATED) != 0) {
current_state = new_state;
- events->Emit (this, "CurrentStateInvalidated");
+ events->Emit (/*this,*/ "CurrentStateInvalidated");
}
if ((queued_events & SPEED_CHANGED) != 0)
@@ -531,7 +531,7 @@
}
if (need_completed) {
- events->Emit (this, "Completed");
+ events->Emit ("Completed");
}
}
Modified: trunk/moon/src/control.cpp
===================================================================
--- trunk/moon/src/control.cpp 2007-06-19 15:09:33 UTC (rev 80171)
+++ trunk/moon/src/control.cpp 2007-06-19 15:09:56 UTC (rev 80172)
@@ -88,10 +88,10 @@
}
bool
-Control::handle_button (Surface *s, char *event, int state, double x, double y)
+Control::handle_button (Surface *s, callback_mouse_event cb, int state, double
x, double y)
{
if (real_object)
- return real_object->handle_button (s, event, state, x, y);
+ return real_object->handle_button (s, cb, state, x, y);
return false;
}
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-06-19 15:09:33 UTC (rev 80171)
+++ trunk/moon/src/runtime.cpp 2007-06-19 15:09:56 UTC (rev 80172)
@@ -49,6 +49,10 @@
#define TIME_CLIP 0
#define TIME_REDRAW 1
+static callback_mouse_event cb_motion, cb_down, cb_up, cb_enter;
+static callback_plain_event cb_got_focus, cb_focus, cb_loaded, cb_mouse_leave;
+static callback_keyboard_event cb_keydown, cb_keyup;
+
void
Base::ref ()
{
@@ -537,25 +541,17 @@
UIElement::handle_motion (Surface *s, int state, double x, double y)
{
if (inside_object (s, x, y)){
- MouseEventArgs args;
- args.state = state;
- args.x = x;
- args.y = y;
- events->Emit (this, "MouseMove", &args);
+ s->cb_motion (this, state, x, y);
return true;
}
return false;
}
bool
-UIElement::handle_button (Surface *s, char *event, int state, double x, double
y)
+UIElement::handle_button (Surface *s, callback_mouse_event cb, int state,
double x, double y)
{
if (inside_object (s, x, y)){
- MouseEventArgs args;
- args.state = state;
- args.x = x;
- args.y = y;
- events->Emit (this, event, &args);
+ cb (this, state, x, y);
return true;
}
return false;
@@ -564,17 +560,13 @@
void
UIElement::enter (Surface *s, int state, double x, double y)
{
- MouseEventArgs args;
- args.state = state;
- args.x = x;
- args.y = y;
- events->Emit (this, "MouseEnter", &args);
+ s->cb_enter (this, state, x, y);
}
void
UIElement::leave (Surface *s)
{
- events->Emit (this, "MouseEnter");
+ s->cb_mouse_leave (this);
}
void
@@ -973,18 +965,14 @@
leave:
if (handled || inside_object (s, x, y)){
- MouseEventArgs args;
- args.state = state;
- args.x = x;
- args.y = y;
- events->Emit (this, "MouseMove", &args);
+ s->cb_motion (this, state, x, y);
return true;
}
return handled;
}
bool
-Canvas::handle_button (Surface *s, char *event, int state, double x, double y)
+Canvas::handle_button (Surface *s, callback_mouse_event cb, int state, double
x, double y)
{
VisualCollection *children = GetChildren ();
bool handled = false;
@@ -1004,17 +992,13 @@
continue;
}
- handled = item->handle_button (s, event, state, x, y);
+ handled = item->handle_button (s, cb, state, x, y);
if (handled)
break;
}
leave:
if (handled || inside_object (s, x, y)){
- MouseEventArgs args;
- args.state = state;
- args.x = x;
- args.y = y;
- events->Emit (this, event, &args);
+ cb (this, state, x, y);
return true;
}
return handled;
@@ -1027,7 +1011,7 @@
current_item->leave (s);
current_item = NULL;
}
- events->Emit (this, "MouseLeave");
+ s->cb_mouse_leave (this);
}
Control*
@@ -1118,9 +1102,9 @@
}
static void
-render_surface (DependencyObject *sender, gpointer event_data, gpointer
closure)
+render_surface (gpointer data)
{
- Surface *s = (Surface*)closure;
+ Surface *s = (Surface*)data;
gdk_window_process_updates (GTK_WIDGET (s->drawing_area)->window,
FALSE);
}
@@ -1206,6 +1190,9 @@
GdkModifierType state;
int x, y;
+ if (!s->cb_motion)
+ return FALSE;
+
if (event->is_hint) {
gdk_window_get_pointer (event->window, &x, &y, &state);
} else {
@@ -1222,6 +1209,9 @@
{
Surface *s = (Surface *) data;
+ if (s->cb_enter == NULL || s->cb_mouse_leave == NULL)
+ return FALSE;
+
if (event->type == GDK_ENTER_NOTIFY){
s->toplevel->handle_motion (s, event->state, event->x,
event->y);
s->toplevel->enter (s, event->state, event->x, event->y);
@@ -1236,16 +1226,14 @@
{
Surface *s = (Surface *) data;
+ if (!s->cb_keydown)
+ return FALSE;
+
//
// I could not write a test that would send the output elsewhere, for
now
// just send to the toplevel
//
- KeyboardEventArgs args;
- args.state = key->state;
- args.key = key->keyval;
- args.platformcode = key->hardware_keycode;
- s->toplevel->events->Emit (s->toplevel, "KeyDown", &args);
- return TRUE;
+ return s->cb_keydown (s->toplevel, key->state, key->keyval,
key->hardware_keycode);
}
static gboolean
@@ -1253,16 +1241,15 @@
{
Surface *s = (Surface *) data;
+ if (!s->cb_keyup)
+ return FALSE;
+
//
// I could not write a test that would send the output elsewhere, for
now
// just send to the toplevel
//
- KeyboardEventArgs args;
- args.state = key->state;
- args.key = key->keyval;
- args.platformcode = key->hardware_keycode;
- s->toplevel->events->Emit (s->toplevel, "KeyUp", &args);
- return TRUE;
+ return s->cb_keyup (s->toplevel, key->state, key->keyval,
key->hardware_keycode);
+
}
static gboolean
@@ -1270,10 +1257,13 @@
{
Surface *s = (Surface *) data;
+ if (!s->cb_up)
+ return FALSE;
+
if (button->button != 1)
return FALSE;
- s->toplevel->handle_button (s, "MouseLeftButtonUp", button->state,
button->x, button->y);
+ s->toplevel->handle_button (s, s->cb_up, button->state, button->x,
button->y);
return TRUE;
}
@@ -1284,10 +1274,13 @@
gtk_widget_grab_focus (widget);
+ if (!s->cb_down)
+ return FALSE;
+
if (button->button != 1)
return FALSE;
- s->toplevel->handle_button (s, "MouseLeftButtonDown", button->state,
button->x, button->y);
+ s->toplevel->handle_button (s, s->cb_down, button->state, button->x,
button->y);
}
static int level = 0;
@@ -1375,14 +1368,14 @@
if (!(item->flags & UIElement::IS_LOADED)) {
item->flags |= UIElement::IS_LOADED;
- item->events->Emit (item, "Loaded");
+ item->events->Emit ("Loaded");
}
}
// printf ("RENDER: LEAVE\n");
if (!(flags & UIElement::IS_LOADED)) {
flags |= UIElement::IS_LOADED;
- events->Emit (this, "Loaded");
+ events->Emit ("Loaded");
}
level -= 4;
//draw_grid (s->cairo);
@@ -2309,7 +2302,7 @@
}
void
-EventObject::Emit (DependencyObject* sender, char *event_name, gpointer
event_data)
+EventObject::Emit (char *event_name)
{
GList *events = (GList*)g_hash_table_lookup (event_hash, event_name);
@@ -2318,7 +2311,7 @@
for (GList *l = events; l; l = l->next) {
EventClosure *closure = (EventClosure*)l->data;
- closure->func (sender, event_data, closure->data);
+ closure->func (closure->data);
}
}
@@ -2758,3 +2751,23 @@
Type::Shutdown ();
DependencyObject::Shutdown ();
}
+
+void surface_register_events (Surface *s,
+ callback_mouse_event motion, callback_mouse_event
down, callback_mouse_event up,
+ callback_mouse_event enter,
+ callback_plain_event got_focus,
callback_plain_event lost_focus,
+ callback_plain_event loaded, callback_plain_event
mouse_leave,
+ callback_keyboard_event keydown,
callback_keyboard_event keyup)
+{
+ s->cb_motion = motion;
+ s->cb_down = down;
+ s->cb_up = up;
+ s->cb_enter = enter;
+ s->cb_got_focus = got_focus;
+ s->cb_lost_focus = lost_focus;
+ s->cb_loaded = loaded;
+ s->cb_mouse_leave = mouse_leave;
+ s->cb_keydown = keydown;
+ s->cb_keyup = keyup;
+}
+
Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h 2007-06-19 15:09:33 UTC (rev 80171)
+++ trunk/moon/src/runtime.h 2007-06-19 15:09:56 UTC (rev 80172)
@@ -18,7 +18,7 @@
#define ENDTIMER(id,str)
#endif
-typedef void (*EventHandler) (DependencyObject* sender, gpointer event_data,
gpointer closure);
+typedef void (*EventHandler) (gpointer data);
class EventObject {
public:
@@ -28,23 +28,11 @@
void AddHandler (char *event_name, EventHandler handler, gpointer data);
void RemoveHandler (char *event_name, EventHandler handler, gpointer
data);
- void Emit (DependencyObject* sender, char *event_name, gpointer
event_data = NULL);
+ void Emit (char *event_name);
private:
GHashTable *event_hash;
};
-struct MouseEventArgs {
- int state;
- double x;
- double y;
-};
-
-struct KeyboardEventArgs {
- int state;
- int platformcode;
- int key;
-};
-
struct Point {
public:
double x, y;
@@ -595,6 +583,14 @@
void event_trigger_fire_actions (EventTrigger *trigger);
//
+// Surface callbacks
+//
+typedef void (*callback_mouse_event) (UIElement *target, int state, double
x, double y);
+typedef void (*callback_plain_event) (UIElement *target);
+typedef bool (*callback_keyboard_event) (UIElement *target, int state, int
platformcode, int key);
+
+
+//
// Item class
//
class UIElement : public Visual {
@@ -696,7 +692,7 @@
//
// Returns true if the button click was handled.
//
- virtual bool handle_button (Surface *s, char *event, int state, double
x, double y);
+ virtual bool handle_button (Surface *s, callback_mouse_event cb, int
state, double x, double y);
//
// enter:
@@ -824,7 +820,7 @@
virtual void update_xform ();
virtual void get_xform_for (UIElement *item, cairo_matrix_t *result);
virtual bool handle_motion (Surface *s, int state, double x, double y);
- virtual bool handle_button (Surface *s, char *event, int state, double
x, double y);
+ virtual bool handle_button (Surface *s, callback_mouse_event cb, int
state, double x, double y);
virtual void leave (Surface *s);
virtual bool OnChildPropertyChanged (DependencyProperty *prop,
DependencyObject *child);
@@ -853,7 +849,7 @@
virtual Point getxformorigin ();
virtual bool inside_object (Surface *s, double x, double y);
virtual bool handle_motion (Surface *s, int state, double x, double y);
- virtual bool handle_button (Surface *s, char *event, int state, double
x, double y);
+ virtual bool handle_button (Surface *s, callback_mouse_event cb, int
state, double x, double y);
virtual void enter (Surface *s, int state, double x, double y);
virtual void leave (Surface *s);
@@ -874,6 +870,9 @@
cairo_buffer_surface (NULL), cairo_buffer(NULL),
xlib_surface(NULL), cairo_xlib(NULL), pixmap(NULL),
using_cairo_xlib_surface(0), pixbuf(NULL),
+ cb_motion(NULL), cb_down(NULL), cb_up(NULL), cb_enter(NULL),
+ cb_got_focus(NULL), cb_lost_focus(NULL), cb_loaded(NULL),
cb_mouse_leave(NULL),
+ cb_keydown(NULL), cb_keyup(NULL),
cairo (NULL) {}
~Surface();
@@ -910,6 +909,11 @@
UIElement *toplevel;
int frames;
+
+ callback_mouse_event cb_motion, cb_down, cb_up, cb_enter;
+ callback_plain_event cb_got_focus, cb_lost_focus, cb_loaded,
cb_mouse_leave;
+ callback_keyboard_event cb_keydown, cb_keyup;
+
};
Surface *surface_new (int width, int height);
@@ -922,6 +926,13 @@
void surface_repaint (Surface *s, int x, int y, int width, int height);
void *surface_get_drawing_area (Surface *s);
+
+void surface_register_events (Surface *s,
+ callback_mouse_event motion,
callback_mouse_event down, callback_mouse_event up,
+ callback_mouse_event enter,
+ callback_plain_event got_focus,
callback_plain_event lost_focus,
+ callback_plain_event loaded,
callback_plain_event mouse_leave,
+ callback_keyboard_event keydown,
callback_keyboard_event keyup);
//
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches