summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-07-18 16:34:39 +0300
committerErnestas Kulik <ernestask@gnome.org>2018-07-18 16:36:18 +0300
commit3ebd1c3fe77809a80ff1d647ba2d368b5aea0623 (patch)
treeb2ca961755b63110be132fca51cd8ecc53d27084
parent0750b4fd28eedf0782825e1b1f932b912c07c6c7 (diff)
downloadgtk+-scroll-event-propagation.tar.gz
eventcontrollerscroll: Conditionally propagate ::scrollscroll-event-propagation
Currently, gtk_event_controller_scroll_handle_event() always returns TRUE if it is handled, which stops the propagation of the event. If there’s a single GtkEventControllerScroll in the widget hierarchy, that means that no others will run, depending on the propagation phase. In Nautilus, this can be observed when adding a scroll controller to the GtkScrolledWindow (ctrl-scrolling controls the zoom level) - either the scrolling or the zooming breaks. Fixes https://gitlab.gnome.org/GNOME/gtk/issues/45
-rw-r--r--gtk/gtkcalendar.c12
-rw-r--r--gtk/gtkcombobox.c8
-rw-r--r--gtk/gtkeventcontrollerscroll.c13
-rw-r--r--gtk/gtkmarshalers.list1
-rw-r--r--gtk/gtkmenu.c6
-rw-r--r--gtk/gtkpathbar.c12
-rw-r--r--gtk/gtkrange.c6
-rw-r--r--gtk/gtkscalebutton.c6
-rw-r--r--gtk/gtkscrolledwindow.c6
-rw-r--r--gtk/gtkspinbutton.c4
-rw-r--r--gtk/gtktreeview.c6
11 files changed, 51 insertions, 29 deletions
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 643b86e5b9..c45df9200d 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -340,10 +340,10 @@ static gint calendar_get_xsep (GtkCalendar *calendar);
static gint calendar_get_ysep (GtkCalendar *calendar);
static gint calendar_get_inner_border (GtkCalendar *calendar);
-static void gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
- gdouble dx,
- gdouble dy,
- GtkWidget *widget);
+static gboolean gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
+ gdouble dx,
+ gdouble dy,
+ GtkWidget *widget);
static char *default_abbreviated_dayname[7];
static char *default_monthname[12];
@@ -2686,7 +2686,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
gtk_drag_set_icon_default (drag);
}
-static void
+static gboolean
gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
@@ -2701,6 +2701,8 @@ gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
calendar_set_month_prev (calendar);
else if (dy > 0)
calendar_set_month_next (calendar);
+
+ return TRUE;
}
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index f5844ad572..6893b8edcc 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -248,7 +248,7 @@ static void gtk_combo_box_real_move_active (GtkComboBox *combo_box,
static void gtk_combo_box_real_popup (GtkComboBox *combo_box);
static gboolean gtk_combo_box_real_popdown (GtkComboBox *combo_box);
-static void gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
+static gboolean gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
GtkComboBox *combo_box);
@@ -1798,7 +1798,7 @@ tree_first (GtkComboBox *combo,
return search_data.set;
}
-static void
+static gboolean
gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
@@ -1810,7 +1810,7 @@ gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
GtkTreeIter new_iter;
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
- return;
+ return FALSE;
if (dy < 0)
found = tree_prev (combo_box, priv->model, &iter, &new_iter);
@@ -1820,6 +1820,8 @@ gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
if (found)
gtk_combo_box_set_active_iter (combo_box, &new_iter);
+ return found;
+
}
/* callbacks */
diff --git a/gtk/gtkeventcontrollerscroll.c b/gtk/gtkeventcontrollerscroll.c
index db5db881d1..cef8257ec0 100644
--- a/gtk/gtkeventcontrollerscroll.c
+++ b/gtk/gtkeventcontrollerscroll.c
@@ -243,6 +243,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
GdkScrollDirection direction = GDK_SCROLL_SMOOTH;
gdouble dx = 0, dy = 0;
+ gboolean handled = TRUE;
if (gdk_event_get_event_type (event) != GDK_SCROLL)
return FALSE;
@@ -324,7 +325,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
if (dx != 0 || dy != 0)
{
- g_signal_emit (controller, signals[SCROLL], 0, dx, dy);
+ g_signal_emit (controller, signals[SCROLL], 0, dx, dy, &handled);
if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
scroll_history_push (scroll, dx, dy, gdk_event_get_time (event));
@@ -344,7 +345,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
}
}
- return TRUE;
+ return handled;
}
static void
@@ -394,14 +395,16 @@ gtk_event_controller_scroll_class_init (GtkEventControllerScrollClass *klass)
*
* Signals that the widget should scroll by the
* amount specified by @dx and @dy.
+ *
+ * Returns: %TRUE if the scroll event was handled, %FALSE otherwise.
**/
signals[SCROLL] =
g_signal_new (I_("scroll"),
GTK_TYPE_EVENT_CONTROLLER_SCROLL,
- G_SIGNAL_RUN_FIRST,
+ G_SIGNAL_RUN_LAST,
0, NULL, NULL,
- _gtk_marshal_VOID__DOUBLE_DOUBLE,
- G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
+ _gtk_marshal_BOOLEAN__DOUBLE_DOUBLE,
+ G_TYPE_BOOLEAN, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
/**
* GtkEventControllerScroll::scroll-end:
* @controller: The object that received the signal
diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list
index 322feb18b6..322428e76d 100644
--- a/gtk/gtkmarshalers.list
+++ b/gtk/gtkmarshalers.list
@@ -23,6 +23,7 @@
BOOLEAN:BOXED
BOOLEAN:BOXED,BOXED
+BOOLEAN:DOUBLE,DOUBLE
BOOLEAN:ENUM
BOOLEAN:ENUM,BOOLEAN
BOOLEAN:ENUM,DOUBLE
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 1efbb2ed4d..d73f2df91d 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -247,7 +247,7 @@ static void gtk_menu_grab_notify (GtkWidget *widget,
static gboolean gtk_menu_captured_event (GtkWidget *widget,
GdkEvent *event);
-static void gtk_menu_scroll_controller_scroll (GtkEventControllerScroll *scroll,
+static gboolean gtk_menu_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
GtkMenu *menu);
@@ -3211,13 +3211,15 @@ gtk_menu_scroll_timeout (gpointer data)
return TRUE;
}
-static void
+static gboolean
gtk_menu_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
GtkMenu *menu)
{
gtk_menu_scroll_by (menu, dy * MENU_SCROLL_STEP2);
+
+ return TRUE;
}
static void
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index eeaf6e4326..33313979fd 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -157,10 +157,10 @@ static void gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
ButtonData *button_data,
gboolean current_dir);
-static void gtk_path_bar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
- gdouble dx,
- gdouble dy,
- GtkPathBar *path_bar);
+static gboolean gtk_path_bar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
+ gdouble dx,
+ gdouble dy,
+ GtkPathBar *path_bar);
static void
add_cancellable (GtkPathBar *path_bar,
@@ -728,7 +728,7 @@ gtk_path_bar_display_changed (GtkWidget *widget,
gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
}
-static void
+static gboolean
gtk_path_bar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
@@ -738,6 +738,8 @@ gtk_path_bar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gtk_path_bar_scroll_down (path_bar);
else if (dy < 0)
gtk_path_bar_scroll_up (path_bar);
+
+ return TRUE;
}
static void
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 009293dd74..b848e623a2 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -236,7 +236,7 @@ static void gtk_range_allocate_trough (GtkGizmo *gi
static gboolean gtk_range_render_trough (GtkGizmo *gizmo,
GtkSnapshot *snapshot);
-static void gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
+static gboolean gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
GtkRange *range);
@@ -2228,7 +2228,7 @@ stop_scrolling (GtkRange *range)
remove_autoscroll (range);
}
-static void
+static gboolean
gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
@@ -2262,6 +2262,8 @@ gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
g_signal_emit (range, signals[CHANGE_VALUE], 0,
GTK_SCROLL_JUMP, gtk_adjustment_get_value (priv->adjustment) + delta,
&handled);
+
+ return TRUE;
}
static void
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 04d90a783a..9c0dd43c2e 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -150,7 +150,7 @@ static void cb_scale_value_changed (GtkRange *range,
static void cb_popup_mapped (GtkWidget *popup,
gpointer user_data);
-static void gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
+static gboolean gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
GtkScaleButton *button);
@@ -766,7 +766,7 @@ gtk_scale_button_set_orientation_private (GtkScaleButton *button,
}
}
-static void
+static gboolean
gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble dx,
gdouble dy,
@@ -784,6 +784,8 @@ gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
gtk_adjustment_get_upper (adjustment));
gtk_scale_button_set_value (button, d);
+
+ return TRUE;
}
/*
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 4c502846ae..7bee752377 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1279,7 +1279,7 @@ scroll_controller_scroll_begin (GtkEventControllerScroll *scroll,
priv->smooth_scroll = TRUE;
}
-static void
+static gboolean
scroll_controller_scroll (GtkEventControllerScroll *scroll,
gdouble delta_x,
gdouble delta_y,
@@ -1290,7 +1290,7 @@ scroll_controller_scroll (GtkEventControllerScroll *scroll,
GdkModifierType state;
if (!gtk_get_current_event_state (&state))
- return;
+ return FALSE;
shifted = (state & GDK_SHIFT_MASK) != 0;
@@ -1349,6 +1349,8 @@ scroll_controller_scroll (GtkEventControllerScroll *scroll,
g_source_set_name_by_id (priv->scroll_events_overshoot_id,
"[gtk+] start_scroll_deceleration_cb");
}
+
+ return TRUE;
}
static void
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 9a112ebf7d..b9ac55d3de 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -689,7 +689,7 @@ swipe_gesture_update (GtkGesture *gesture,
gtk_spin_button_real_spin (spin_button, -vel_y / 20);
}
-static void
+static gboolean
scroll_controller_scroll (GtkEventControllerScroll *Scroll,
gdouble dx,
gdouble dy,
@@ -701,6 +701,8 @@ scroll_controller_scroll (GtkEventControllerScroll *Scroll,
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
gtk_spin_button_real_spin (spin, -dy * gtk_adjustment_get_step_increment (priv->adjustment));
+
+ return TRUE;
}
static gboolean
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index f9ccd551c4..5205af8108 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -800,7 +800,7 @@ static void gtk_tree_view_search_pressed_cb (GtkGesture *gestu
double x,
double y,
GtkTreeView *tree_view);
-static void gtk_tree_view_search_scroll_event (GtkWidget *entry,
+static gboolean gtk_tree_view_search_scroll_event (GtkWidget *entry,
gdouble dx,
gdouble dy,
GtkTreeView *tree_view);
@@ -14251,7 +14251,7 @@ gtk_tree_view_search_pressed_cb (GtkGesture *gesture,
gtk_tree_view_search_window_hide (widget, tree_view, keyb_device);
}
-static void
+static gboolean
gtk_tree_view_search_scroll_event (GtkWidget *widget,
gdouble dx,
gdouble dy,
@@ -14277,6 +14277,8 @@ gtk_tree_view_search_scroll_event (GtkWidget *widget,
tree_view);
g_source_set_name_by_id (tree_view->priv->typeselect_flush_timeout, "[gtk+] gtk_tree_view_search_entry_flush_timeout");
}
+
+ return TRUE;
}
static gboolean