scrolledwindow: Stop using _gtk_widget_set_captured_event_handler

We can use an event controller with phase = CAPTURE these days.
This commit is contained in:
Timm Bäder 2019-08-13 12:08:36 +02:00
parent 6e872715ef
commit 6669ddad09

View File

@ -1173,13 +1173,12 @@ get_scroll_unit (GtkScrolledWindow *sw,
} }
static gboolean static gboolean
captured_event_cb (GtkWidget *widget, captured_scroll_cb (GtkEventControllerScroll *scroll,
GdkEvent *event) double delta_x,
double delta_y,
GtkScrolledWindow *scrolled_window)
{ {
GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW (widget); gtk_scrolled_window_cancel_deceleration (scrolled_window);
if (gdk_event_get_event_type (event) == GDK_SCROLL)
gtk_scrolled_window_cancel_deceleration (sw);
return GDK_EVENT_PROPAGATE; return GDK_EVENT_PROPAGATE;
} }
@ -1972,8 +1971,6 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
gtk_scrolled_window_set_kinetic_scrolling (scrolled_window, TRUE); gtk_scrolled_window_set_kinetic_scrolling (scrolled_window, TRUE);
gtk_scrolled_window_set_capture_button_press (scrolled_window, TRUE); gtk_scrolled_window_set_capture_button_press (scrolled_window, TRUE);
_gtk_widget_set_captured_event_handler (widget, captured_event_cb);
controller = gtk_event_controller_motion_new (); controller = gtk_event_controller_motion_new ();
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect_swapped (controller, "motion", g_signal_connect_swapped (controller, "motion",
@ -2012,6 +2009,12 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
G_CALLBACK (scroll_controller_decelerate), scrolled_window); G_CALLBACK (scroll_controller_decelerate), scrolled_window);
gtk_widget_add_controller (widget, controller); gtk_widget_add_controller (widget, controller);
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES |
GTK_EVENT_CONTROLLER_SCROLL_KINETIC);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect (controller, "scroll",
G_CALLBACK (captured_scroll_cb), scrolled_window);
controller = gtk_event_controller_motion_new (); controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "leave", g_signal_connect (controller, "leave",
G_CALLBACK (motion_controller_leave), scrolled_window); G_CALLBACK (motion_controller_leave), scrolled_window);