forked from AuroraMiddleware/gtk
eventcontrollerscroll: Conditionally propagate ::scroll
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
This commit is contained in:
parent
c2c1acc73e
commit
edc4b2f7d0
@ -338,10 +338,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];
|
||||
@ -2684,7 +2684,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,
|
||||
@ -2699,6 +2699,8 @@ gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
calendar_set_month_prev (calendar);
|
||||
else if (dy > 0)
|
||||
calendar_set_month_next (calendar);
|
||||
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,7 +249,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);
|
||||
@ -1801,7 +1801,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,
|
||||
@ -1813,7 +1813,7 @@ gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
GtkTreeIter new_iter;
|
||||
|
||||
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
|
||||
return;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
if (dy < 0)
|
||||
found = tree_prev (combo_box, priv->model, &iter, &new_iter);
|
||||
@ -1823,6 +1823,8 @@ gtk_combo_box_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
if (found)
|
||||
gtk_combo_box_set_active_iter (combo_box, &new_iter);
|
||||
|
||||
return found;
|
||||
|
||||
}
|
||||
|
||||
/* callbacks */
|
||||
|
@ -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
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
BOOLEAN:BOXED
|
||||
BOOLEAN:BOXED,BOXED
|
||||
BOOLEAN:DOUBLE,DOUBLE
|
||||
BOOLEAN:ENUM
|
||||
BOOLEAN:ENUM,BOOLEAN
|
||||
BOOLEAN:ENUM,DOUBLE
|
||||
|
@ -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);
|
||||
@ -3062,13 +3062,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 GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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,
|
||||
@ -740,7 +740,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,
|
||||
@ -750,6 +750,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 GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -235,7 +235,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);
|
||||
@ -2226,7 +2226,7 @@ stop_scrolling (GtkRange *range)
|
||||
remove_autoscroll (range);
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
gdouble dx,
|
||||
gdouble dy,
|
||||
@ -2260,6 +2260,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 GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -149,7 +149,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);
|
||||
@ -765,7 +765,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,
|
||||
@ -783,6 +783,8 @@ gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
gtk_adjustment_get_upper (adjustment));
|
||||
|
||||
gtk_scale_button_set_value (button, d);
|
||||
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1252,7 +1252,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,
|
||||
@ -1263,7 +1263,7 @@ scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
GdkModifierType state;
|
||||
|
||||
if (!gtk_get_current_event_state (&state))
|
||||
return;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
shifted = (state & GDK_SHIFT_MASK) != 0;
|
||||
|
||||
@ -1322,6 +1322,8 @@ scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
g_source_set_name_by_id (priv->scroll_events_overshoot_id,
|
||||
"[gtk+] start_scroll_deceleration_cb");
|
||||
}
|
||||
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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 GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -811,7 +811,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);
|
||||
@ -13914,7 +13914,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,
|
||||
@ -13940,6 +13940,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 GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user