Allow disabling motion event throttling
authorEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 14 Jul 2009 12:47:35 +0000 (13:47 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 20 Jul 2009 10:44:52 +0000 (11:44 +0100)
It might be desirable for some applications and/or platforms to get
every motion event that was delivered to Clutter from the windowing
backend. By adding a per-stage flag we can bypass the throttling
done when processing the events.

  http://bugzilla.openedhand.com/show_bug.cgi?id=1665

clutter/clutter-stage.c
clutter/clutter-stage.h
doc/reference/clutter/clutter-sections.txt

index a2f4263..aa30650 100644 (file)
@@ -89,12 +89,13 @@ struct _ClutterStagePrivate
 
   GQueue             *event_queue;
 
-  guint redraw_pending    : 1;
-  guint is_fullscreen     : 1;
-  guint is_offscreen      : 1;
-  guint is_cursor_visible : 1;
-  guint is_user_resizable : 1;
-  guint use_fog           : 1;
+  guint redraw_pending         : 1;
+  guint is_fullscreen          : 1;
+  guint is_offscreen           : 1;
+  guint is_cursor_visible      : 1;
+  guint is_user_resizable      : 1;
+  guint use_fog                : 1;
+  guint throttle_motion_events : 1;
 };
 
 enum
@@ -465,7 +466,8 @@ _clutter_stage_process_queued_events (ClutterStage *stage)
       next_event = l->next ? l->next->data : NULL;
 
       /* Skip consecutive motion events */
-      if (next_event &&
+      if (priv->throttle_motion_events &&
+          next_event &&
          event->type == CLUTTER_MOTION &&
          (next_event->type == CLUTTER_MOTION ||
           next_event->type == CLUTTER_LEAVE))
@@ -1015,11 +1017,12 @@ clutter_stage_init (ClutterStage *self)
 
   priv->event_queue = g_queue_new ();
 
-  priv->is_offscreen      = FALSE;
-  priv->is_fullscreen     = FALSE;
-  priv->is_user_resizable = FALSE;
-  priv->is_cursor_visible = TRUE;
-  priv->use_fog           = FALSE;
+  priv->is_offscreen           = FALSE;
+  priv->is_fullscreen          = FALSE;
+  priv->is_user_resizable      = FALSE;
+  priv->is_cursor_visible      = TRUE;
+  priv->use_fog                = FALSE;
+  priv->throttle_motion_events = TRUE;
 
   priv->color = default_stage_color;
 
@@ -2055,3 +2058,52 @@ _clutter_stage_get_default_window (void)
 
   return _clutter_stage_get_window (CLUTTER_STAGE (stage));
 }
+
+/**
+ * clutter_stage_set_throttle_motion_events:
+ * @stage: a #ClutterStage
+ * @throttle: %TRUE to throttle motion events
+ *
+ * Sets whether motion events received between redraws should
+ * be throttled or not. If motion events are throttled, those
+ * events received by the windowing system between redraws will
+ * be compressed so that only the last event will be propagated
+ * to the @stage and its actors.
+ *
+ * This function should only be used if you want to have all
+ * the motion events delivered to your application code.
+ *
+ * Since: 1.0
+ */
+void
+clutter_stage_set_throttle_motion_events (ClutterStage *stage,
+                                          gboolean      throttle)
+{
+  ClutterStagePrivate *priv;
+
+  g_return_if_fail (CLUTTER_IS_STAGE (stage));
+
+  priv = stage->priv;
+
+  if (priv->throttle_motion_events != throttle)
+    priv->throttle_motion_events = throttle;
+}
+
+/**
+ * clutter_stage_get_throttle_motion_events:
+ * @stage: a #ClutterStage
+ *
+ * Retrieves the value set with clutter_stage_set_throttle_motion_events()
+ *
+ * Return value: %TRUE if the motion events are being throttled,
+ *   and %FALSE otherwise
+ *
+ * Since: 1.0
+ */
+gboolean
+clutter_stage_get_throttle_motion_events (ClutterStage *stage)
+{
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
+
+  return stage->priv->throttle_motion_events;
+}
index 380ee85..59baf56 100644 (file)
@@ -237,15 +237,17 @@ void                  clutter_stage_get_fog            (ClutterStage *stage,
 void                  clutter_stage_set_key_focus      (ClutterStage *stage,
                                                         ClutterActor *actor);
 ClutterActor *        clutter_stage_get_key_focus      (ClutterStage *stage);
-
-/* New experiental calls */
 void                  clutter_stage_ensure_current     (ClutterStage *stage);
 void                  clutter_stage_queue_redraw       (ClutterStage *stage);
 gboolean              clutter_stage_is_default         (ClutterStage *stage);
 void                  clutter_stage_ensure_viewport    (ClutterStage *stage);
 void                  clutter_stage_ensure_redraw      (ClutterStage *stage);
 
-/* Commodity macro */
+void     clutter_stage_set_throttle_motion_events (ClutterStage *stage,
+                                                   gboolean      throttle);
+gboolean clutter_stage_get_throttle_motion_events (ClutterStage *stage);
+
+/* Commodity macro, for mallum only */
 #define clutter_stage_add(stage,actor)                  G_STMT_START {  \
   if (CLUTTER_IS_STAGE ((stage)) && CLUTTER_IS_ACTOR ((actor)))         \
     {                                                                   \
index 2e38c6b..87495cd 100644 (file)
@@ -510,6 +510,8 @@ clutter_stage_event
 clutter_stage_set_key_focus
 clutter_stage_get_key_focus
 clutter_stage_read_pixels
+clutter_stage_set_throttle_motion_events
+clutter_stage_get_throttle_motion_events
 
 <SUBSECTION>
 ClutterPerspective