* clutter/clutter-event.h: made ClutterEventAny have a source field,
rearanged other structs to have source in the same position. * clutter/clutter-event.c: (clutter_event_get_source): modified to use the any event. (clutter_event_free): removed unused variable. * clutter/clutter-main.c: (deliver_event), (clutter_do_event): reduced amount of code. As well as deliver button-release events to the stage.
This commit is contained in:
parent
222b012014
commit
95338ba67b
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2007-11-06 Øyvind Kolås <pippin@o-hand.com>
|
||||
|
||||
* clutter/clutter-event.h: made ClutterEventAny have a source field,
|
||||
rearanged other structs to have source in the same position.
|
||||
* clutter/clutter-event.c: (clutter_event_get_source): modified to use
|
||||
the any event.
|
||||
(clutter_event_free): removed unused variable.
|
||||
* clutter/clutter-main.c: (deliver_event), (clutter_do_event): reduced
|
||||
amount of code. As well as deliver button-release events to the stage.
|
||||
|
||||
2007-11-08 Rob Bradford <rob@openedhand.com>
|
||||
|
||||
* clutter/glx/clutter-glx.h:
|
||||
|
@ -173,34 +173,9 @@ clutter_event_get_coords (ClutterEvent *event,
|
||||
ClutterActor*
|
||||
clutter_event_get_source (ClutterEvent *event)
|
||||
{
|
||||
ClutterActor *res = NULL;
|
||||
gint event_x, event_y;
|
||||
|
||||
g_return_val_if_fail (event != NULL, NULL);
|
||||
|
||||
event_x = event_y = 0;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case CLUTTER_KEY_PRESS:
|
||||
case CLUTTER_KEY_RELEASE:
|
||||
res = event->key.source;
|
||||
break;
|
||||
case CLUTTER_BUTTON_PRESS:
|
||||
case CLUTTER_BUTTON_RELEASE:
|
||||
res = event->button.source;
|
||||
break;
|
||||
case CLUTTER_MOTION:
|
||||
res = event->motion.source;
|
||||
break;
|
||||
case CLUTTER_SCROLL:
|
||||
res = event->scroll.source;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
return event->any.source;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -378,7 +353,6 @@ clutter_event_free (ClutterEvent *event)
|
||||
{
|
||||
if (G_LIKELY (event))
|
||||
{
|
||||
ClutterActor *source = NULL;
|
||||
if (event->type == CLUTTER_LEAVE || event->type == CLUTTER_ENTER)
|
||||
g_object_unref (event->crossing.related);
|
||||
g_slice_free (ClutterEvent, event);
|
||||
|
@ -104,6 +104,7 @@ struct _ClutterAnyEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source;
|
||||
};
|
||||
|
||||
struct _ClutterKeyEvent
|
||||
@ -111,10 +112,10 @@ struct _ClutterKeyEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source;
|
||||
ClutterModifierType modifier_state;
|
||||
guint keyval;
|
||||
guint16 hardware_keycode;
|
||||
ClutterActor *source;
|
||||
};
|
||||
|
||||
struct _ClutterButtonEvent
|
||||
@ -122,6 +123,7 @@ struct _ClutterButtonEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source;
|
||||
gint x;
|
||||
gint y;
|
||||
ClutterModifierType modifier_state;
|
||||
@ -129,7 +131,6 @@ struct _ClutterButtonEvent
|
||||
guint click_count;
|
||||
gdouble *axes; /* Future use */
|
||||
ClutterInputDevice *device; /* Future use */
|
||||
ClutterActor *source;
|
||||
};
|
||||
|
||||
struct _ClutterCrossingEvent
|
||||
@ -137,9 +138,9 @@ struct _ClutterCrossingEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source;
|
||||
gint x;
|
||||
gint y;
|
||||
ClutterActor *source;
|
||||
ClutterActor *related;
|
||||
};
|
||||
|
||||
@ -149,12 +150,12 @@ struct _ClutterMotionEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source;
|
||||
gint x;
|
||||
gint y;
|
||||
ClutterModifierType modifier_state;
|
||||
gdouble *axes; /* Future use */
|
||||
ClutterInputDevice *device; /* Future use */
|
||||
ClutterActor *source;
|
||||
};
|
||||
|
||||
struct _ClutterScrollEvent
|
||||
@ -162,13 +163,13 @@ struct _ClutterScrollEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source;
|
||||
gint x;
|
||||
gint y;
|
||||
ClutterScrollDirection direction;
|
||||
ClutterModifierType modifier_state;
|
||||
gdouble *axes; /* future use */
|
||||
ClutterInputDevice *device; /* future use */
|
||||
ClutterActor *source;
|
||||
};
|
||||
|
||||
struct _ClutterStageStateEvent
|
||||
@ -176,6 +177,7 @@ struct _ClutterStageStateEvent
|
||||
ClutterEventType type;
|
||||
guint32 time;
|
||||
ClutterEventFlags flags;
|
||||
ClutterActor *source; /* unused XXX: should probably be the stage itself */
|
||||
ClutterStageState changed_mask;
|
||||
ClutterStageState new_state;
|
||||
};
|
||||
|
@ -1152,8 +1152,7 @@ event_click_count_generate (ClutterEvent *event)
|
||||
}
|
||||
|
||||
static inline void
|
||||
deliver_event (ClutterEvent *event,
|
||||
ClutterActor *source)
|
||||
deliver_event (ClutterEvent *event)
|
||||
{
|
||||
#define MAX_EVENT_DEPTH 512
|
||||
|
||||
@ -1163,7 +1162,7 @@ deliver_event (ClutterEvent *event,
|
||||
ClutterActor *actor;
|
||||
gint i = 0, n_tree_events = 0;
|
||||
|
||||
g_return_if_fail (source != NULL);
|
||||
g_return_if_fail (event->any.source != NULL);
|
||||
g_return_if_fail (lock == FALSE);
|
||||
|
||||
lock = TRUE; /* Guard against reentrancy */
|
||||
@ -1172,7 +1171,7 @@ deliver_event (ClutterEvent *event,
|
||||
if (G_UNLIKELY (event_tree == NULL))
|
||||
event_tree = g_new0 (ClutterActor *, MAX_EVENT_DEPTH);
|
||||
|
||||
actor = source;
|
||||
actor = event->any.source;
|
||||
|
||||
/* Build 'tree' of events */
|
||||
while (actor && n_tree_events < MAX_EVENT_DEPTH)
|
||||
@ -1237,21 +1236,17 @@ clutter_do_event (ClutterEvent *event)
|
||||
switch (event->type)
|
||||
{
|
||||
case CLUTTER_NOTHING:
|
||||
event->any.source = stage;
|
||||
break;
|
||||
case CLUTTER_ENTER:
|
||||
case CLUTTER_LEAVE:
|
||||
{
|
||||
ClutterActor *actor = NULL;
|
||||
|
||||
actor = event->crossing.source;
|
||||
|
||||
g_return_if_fail (actor != NULL);
|
||||
|
||||
deliver_event (event, actor);
|
||||
deliver_event (event);
|
||||
}
|
||||
break;
|
||||
case CLUTTER_DESTROY_NOTIFY:
|
||||
case CLUTTER_DELETE:
|
||||
event->any.source = stage;
|
||||
if (clutter_stage_event (CLUTTER_STAGE (stage), event))
|
||||
clutter_main_quit ();
|
||||
break;
|
||||
@ -1261,23 +1256,23 @@ clutter_do_event (ClutterEvent *event)
|
||||
ClutterActor *actor = NULL;
|
||||
|
||||
actor = clutter_stage_get_key_focus (CLUTTER_STAGE (stage));
|
||||
event->any.source = actor;
|
||||
|
||||
g_return_if_fail (actor != NULL);
|
||||
|
||||
event->key.source = actor;
|
||||
deliver_event (event, actor);
|
||||
deliver_event (event);
|
||||
}
|
||||
break;
|
||||
case CLUTTER_MOTION:
|
||||
if (context->motion_events_per_actor == FALSE)
|
||||
{
|
||||
/* Only stage gets motion events */
|
||||
event->motion.source = stage;
|
||||
event->any.source = stage;
|
||||
|
||||
/* Trigger handlers in both capture .. */
|
||||
/* Trigger handlers on stage in both capture .. */
|
||||
if (!clutter_actor_event (stage, event, TRUE))
|
||||
{
|
||||
/* and/or bubbling phase */
|
||||
/* and bubbling phase */
|
||||
clutter_actor_event (stage, event, FALSE);
|
||||
}
|
||||
|
||||
@ -1292,13 +1287,19 @@ clutter_do_event (ClutterEvent *event)
|
||||
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
|
||||
/* Safety on - probably a release off stage ?
|
||||
* FIXME: should likely deliver the release somehow - grabs ?
|
||||
*/
|
||||
if (x > CLUTTER_STAGE_WIDTH () ||
|
||||
y > CLUTTER_STAGE_HEIGHT() ||
|
||||
/* Handle release off stage */
|
||||
if (x >= CLUTTER_STAGE_WIDTH () ||
|
||||
y >= CLUTTER_STAGE_HEIGHT() ||
|
||||
x < 0 || y < 0)
|
||||
{
|
||||
if (event->type == CLUTTER_BUTTON_RELEASE)
|
||||
{
|
||||
CLUTTER_NOTE (EVENT, "Release off stage received at %i, %i", x, y);
|
||||
event->button.source = stage;
|
||||
deliver_event (event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Map the event to a reactive actor */
|
||||
actor = _clutter_do_pick (CLUTTER_STAGE (stage),
|
||||
@ -1315,10 +1316,7 @@ clutter_do_event (ClutterEvent *event)
|
||||
CLUTTER_NOTE (EVENT, "Reactive event received at %i, %i - actor: %p",
|
||||
x, y, actor);
|
||||
|
||||
if (event->type == CLUTTER_SCROLL)
|
||||
event->scroll.source = actor;
|
||||
else
|
||||
event->button.source = actor;
|
||||
event->any.source = actor;
|
||||
|
||||
/* Motion enter leave events */
|
||||
if (event->type == CLUTTER_MOTION)
|
||||
@ -1358,11 +1356,12 @@ clutter_do_event (ClutterEvent *event)
|
||||
else
|
||||
event_click_count_generate (event);
|
||||
|
||||
deliver_event (event, actor);
|
||||
deliver_event (event);
|
||||
}
|
||||
break;
|
||||
case CLUTTER_STAGE_STATE:
|
||||
/* fullscreen / focus - forward to stage */
|
||||
event->any.source = stage;
|
||||
clutter_stage_event (CLUTTER_STAGE (stage), event);
|
||||
break;
|
||||
case CLUTTER_CLIENT_MESSAGE:
|
||||
|
Loading…
Reference in New Issue
Block a user