[gtk+/gestures: 18/20] gesture: Add private getter to know whether a touch begin was handled
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gestures: 18/20] gesture: Add private getter to know whether a touch begin was handled
- Date: Mon, 3 Mar 2014 21:00:51 +0000 (UTC)
commit 3ba0f6c054b937e6f0c20cf47a0d2d142b71ca94
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Mar 3 20:46:10 2014 +0100
gesture: Add private getter to know whether a touch begin was handled
If GDK_TOUCH_BEGIN was handled/consumed for a sequence, or GDK_BUTTON_PRESS was
handled for the mouse gesture, this function will return TRUE.
gtk/Makefile.am | 1 +
gtk/gtkgesture.c | 29 +++++++++++++++++++++++++++--
gtk/gtkgestureprivate.h | 32 ++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 43fc477..d27a62d 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -501,6 +501,7 @@ gtk_private_h_sources = \
gtkfilesystemmodel.h \
gtkfontchooserprivate.h \
gtkfontchooserutils.h \
+ gtkgestureprivate.h \
gtkheaderbarprivate.h \
gtkhslaprivate.h \
gtkiconcache.h \
diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c
index e86e6d4..1014e12 100644
--- a/gtk/gtkgesture.c
+++ b/gtk/gtkgesture.c
@@ -45,6 +45,7 @@ enum {
struct _PointData
{
GdkEvent *event;
+ guint press_handled : 1;
guint state : 2;
};
@@ -301,8 +302,14 @@ gtk_gesture_handle_event (GtkEventController *controller,
break;
/* Fall through */
case GDK_TOUCH_BEGIN:
- if (_gtk_gesture_update_point (gesture, event, TRUE))
- _gtk_gesture_check_recognized (gesture, sequence);
+ if (_gtk_gesture_update_point (gesture, event, TRUE) &&
+ _gtk_gesture_check_recognized (gesture, sequence))
+ {
+ PointData *data;
+
+ data = g_hash_table_lookup (priv->points, sequence);
+ data->press_handled = TRUE;
+ }
break;
case GDK_BUTTON_RELEASE:
if (priv->touch_only)
@@ -1021,3 +1028,21 @@ gtk_gesture_cancel_sequence (GtkGesture *gesture,
_gtk_gesture_remove_point (gesture, data->event);
return TRUE;
}
+
+gboolean
+_gtk_gesture_handled_sequence_press (GtkGesture *gesture,
+ GdkEventSequence *sequence)
+{
+ GtkGesturePrivate *priv;
+ PointData *data;
+
+ g_return_val_if_fail (GTK_IS_GESTURE (gesture), FALSE);
+
+ priv = gtk_gesture_get_instance_private (gesture);
+ data = g_hash_table_lookup (priv->points, sequence);
+
+ if (!data)
+ return FALSE;
+
+ return data->press_handled;
+}
diff --git a/gtk/gtkgestureprivate.h b/gtk/gtkgestureprivate.h
new file mode 100644
index 0000000..d60eaf1
--- /dev/null
+++ b/gtk/gtkgestureprivate.h
@@ -0,0 +1,32 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2014, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author(s): Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifndef __GTK_GESTURE_PRIVATE_H__
+#define __GTK_GESTURE_PRIVATE_H__
+
+#include "gtkgesture.h"
+
+G_BEGIN_DECLS
+
+gboolean _gtk_gesture_handled_sequence_press (GtkGesture *gesture,
+ GdkEventSequence *sequence);
+
+G_END_DECLS
+
+#endif /* __GTK_GESTURE_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]