eventcontrollerscroll: Always propagate hold events

Otherwise a stray scroll controller may prevent others from getting hold
events, even if it always propagates scroll events and does absolutely
nothing.
This commit is contained in:
Alexander Mikhaylenko 2022-03-28 01:05:23 +04:00 committed by Carlos Garnacho
parent 40386c97eb
commit 9bd8ed0d82

View File

@ -241,28 +241,26 @@ gtk_event_controller_scroll_get_property (GObject *object,
} }
} }
static gboolean static void
gtk_event_controller_scroll_begin (GtkEventController *controller) gtk_event_controller_scroll_begin (GtkEventController *controller)
{ {
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller); GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
if (scroll->active) if (scroll->active)
return FALSE; return;
g_signal_emit (controller, signals[SCROLL_BEGIN], 0); g_signal_emit (controller, signals[SCROLL_BEGIN], 0);
scroll_history_reset (scroll); scroll_history_reset (scroll);
scroll->active = TRUE; scroll->active = TRUE;
return TRUE;
} }
static gboolean static void
gtk_event_controller_scroll_end (GtkEventController *controller) gtk_event_controller_scroll_end (GtkEventController *controller)
{ {
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller); GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
if (!scroll->active) if (!scroll->active)
return FALSE; return;
g_signal_emit (controller, signals[SCROLL_END], 0); g_signal_emit (controller, signals[SCROLL_END], 0);
scroll->active = FALSE; scroll->active = FALSE;
@ -274,8 +272,6 @@ gtk_event_controller_scroll_end (GtkEventController *controller)
scroll_history_finish (scroll, &vel_x, &vel_y); scroll_history_finish (scroll, &vel_x, &vel_y);
g_signal_emit (controller, signals[DECELERATE], 0, vel_x, vel_y); g_signal_emit (controller, signals[DECELERATE], 0, vel_x, vel_y);
} }
return TRUE;
} }
static gboolean static gboolean
@ -298,30 +294,29 @@ gtk_event_controller_scroll_handle_hold_event (GtkEventController *controller,
GdkEvent *event) GdkEvent *event)
{ {
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller); GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
gboolean handled = GDK_EVENT_PROPAGATE;
GdkTouchpadGesturePhase phase; GdkTouchpadGesturePhase phase;
guint n_fingers = 0; guint n_fingers = 0;
if (gdk_event_get_event_type (event) != GDK_TOUCHPAD_HOLD) if (gdk_event_get_event_type (event) != GDK_TOUCHPAD_HOLD)
return handled; return GDK_EVENT_PROPAGATE;
n_fingers = gdk_touchpad_event_get_n_fingers (event); n_fingers = gdk_touchpad_event_get_n_fingers (event);
if (n_fingers != 1 && n_fingers != 2) if (n_fingers != 1 && n_fingers != 2)
return handled; return GDK_EVENT_PROPAGATE;
if (scroll->hold_timeout_id != 0) if (scroll->hold_timeout_id != 0)
return handled; return GDK_EVENT_PROPAGATE;
phase = gdk_touchpad_event_get_gesture_phase (event); phase = gdk_touchpad_event_get_gesture_phase (event);
switch (phase) switch (phase)
{ {
case GDK_TOUCHPAD_GESTURE_PHASE_BEGIN: case GDK_TOUCHPAD_GESTURE_PHASE_BEGIN:
handled = gtk_event_controller_scroll_begin (controller); gtk_event_controller_scroll_begin (controller);
break; break;
case GDK_TOUCHPAD_GESTURE_PHASE_END: case GDK_TOUCHPAD_GESTURE_PHASE_END:
handled = gtk_event_controller_scroll_end (controller); gtk_event_controller_scroll_end (controller);
break; break;
case GDK_TOUCHPAD_GESTURE_PHASE_CANCEL: case GDK_TOUCHPAD_GESTURE_PHASE_CANCEL:
@ -339,7 +334,7 @@ gtk_event_controller_scroll_handle_hold_event (GtkEventController *controller,
break; break;
} }
return handled; return GDK_EVENT_PROPAGATE;
} }
static gboolean static gboolean