2 Commits

Author SHA1 Message Date
Rafał Dzięgiel
d8b9773210 clapper-gtk: Pause video when dragging
Before we can do actual scrubbing, we need to pause playback and do seeks
while it is paused. Then restore playing state after dragging ends.
2024-04-07 20:47:08 +02:00
Rafał Dzięgiel
b282f3c1d2 clapper-app: Do not trigger default scroll handler on GtkRange
In addition to GtkScrolledWindow, when also hovering over GtkRange
subclassing widgets like GtkScale, do not trigger accidentally
default app window scroll handler.

We want the hovered upon widget and only that widget to handle scroll
events in such case.
2024-04-07 20:13:25 +02:00
2 changed files with 20 additions and 5 deletions

View File

@@ -471,11 +471,14 @@ scroll_cb (GtkEventControllerScroll *scroll,
pickup = _pick_pointer_widget (self);
/* We do not want to accidentally allow this controller
* to handle scrolls when hovering over scrolled window */
if (pickup && (GTK_IS_SCROLLED_WINDOW (pickup)
|| gtk_widget_get_ancestor (pickup, GTK_TYPE_SCROLLED_WINDOW)))
return FALSE;
/* We do not want to accidentally allow this controller to handle
* scrolls when hovering over widgets that also handle scroll */
while ((pickup && !CLAPPER_GTK_IS_VIDEO (pickup))) {
if (GTK_IS_SCROLLED_WINDOW (pickup) || GTK_IS_RANGE (pickup))
return FALSE;
pickup = gtk_widget_get_parent (pickup);
}
device = gtk_event_controller_get_current_event_device (GTK_EVENT_CONTROLLER (scroll));

View File

@@ -57,6 +57,7 @@ struct _ClapperGtkSeekBar
gboolean can_scrub;
gboolean scrubbing;
gboolean was_playing;
gboolean dragging;
guint position_uint;
@@ -267,6 +268,14 @@ scale_css_classes_changed_cb (GtkWidget *widget,
if ((self->dragging = dragging)) {
GST_DEBUG_OBJECT (self, "Scale drag started");
if (G_LIKELY (self->player != NULL)) {
ClapperPlayerState state = clapper_player_get_state (self->player);
if ((self->was_playing = (state == CLAPPER_PLAYER_STATE_PLAYING)))
clapper_player_pause (self->player);
}
return;
}
@@ -289,6 +298,9 @@ scale_css_classes_changed_cb (GtkWidget *widget,
} else {
clapper_player_seek_custom (self->player, value, self->seek_method);
}
if (self->was_playing)
clapper_player_play (self->player);
}
static void