Hide Cursor On Idle (#1993)
* Implement "Hide Cursor On Idle" option Adds a general option to autohide the cursor after 8s have elapsed. * Fix cursor not hiding on Windows and dispose it * Don't dispose cursor, fix var names * Abide by the GNOME documentation * Fix nits * Disabled by default, make it so it doesn't utilize any timer * Remove *NIX time and extra lines * Don't calculate if option is disabled * Move if case * Fix alignment
This commit is contained in:
parent
80ed8596c1
commit
6f1d964801
7 changed files with 97 additions and 5 deletions
|
@ -42,6 +42,8 @@ namespace Ryujinx.Ui
|
|||
private double _mouseY;
|
||||
private bool _mousePressed;
|
||||
|
||||
private DateTime _lastCursorMoveTime = DateTime.Now;
|
||||
|
||||
private bool _toggleFullscreen;
|
||||
private bool _toggleDockedMode;
|
||||
|
||||
|
@ -62,6 +64,8 @@ namespace Ryujinx.Ui
|
|||
private GraphicsDebugLevel _glLogLevel;
|
||||
|
||||
private readonly ManualResetEvent _exitEvent;
|
||||
|
||||
private Gdk.Cursor _invisibleCursor = new Gdk.Cursor (Gdk.Display.Default, Gdk.CursorType.BlankCursor);
|
||||
|
||||
public GlRenderer(Switch device, GraphicsDebugLevel glLogLevel)
|
||||
: base (GetGraphicsMode(),
|
||||
|
@ -304,9 +308,37 @@ namespace Ryujinx.Ui
|
|||
_mouseY = evnt.Y;
|
||||
}
|
||||
|
||||
ResetCursorIdle();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ResetCursorIdle()
|
||||
{
|
||||
if (ConfigurationState.Instance.HideCursorOnIdle)
|
||||
{
|
||||
_lastCursorMoveTime = DateTime.Now;
|
||||
}
|
||||
|
||||
if (Window.Cursor != null)
|
||||
{
|
||||
Window.Cursor = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void HideCursorIdle()
|
||||
{
|
||||
if (ConfigurationState.Instance.HideCursorOnIdle)
|
||||
{
|
||||
TimeSpan elapsedTime = DateTime.Now.Subtract(_lastCursorMoveTime);
|
||||
|
||||
if (elapsedTime.TotalSeconds > 8)
|
||||
{
|
||||
Gtk.Application.Invoke(delegate { Window.Cursor = _invisibleCursor; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnGetPreferredHeight(out int minimumHeight, out int naturalHeight)
|
||||
{
|
||||
Gdk.Monitor monitor = Display.GetMonitorAtWindow(Window);
|
||||
|
@ -485,6 +517,8 @@ namespace Ryujinx.Ui
|
|||
|
||||
MotionDevice motionDevice = new MotionDevice(_dsuClient);
|
||||
|
||||
HideCursorIdle();
|
||||
|
||||
foreach (InputConfig inputConfig in ConfigurationState.Instance.Hid.InputConfig.Value)
|
||||
{
|
||||
ControllerKeys currentButton = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue