[libhandy] swipe-tracker: Skip swipes outside swipe area
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] swipe-tracker: Skip swipes outside swipe area
- Date: Sat, 27 Jun 2020 12:06:18 +0000 (UTC)
commit 1bdd37314e7d4511786aad6ed13270bedd90bd96
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Jun 26 19:39:50 2020 +0500
swipe-tracker: Skip swipes outside swipe area
This will help with https://gitlab.gnome.org/GNOME/libhandy/-/issues/167
Signed-off-by: Alexander Mikhaylenko <alexm gnome org>
src/hdy-swipe-tracker.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index b46599bf..32e2ebae 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -58,6 +58,9 @@ struct _HdySwipeTracker
gboolean allow_mouse_drag;
GtkOrientation orientation;
+ gint start_x;
+ gint start_y;
+
guint32 prev_time;
gdouble velocity;
@@ -109,6 +112,9 @@ reset (HdySwipeTracker *self)
self->initial_progress = 0;
self->progress = 0;
+ self->start_x = 0;
+ self->start_y = 0;
+
self->prev_time = 0;
self->velocity = 0;
@@ -278,6 +284,9 @@ drag_begin_cb (HdySwipeTracker *self,
{
if (self->state != HDY_SWIPE_TRACKER_STATE_NONE)
gtk_gesture_set_state (self->touch_gesture, GTK_EVENT_SEQUENCE_DENIED);
+
+ self->start_x = start_x;
+ self->start_y = start_y;
}
static void
@@ -412,8 +421,17 @@ handle_scroll_event (HdySwipeTracker *self,
return GDK_EVENT_PROPAGATE;
if (is_vertical == is_delta_vertical) {
- if (!capture)
+ if (!capture) {
+ GtkWidget *widget = gtk_get_event_widget (event);
+ gdouble event_x, event_y;
+
+ gdk_event_get_coords (event, &event_x, &event_y);
+ gtk_widget_translate_coordinates (widget, GTK_WIDGET (self->swipeable),
+ event_x, event_y,
+ &self->start_x, &self->start_y);
+
gesture_prepare (self, delta > 0 ? HDY_NAVIGATION_DIRECTION_FORWARD : HDY_NAVIGATION_DIRECTION_BACK);
+ }
} else {
self->is_scrolling = TRUE;
return GDK_EVENT_PROPAGATE;
@@ -1034,6 +1052,18 @@ hdy_swipe_tracker_emit_begin_swipe (HdySwipeTracker *self,
{
g_return_if_fail (HDY_IS_SWIPE_TRACKER (self));
+ if (direct) {
+ GdkRectangle rect;
+
+ hdy_swipeable_get_swipe_area (self->swipeable, &rect);
+
+ if (self->start_x < rect.x ||
+ self->start_x >= rect.x + rect.width ||
+ self->start_y < rect.y ||
+ self->start_y >= rect.y + rect.height)
+ return;
+ }
+
g_signal_emit (self, signals[SIGNAL_BEGIN_SWIPE], 0, direction, direct);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]