diff --git a/clapper_src/buttons.js b/clapper_src/buttons.js index c635efad..7e829ab4 100644 --- a/clapper_src/buttons.js +++ b/clapper_src/buttons.js @@ -29,6 +29,15 @@ class ClapperCustomButton extends Gtk.Button this.margin_top = (isFullscreen) ? 6 : 4; this.isFullscreen = isFullscreen; } + + vfunc_clicked() + { + if(!this.isFullscreen) + return; + + let { player } = this.get_ancestor(Gtk.Grid); + player._setHideControlsTimeout(); + } }); var IconButton = GObject.registerClass( @@ -131,8 +140,9 @@ class ClapperPopoverButton extends IconButton vfunc_clicked() { - this.set_state_flags(Gtk.StateFlags.CHECKED, false); + super.vfunc_clicked(); + this.set_state_flags(Gtk.StateFlags.CHECKED, false); this.popover.set_parent(this); this.popover.popup(); } diff --git a/clapper_src/controls.js b/clapper_src/controls.js index 20d70f82..3e53409a 100644 --- a/clapper_src/controls.js +++ b/clapper_src/controls.js @@ -1,4 +1,4 @@ -const { GObject, Gtk } = imports.gi; +const { GObject, Gdk, Gtk } = imports.gi; const Buttons = imports.clapper_src.buttons; const Debug = imports.clapper_src.debug; const Misc = imports.clapper_src.misc; @@ -56,6 +56,11 @@ class ClapperControls extends Gtk.Box this.unfullscreenButton.connect('clicked', this._onUnfullscreenClicked.bind(this)); this.unfullscreenButton.set_visible(false); + let keyController = new Gtk.EventControllerKey(); + keyController.connect('key-pressed', this._onControlsKeyPressed.bind(this)); + keyController.connect('key-released', this._onControlsKeyReleased.bind(this)); + this.add_controller(keyController); + this.add_css_class('playercontrols'); this.realizeSignal = this.connect('realize', this._onRealize.bind(this)); } @@ -416,4 +421,27 @@ class ClapperControls extends Gtk.Box let positionSeconds = Math.round(scale.get_value()); clapperWidget.player.seek_seconds(positionSeconds); } + + /* Only happens when navigating through controls panel */ + _onControlsKeyPressed(controller, keyval, keycode, state) + { + let { player } = this.get_ancestor(Gtk.Grid); + player._setHideControlsTimeout(); + } + + _onControlsKeyReleased(controller, keyval, keycode, state) + { + switch(keyval) { + case Gdk.KEY_space: + case Gdk.KEY_Return: + case Gdk.KEY_Escape: + case Gdk.KEY_Right: + case Gdk.KEY_Left: + break; + default: + let { player } = this.get_ancestor(Gtk.Grid); + player._onWidgetKeyReleased(controller, keyval, keycode, state); + break; + } + } }); diff --git a/clapper_src/player.js b/clapper_src/player.js index eb280ee7..01291272 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -418,6 +418,7 @@ class ClapperPlayer extends GstPlayer.Player root.connect('close-request', this._onCloseRequest.bind(this)); } + /* Widget only - does not happen when using controls navigation */ _onWidgetKeyPressed(controller, keyval, keycode, state) { this.keyPressCount++; @@ -447,6 +448,7 @@ class ClapperPlayer extends GstPlayer.Player } } + /* Also happens after using controls navigation for selected keys */ _onWidgetKeyReleased(controller, keyval, keycode, state) { this.keyPressCount = 0;