[gtk+/gestures: 12/13] widget: Add widget-level handling of touch sequence state.



commit 9a49020ccdc36819b3c0e8270873ed33ebbc5f77
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Feb 26 13:07:08 2014 +0100

    widget: Add widget-level handling of touch sequence state.
    
    These functions ATM do nothing but proxying the controller(s) state
    with the given sequence.

 gtk/gtkwidget.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.h |    8 +++++++
 2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 198d496..349ac1d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -16394,3 +16394,65 @@ gtk_widget_list_controllers (GtkWidget           *widget,
 
   return retval;
 }
+
+GtkEventSequenceState
+gtk_widget_get_sequence_state (GtkWidget        *widget,
+                               GdkEventSequence *sequence)
+{
+  GtkEventSequenceState state;
+  EventControllerData *data;
+  GtkWidgetPrivate *priv;
+  GList *l;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget),
+                        GTK_EVENT_SEQUENCE_NONE);
+
+  priv = widget->priv;
+
+  for (l = priv->event_controllers; l; l = l->next)
+    {
+      data = l->data;
+
+      if (!GTK_IS_GESTURE (data->controller))
+        continue;
+
+      state = gtk_gesture_get_sequence_state (GTK_GESTURE (data->controller),
+                                              sequence);
+      if (state != GTK_EVENT_SEQUENCE_NONE)
+        return state;
+    }
+
+  return GTK_EVENT_SEQUENCE_NONE;
+}
+
+void
+gtk_widget_set_sequence_state (GtkWidget             *widget,
+                               GdkEventSequence      *sequence,
+                               GtkEventSequenceState  state)
+{
+  EventControllerData *data;
+  gboolean handled = FALSE;
+  GtkWidgetPrivate *priv;
+  GList *l;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget),
+                        GTK_EVENT_SEQUENCE_NONE);
+
+  priv = widget->priv;
+
+  for (l = priv->event_controllers; l; l = l->next)
+    {
+      data = l->data;
+
+      if (!GTK_IS_GESTURE (data->controller))
+        continue;
+
+      handled |= gtk_gesture_set_sequence_state (GTK_GESTURE (data->controller),
+                                                 sequence, state);
+    }
+
+  if (!handled)
+    return;
+
+  /* FIXME: Propagate upwards/downwards */
+}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 6b09b09..674a745 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1480,6 +1480,14 @@ GDK_AVAILABLE_IN_3_12
 GList * gtk_widget_list_controllers                     (GtkWidget           *widget,
                                                          GtkPropagationPhase  phase);
 
+GDK_AVAILABLE_IN_3_12
+GtkEventSequenceState gtk_widget_get_sequence_state     (GtkWidget             *widget,
+                                                         GdkEventSequence      *sequence);
+GDK_AVAILABLE_IN_3_12
+void                  gtk_widget_set_sequence_state     (GtkWidget             *widget,
+                                                         GdkEventSequence      *sequence,
+                                                         GtkEventSequenceState  state);
+
 G_END_DECLS
 
 #endif /* __GTK_WIDGET_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]