From ea8226f1d3eb0bd0bc14cce278a261fb66c81ce8 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Wed, 14 Oct 2020 16:45:09 +0200 Subject: [PATCH] Restore seek on drop behavior --- clapper_src/app.js | 8 +------- clapper_src/controls.js | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/clapper_src/app.js b/clapper_src/app.js index cfd89f48..53a69a8c 100644 --- a/clapper_src/app.js +++ b/clapper_src/app.js @@ -163,13 +163,7 @@ var App = GObject.registerClass({ this.player.widget.width_request = 960; this.player.widget.height_request = 540; -/* - this.player.widget.add_events( - Gdk.EventMask.SCROLL_MASK - | Gdk.EventMask.ENTER_NOTIFY_MASK - | Gdk.EventMask.LEAVE_NOTIFY_MASK - ); -*/ + this.interface.addPlayer(this.player); this.player.connect('state-changed', this._onPlayerStateChanged.bind(this)); diff --git a/clapper_src/controls.js b/clapper_src/controls.js index dc368ffd..96608eb2 100644 --- a/clapper_src/controls.js +++ b/clapper_src/controls.js @@ -203,14 +203,14 @@ var Controls = GObject.registerClass({ this.positionScale.add_css_class('positionscale'); this.positionScale.connect('value-changed', this._onPositionScaleValueChanged.bind(this)); -/* + + /* GTK4 is missing pressed/released signals for GtkRange/GtkScale. + * We cannot add controllers, cause it already has them, so we + * workaround this by observing css classes it currently has */ this.positionScale.connect( - 'button-press-event', this._onPositionScaleButtonPressEvent.bind(this) + 'notify::css-classes', this._onPositionScaleDragging.bind(this) ); - this.positionScale.connect( - 'button-release-event', this._onPositionScaleButtonReleaseEvent.bind(this) - ); -*/ + this.positionAdjustment = this.positionScale.get_adjustment(); this.append(this.positionScale); } @@ -295,15 +295,14 @@ var Controls = GObject.registerClass({ this.elapsedButton.set_label(elapsed); } - _onPositionScaleButtonPressEvent() + _onPositionScaleDragging(scale) { - this.isPositionSeeking = true; - this.emit('position-seeking-changed', this.isPositionSeeking); - } + let isPositionSeeking = scale.has_css_class('dragging'); - _onPositionScaleButtonReleaseEvent() - { - this.isPositionSeeking = false; + if(this.isPositionSeeking === isPositionSeeking) + return; + + this.isPositionSeeking = isPositionSeeking; this.emit('position-seeking-changed', this.isPositionSeeking); }