From 896ebdc9d75507dfbd56089aea1d7c959a7f7d44 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 9 Jul 2020 16:10:55 +0200 Subject: [PATCH] gtkscrolledwindow: Look up correctly target in captured motion events Check correctly that the captured motion events are emitted towards the content or one of the scrollbars, in order to have it set the expected "over" state depending on whether the drag begins from the scrolledwindow content or one of the scrollbars. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2879 --- gtk/gtkscrolledwindow.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 25312db293..bb74c4f17b 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1169,10 +1169,13 @@ check_update_scrollbar_proximity (GtkScrolledWindow *sw, gboolean indicator_close, on_scrollbar, on_other_scrollbar; indicator_close = coords_close_to_indicator (sw, indicator, x, y); - on_scrollbar = (target == indicator->scrollbar); + on_scrollbar = (target == indicator->scrollbar || + gtk_widget_is_ancestor (target, indicator->scrollbar)); on_other_scrollbar = (!on_scrollbar && (target == priv->hindicator.scrollbar || - target == priv->vindicator.scrollbar)); + target == priv->vindicator.scrollbar || + gtk_widget_is_ancestor (target, priv->hindicator.scrollbar) || + gtk_widget_is_ancestor (target, priv->vindicator.scrollbar))); if (indicator->over_timeout_id) { @@ -1262,7 +1265,8 @@ captured_motion (GtkEventController *controller, if (priv->vscrollbar_visible) indicator_start_fade (&priv->vindicator, 1.0); - if (!target && + if ((target == priv->child || + gtk_widget_is_ancestor (target, priv->child)) && (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0) { indicator_set_over (&priv->hindicator, FALSE);