Restore automatic menu hiding

This commit is contained in:
Rafostar
2020-10-14 10:57:43 +02:00
parent 1f6a9b59d6
commit 1069f151f0
2 changed files with 25 additions and 77 deletions

View File

@@ -117,7 +117,7 @@ var App = GObject.registerClass({
this.hideControlsTimeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3, () => { this.hideControlsTimeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3, () => {
this.hideControlsTimeout = null; this.hideControlsTimeout = null;
if(this.window.isFullscreen && this.isCursorInPlayer) { if(this.window.isFullscreen && this.player.motionController.is_pointer) {
this.clearTimeout('updateTime'); this.clearTimeout('updateTime');
this.interface.revealControls(false); this.interface.revealControls(false);
} }
@@ -176,17 +176,15 @@ var App = GObject.registerClass({
this.player.clickGesture.connect( this.player.clickGesture.connect(
'pressed', this._onPlayerPressed.bind(this) 'pressed', this._onPlayerPressed.bind(this)
); );
/*
this.player.connectWidget(
'enter-notify-event', this._onPlayerEnterNotifyEvent.bind(this)
);
this.player.connectWidget(
'leave-notify-event', this._onPlayerLeaveNotifyEvent.bind(this)
);
*/
this.player.keyController.connect( this.player.keyController.connect(
'key-pressed', this._onPlayerKeyPressed.bind(this) 'key-pressed', this._onPlayerKeyPressed.bind(this)
); );
this.player.motionController.connect(
'enter', this._onPlayerEnter.bind(this)
);
this.player.motionController.connect(
'leave', this._onPlayerLeave.bind(this)
);
this.player.motionController.connect( this.player.motionController.connect(
'motion', this._onPlayerMotion.bind(this) 'motion', this._onPlayerMotion.bind(this)
); );
@@ -327,19 +325,15 @@ var App = GObject.registerClass({
} }
} }
_onPlayerEnterNotifyEvent(self, event) _onPlayerEnter(controller, x, y)
{ {
this.isCursorInPlayer = true;
this.setHideCursorTimeout(); this.setHideCursorTimeout();
if(this.window.isFullscreen) if(this.window.isFullscreen)
this.setHideControlsTimeout(); this.setHideControlsTimeout();
} }
_onPlayerLeaveNotifyEvent(self, event) _onPlayerLeave(controller)
{ {
this.isCursorInPlayer = false;
this.clearTimeout('hideCursor'); this.clearTimeout('hideCursor');
this.clearTimeout('hideControls'); this.clearTimeout('hideControls');
} }

View File

@@ -26,10 +26,7 @@ class ClapperCustomRevealer extends Gtk.Revealer
{ {
if(isReveal) { if(isReveal) {
this._clearTimeout(); this._clearTimeout();
if(!this.visible) this.set_visible(isReveal);
this.show();
this._setShowTimeout();
} }
else else
this._setHideTimeout(); this._setHideTimeout();
@@ -37,68 +34,37 @@ class ClapperCustomRevealer extends Gtk.Revealer
this._timedReveal(isReveal, REVEAL_TIME); this._timedReveal(isReveal, REVEAL_TIME);
} }
show()
{
if(this.visible)
return;
// Decreased size = lower CPU usage
this._setTopAlign('START');
super.show();
debug(`showing ${this.revealerName} revealer in drawing area`);
}
hide()
{
if(!this.visible)
return;
super.hide();
debug(`removed ${this.revealerName} revealer from drawing area`);
}
showChild(isReveal) showChild(isReveal)
{ {
this._clearTimeout(); this._clearTimeout();
this.set_visible(isReveal);
if(isReveal)
this.show();
else if(!isReveal)
this.hide();
this._timedReveal(isReveal, 0); this._timedReveal(isReveal, 0);
} }
set_visible(isVisible)
{
if(this.visible === isVisible)
return;
super.set_visible(isVisible);
debug(`${this.revealerName} revealer visible: ${isVisible}`);
}
_timedReveal(isReveal, time) _timedReveal(isReveal, time)
{ {
this.set_transition_duration(time); this.set_transition_duration(time);
this.set_reveal_child(isReveal); this.set_reveal_child(isReveal);
} }
// Drawing revealers on top of video frames /* Drawing revealers on top of video frames
// increases CPU usage, so we hide them * increases CPU usage, so we hide them */
_setHideTimeout() _setHideTimeout()
{ {
this._clearTimeout(); this._clearTimeout();
this._setTopAlign('FILL');
this._revealerTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, REVEAL_TIME + 20, () => { this._revealerTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, REVEAL_TIME + 20, () => {
this._revealerTimeout = null; this._revealerTimeout = null;
this.hide(); this.set_visible(false);
return GLib.SOURCE_REMOVE;
});
}
_setShowTimeout()
{
this._clearTimeout();
this._setTopAlign('FILL');
this._revealerTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, REVEAL_TIME + 20, () => {
this._revealerTimeout = null;
this._setTopAlign('START');
return GLib.SOURCE_REMOVE; return GLib.SOURCE_REMOVE;
}); });
@@ -112,17 +78,6 @@ class ClapperCustomRevealer extends Gtk.Revealer
GLib.source_remove(this._revealerTimeout); GLib.source_remove(this._revealerTimeout);
this._revealerTimeout = null; this._revealerTimeout = null;
} }
_setTopAlign(align)
{
if(
this.revealerName !== 'top'
|| this.valign === Gtk.Align[align]
)
return;
this.valign = Gtk.Align[align];
}
}); });
var RevealerTop = GObject.registerClass( var RevealerTop = GObject.registerClass(
@@ -186,7 +141,6 @@ class ClapperRevealerTop extends CustomRevealer
this.revealerGrid.attach(this.endTime, 1, 0, 1, 1); this.revealerGrid.attach(this.endTime, 1, 0, 1, 1);
this.set_child(this.revealerGrid); this.set_child(this.revealerGrid);
//this.revealerGrid.show_all();
} }
setMediaTitle(title) setMediaTitle(title)
@@ -202,8 +156,8 @@ class ClapperRevealerTop extends CustomRevealer
this.currentTime.set_label(now); this.currentTime.set_label(now);
this.endTime.set_label(end); this.endTime.set_label(end);
// Make sure that next timeout is always run after clock changes, /* Make sure that next timeout is always run after clock changes,
// by delaying it for additional few milliseconds * by delaying it for additional few milliseconds */
let nextUpdate = 60002 - parseInt(currTime.get_seconds() * 1000); let nextUpdate = 60002 - parseInt(currTime.get_seconds() * 1000);
debug(`updated current time: ${now}`); debug(`updated current time: ${now}`);