From 6e1799669113bda2858362bd9c74b75b4ded02a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 7 Apr 2024 20:04:26 +0200 Subject: [PATCH 1/3] clapper-app: Fix wrong direction of touchpad scrolling We should not invert axis. Otherwise its opposite compared to the same gesture performed on GtkScale. --- src/bin/clapper-app/clapper-app-window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-window.c b/src/bin/clapper-app/clapper-app-window.c index d1c6f4f4..6441f94e 100644 --- a/src/bin/clapper-app/clapper-app-window.c +++ b/src/bin/clapper-app/clapper-app-window.c @@ -482,8 +482,8 @@ scroll_cb (GtkEventControllerScroll *scroll, switch (gdk_device_get_source (device)) { case GDK_SOURCE_TOUCHPAD: case GDK_SOURCE_TOUCHSCREEN: - dx *= -0.4; - dy *= -0.4; + dx *= 0.4; + dy *= 0.4; break; default: break; From 1327dc23e43a4a5918eef2d54bf634dbf441eaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 7 Apr 2024 20:08:48 +0200 Subject: [PATCH 2/3] clapper-gtk: Fix seek bar touchpad scrolling Since we only do seek on scale drop, handle scrubbing using touchpad the same way by marking it as "dragging" after scrubbing starts and doing seek after it ends. --- src/lib/clapper-gtk/clapper-gtk-seek-bar.c | 38 +++++++++++++++++++ .../clapper-gtk/ui/clapper-gtk-seek-bar.ui | 9 +++++ 2 files changed, 47 insertions(+) diff --git a/src/lib/clapper-gtk/clapper-gtk-seek-bar.c b/src/lib/clapper-gtk/clapper-gtk-seek-bar.c index f157379b..6afdbf99 100644 --- a/src/lib/clapper-gtk/clapper-gtk-seek-bar.c +++ b/src/lib/clapper-gtk/clapper-gtk-seek-bar.c @@ -55,6 +55,9 @@ struct _ClapperGtkSeekBar gboolean has_hours; gboolean has_markers; + gboolean can_scrub; + gboolean scrubbing; + gboolean dragging; guint position_uint; @@ -288,6 +291,38 @@ scale_css_classes_changed_cb (GtkWidget *widget, } } +static void +scale_scroll_begin_cb (GtkEventControllerScroll *scroll, ClapperGtkSeekBar *self) +{ + self->can_scrub = TRUE; +} + +static gboolean +scale_scroll_cb (GtkEventControllerScroll *scroll, + gdouble dx, gdouble dy, ClapperGtkSeekBar *self) +{ + if (self->can_scrub && !self->scrubbing) { + GST_DEBUG_OBJECT (self, "Scrubbing start"); + self->scrubbing = TRUE; + gtk_widget_add_css_class (self->scale, "dragging"); + + return TRUE; + } + + return FALSE; +} + +static void +scale_scroll_end_cb (GtkEventControllerScroll *scroll, ClapperGtkSeekBar *self) +{ + if (self->scrubbing) { + GST_DEBUG_OBJECT (self, "Scrubbing end"); + gtk_widget_remove_css_class (self->scale, "dragging"); + self->scrubbing = FALSE; + } + self->can_scrub = FALSE; +} + static void motion_cb (GtkEventControllerMotion *motion, gdouble x, gdouble y, ClapperGtkSeekBar *self) @@ -773,6 +808,9 @@ clapper_gtk_seek_bar_class_init (ClapperGtkSeekBarClass *klass) gtk_widget_class_bind_template_callback (widget_class, scale_value_changed_cb); gtk_widget_class_bind_template_callback (widget_class, scale_css_classes_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, scale_scroll_begin_cb); + gtk_widget_class_bind_template_callback (widget_class, scale_scroll_cb); + gtk_widget_class_bind_template_callback (widget_class, scale_scroll_end_cb); gtk_widget_class_bind_template_callback (widget_class, motion_cb); gtk_widget_class_bind_template_callback (widget_class, motion_leave_cb); gtk_widget_class_bind_template_callback (widget_class, touch_released_cb); diff --git a/src/lib/clapper-gtk/ui/clapper-gtk-seek-bar.ui b/src/lib/clapper-gtk/ui/clapper-gtk-seek-bar.ui index 264ecb49..c0109aa0 100644 --- a/src/lib/clapper-gtk/ui/clapper-gtk-seek-bar.ui +++ b/src/lib/clapper-gtk/ui/clapper-gtk-seek-bar.ui @@ -29,6 +29,15 @@ position_adjustment + + + capture + both-axes + + + + + From c327734ca629d2edfe6983c1ddedf4f101eb5e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 7 Apr 2024 20:13:20 +0200 Subject: [PATCH 3/3] clapper-app: Do not trigger default scroll handler on GtkRange In addition to GtkScrolledWindow, when also hovering over GtkRange subclassing widgets like GtkScale, do not trigger accidentally default app window scroll handler. We want the hovered upon widget and only that widget to handle scroll events in such case. --- src/bin/clapper-app/clapper-app-window.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-window.c b/src/bin/clapper-app/clapper-app-window.c index 6441f94e..e19bb34f 100644 --- a/src/bin/clapper-app/clapper-app-window.c +++ b/src/bin/clapper-app/clapper-app-window.c @@ -471,11 +471,14 @@ scroll_cb (GtkEventControllerScroll *scroll, pickup = _pick_pointer_widget (self); - /* We do not want to accidentally allow this controller - * to handle scrolls when hovering over scrolled window */ - if (pickup && (GTK_IS_SCROLLED_WINDOW (pickup) - || gtk_widget_get_ancestor (pickup, GTK_TYPE_SCROLLED_WINDOW))) - return FALSE; + /* We do not want to accidentally allow this controller to handle + * scrolls when hovering over widgets that also handle scroll */ + while (pickup && !CLAPPER_GTK_IS_VIDEO (pickup)) { + if (GTK_IS_SCROLLED_WINDOW (pickup) || GTK_IS_RANGE (pickup)) + return FALSE; + + pickup = gtk_widget_get_parent (pickup); + } device = gtk_event_controller_get_current_event_device (GTK_EVENT_CONTROLLER (scroll));