diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index f0290bb12..3bbe785f7 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -109,6 +109,7 @@ #include "clutter-master-clock.h" #include "clutter-private.h" #include "clutter-profile.h" +#include "clutter-stage-manager.h" #include "clutter-stage-private.h" #include "clutter-version.h" /* For flavour define */ @@ -264,9 +265,28 @@ clutter_redraw (ClutterStage *stage) void clutter_set_motion_events_enabled (gboolean enable) { - ClutterMainContext *context = _clutter_context_get_default (); + ClutterStageManager *stage_manager; + ClutterMainContext *context; + const GSList *l; + enable = !!enable; + + context = _clutter_context_get_default (); + if (context->motion_events_per_actor == enable) + return; + + /* store the flag for later query and for newly created stages */ context->motion_events_per_actor = enable; + + /* propagate the change to all stages */ + stage_manager = clutter_stage_manager_get_default (); + + for (l = clutter_stage_manager_peek_stages (stage_manager); + l != NULL; + l = l->next) + { + _clutter_stage_set_motion_events_enabled (l->data, enable); + } } /** @@ -2355,10 +2375,8 @@ _clutter_process_event_details (ClutterActor *stage, break; case CLUTTER_MOTION: - /* Only stage gets motion events if clutter_set_motion_events is TRUE, - * and the event is not a synthetic event with source set. - */ - if (!context->motion_events_per_actor && + /* only the stage gets motion events if they are enabled */ + if (!_clutter_stage_get_motion_events_enabled (CLUTTER_STAGE (stage)) && event->any.source == NULL) { /* Only stage gets motion events */ @@ -2368,13 +2386,15 @@ _clutter_process_event_details (ClutterActor *stage, if (context->pointer_grab_actor != NULL) { clutter_actor_event (context->pointer_grab_actor, - event, FALSE); + event, + FALSE); break; } else if (device != NULL && device->pointer_grab_actor != NULL) { clutter_actor_event (device->pointer_grab_actor, - event, FALSE); + event, + FALSE); break; } diff --git a/clutter/clutter-stage-private.h b/clutter/clutter-stage-private.h index f61fc9d32..3217a822f 100644 --- a/clutter/clutter-stage-private.h +++ b/clutter/clutter-stage-private.h @@ -90,6 +90,10 @@ void _clutter_stage_remove_device (ClutterStage *stage, gboolean _clutter_stage_has_device (ClutterStage *stage, ClutterInputDevice *device); +void _clutter_stage_set_motion_events_enabled (ClutterStage *stage, + gboolean enabled); +gboolean _clutter_stage_get_motion_events_enabled (ClutterStage *stage); + G_END_DECLS #endif /* __CLUTTER_STAGE_PRIVATE_H__ */ diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index d56fdcf21..5832b7209 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -157,6 +157,7 @@ struct _ClutterStagePrivate guint dirty_projection : 1; guint have_valid_pick_buffer : 1; guint accept_focus : 1; + guint motion_events_enabled : 1; }; enum @@ -1636,6 +1637,7 @@ clutter_stage_init (ClutterStage *self) priv->use_fog = FALSE; priv->throttle_motion_events = TRUE; priv->min_size_changed = FALSE; + priv->motion_events_enabled = clutter_get_motion_events_enabled (); priv->color = default_stage_color; @@ -3465,3 +3467,23 @@ _clutter_stage_has_device (ClutterStage *stage, return g_hash_table_lookup (priv->devices, device) != NULL; } + +void +_clutter_stage_set_motion_events_enabled (ClutterStage *stage, + gboolean enabled) +{ + ClutterStagePrivate *priv = stage->priv; + + enabled = !!enabled; + + if (priv->motion_events_enabled != enabled) + { + priv->motion_events_enabled = enabled; + } +} + +gboolean +_clutter_stage_get_motion_events_enabled (ClutterStage *stage) +{ + return stage->priv->motion_events_enabled; +}