gtkeventcontrollerscroll: Refactor scroll end

Move the logic to end scrolling to its own function to be able to
reuse it.

Refactor, no functional changes.

Part-of: <!3454>
This commit is contained in:
José Expósito 2021-06-22 18:27:14 +02:00 committed by Carlos Garnacho
parent 5cd289dc1d
commit ec91b2de10

View File

@ -250,6 +250,28 @@ gtk_event_controller_scroll_begin (GtkEventController *controller)
return TRUE;
}
static gboolean
gtk_event_controller_scroll_end (GtkEventController *controller)
{
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
if (!scroll->active)
return FALSE;
g_signal_emit (controller, signals[SCROLL_END], 0);
scroll->active = FALSE;
if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
{
double vel_x, vel_y;
scroll_history_finish (scroll, &vel_x, &vel_y);
g_signal_emit (controller, signals[DECELERATE], 0, vel_x, vel_y);
}
return TRUE;
}
static gboolean
gtk_event_controller_scroll_handle_event (GtkEventController *controller,
GdkEvent *event,
@ -343,17 +365,8 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
if (scroll->active && gdk_scroll_event_is_stop (event))
{
g_signal_emit (controller, signals[SCROLL_END], 0);
scroll->active = FALSE;
gtk_event_controller_scroll_end (controller);
handled = FALSE;
if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
{
double vel_x, vel_y;
scroll_history_finish (scroll, &vel_x, &vel_y);
g_signal_emit (controller, signals[DECELERATE], 0, vel_x, vel_y);
}
}
return handled;