From 05c95287237464a8b2ca8c7822469452a42bc022 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Wed, 14 Oct 2020 12:30:57 +0200 Subject: [PATCH] Auto change focus between player and controls --- clapper_src/revealers.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/clapper_src/revealers.js b/clapper_src/revealers.js index 73204289..3d52656c 100644 --- a/clapper_src/revealers.js +++ b/clapper_src/revealers.js @@ -44,10 +44,12 @@ class ClapperCustomRevealer extends Gtk.Revealer set_visible(isVisible) { if(this.visible === isVisible) - return; + return false; super.set_visible(isVisible); debug(`${this.revealerName} revealer visible: ${isVisible}`); + + return true; } _timedReveal(isReveal, time) @@ -192,4 +194,33 @@ class ClapperRevealerBottom extends CustomRevealer { this.revealerBox.remove(widget); } + + set_visible(isVisible) + { + let isChange = super.set_visible(isVisible); + if(!isChange) return; + + if(isVisible) { + let box = this.get_first_child(); + if(!box) return; + + let controls = box.get_first_child(); + if(!controls) return; + + let togglePlayButton = controls.get_first_child(); + if(togglePlayButton) { + togglePlayButton.grab_focus(); + debug('focus moved to toggle play button'); + } + } + else { + let parent = this.get_parent(); + let playerWidget = parent.get_first_child(); + + if(playerWidget) { + playerWidget.grab_focus(); + debug('focus moved to player widget'); + } + } + } });