mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Hide both cursor and overlays with a single timer
Simplify hide controls logic code by using single timer to hide both cursor and video overlays at once
This commit is contained in:
@@ -31,7 +31,6 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
this._maxVolume = Misc.getLinearValue(Misc.maxVolume);
|
this._maxVolume = Misc.getLinearValue(Misc.maxVolume);
|
||||||
|
|
||||||
this._hideCursorTimeout = null;
|
|
||||||
this._hideControlsTimeout = null;
|
this._hideControlsTimeout = null;
|
||||||
this._updateTimeTimeout = null;
|
this._updateTimeTimeout = null;
|
||||||
|
|
||||||
@@ -316,11 +315,11 @@ class ClapperPlayer extends PlayerBase
|
|||||||
return clapperWidget.fullscreenMode;
|
return clapperWidget.fullscreenMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
_setHideCursorTimeout()
|
_setHideControlsTimeout()
|
||||||
{
|
{
|
||||||
this._clearTimeout('hideCursor');
|
this._clearTimeout('hideControls');
|
||||||
this._hideCursorTimeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
|
this._hideControlsTimeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 2, () => {
|
||||||
this._hideCursorTimeout = null;
|
this._hideControlsTimeout = null;
|
||||||
|
|
||||||
if(this.cursorInPlayer) {
|
if(this.cursorInPlayer) {
|
||||||
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
@@ -328,24 +327,11 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
this.widget.set_cursor(blankCursor);
|
this.widget.set_cursor(blankCursor);
|
||||||
clapperWidget.revealerTop.set_cursor(blankCursor);
|
clapperWidget.revealerTop.set_cursor(blankCursor);
|
||||||
}
|
|
||||||
|
|
||||||
return GLib.SOURCE_REMOVE;
|
if(clapperWidget.fullscreenMode)
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_setHideControlsTimeout()
|
|
||||||
{
|
|
||||||
this._clearTimeout('hideControls');
|
|
||||||
this._hideControlsTimeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3, () => {
|
|
||||||
this._hideControlsTimeout = null;
|
|
||||||
|
|
||||||
if(this.cursorInPlayer) {
|
|
||||||
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
|
||||||
if(clapperWidget.fullscreenMode) {
|
|
||||||
this._clearTimeout('updateTime');
|
this._clearTimeout('updateTime');
|
||||||
clapperWidget.revealControls(false);
|
|
||||||
}
|
clapperWidget.revealControls(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
@@ -641,18 +627,13 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this.cursorInPlayer = true;
|
this.cursorInPlayer = true;
|
||||||
this.isWidgetDragging = false;
|
this.isWidgetDragging = false;
|
||||||
|
|
||||||
this._setHideCursorTimeout();
|
this._setHideControlsTimeout();
|
||||||
|
|
||||||
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
|
||||||
if(clapperWidget.fullscreenMode)
|
|
||||||
this._setHideControlsTimeout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onWidgetLeave(controller)
|
_onWidgetLeave(controller)
|
||||||
{
|
{
|
||||||
this.cursorInPlayer = false;
|
this.cursorInPlayer = false;
|
||||||
|
|
||||||
this._clearTimeout('hideCursor');
|
|
||||||
this._clearTimeout('hideControls');
|
this._clearTimeout('hideControls');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,20 +655,15 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
this.widget.set_cursor(defaultCursor);
|
this.widget.set_cursor(defaultCursor);
|
||||||
clapperWidget.revealerTop.set_cursor(defaultCursor);
|
clapperWidget.revealerTop.set_cursor(defaultCursor);
|
||||||
this._setHideCursorTimeout();
|
|
||||||
|
this._setHideControlsTimeout();
|
||||||
|
|
||||||
if(clapperWidget.fullscreenMode) {
|
if(clapperWidget.fullscreenMode) {
|
||||||
if(!this._updateTimeTimeout)
|
if(!this._updateTimeTimeout)
|
||||||
this._setUpdateTimeInterval();
|
this._setUpdateTimeInterval();
|
||||||
|
|
||||||
this._setHideControlsTimeout();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(this._hideControlsTimeout)
|
|
||||||
this._clearTimeout('hideControls');
|
|
||||||
if(this._updateTimeTimeout)
|
|
||||||
this._clearTimeout('updateTime');
|
|
||||||
}
|
}
|
||||||
|
else if(this._updateTimeTimeout)
|
||||||
|
this._clearTimeout('updateTime');
|
||||||
|
|
||||||
if(!clapperWidget.revealerTop.get_reveal_child()) {
|
if(!clapperWidget.revealerTop.get_reveal_child()) {
|
||||||
/* Do not grab controls key focus on mouse movement */
|
/* Do not grab controls key focus on mouse movement */
|
||||||
|
Reference in New Issue
Block a user