aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx/Ui/RendererWidgetBase.cs
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-05-02 03:29:47 +0200
committerGitHub <noreply@github.com>2023-05-02 03:29:47 +0200
commitdd574146fb5f05c1c0a469a4ad4a20c46bb37d74 (patch)
tree581cf26bcc2a5a31da00a66fd3255cfd489faced /src/Ryujinx/Ui/RendererWidgetBase.cs
parent2c94ac455ead867aac0a7a689a55d814a8bcc0da (diff)
Add hide-cursor command line argument & always hide cursor option (#4613)1.1.743
* Add hide-cursor command line argument * gtk: Adjust SettingsWindow for hide cursor options * ava: Adjust SettingsWindow for hide cursor options * ava: Add override check for HideCursor arg * Remove copy&paste sins * ava: Leave a little more room between the options * gtk: Fix hide cursor issues * ava: Only hide cursor if it's within the embedded window
Diffstat (limited to 'src/Ryujinx/Ui/RendererWidgetBase.cs')
-rw-r--r--src/Ryujinx/Ui/RendererWidgetBase.cs59
1 files changed, 39 insertions, 20 deletions
diff --git a/src/Ryujinx/Ui/RendererWidgetBase.cs b/src/Ryujinx/Ui/RendererWidgetBase.cs
index 65afa6e4..0fa7240b 100644
--- a/src/Ryujinx/Ui/RendererWidgetBase.cs
+++ b/src/Ryujinx/Ui/RendererWidgetBase.cs
@@ -72,7 +72,7 @@ namespace Ryujinx.Ui
const int CursorHideIdleTime = 5; // seconds
private static readonly Cursor _invisibleCursor = new Cursor(Display.Default, CursorType.BlankCursor);
private long _lastCursorMoveTime;
- private bool _hideCursorOnIdle;
+ private HideCursorMode _hideCursorMode;
private InputManager _inputManager;
private IKeyboard _keyboardInterface;
private GraphicsDebugLevel _glLogLevel;
@@ -113,10 +113,10 @@ namespace Ryujinx.Ui
_gpuCancellationTokenSource = new CancellationTokenSource();
- _hideCursorOnIdle = ConfigurationState.Instance.HideCursorOnIdle;
+ _hideCursorMode = ConfigurationState.Instance.HideCursor;
_lastCursorMoveTime = Stopwatch.GetTimestamp();
- ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorStateChanged;
+ ConfigurationState.Instance.HideCursor.Event += HideCursorStateChanged;
ConfigurationState.Instance.Graphics.AntiAliasing.Event += UpdateAnriAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
@@ -145,26 +145,32 @@ namespace Ryujinx.Ui
return Renderer.GetHardwareInfo().GpuVendor;
}
- private void HideCursorStateChanged(object sender, ReactiveEventArgs<bool> state)
+ private void HideCursorStateChanged(object sender, ReactiveEventArgs<HideCursorMode> state)
{
Application.Invoke(delegate
{
- _hideCursorOnIdle = state.NewValue;
+ _hideCursorMode = state.NewValue;
- if (_hideCursorOnIdle)
+ switch (_hideCursorMode)
{
- _lastCursorMoveTime = Stopwatch.GetTimestamp();
- }
- else
- {
- Window.Cursor = null;
+ case HideCursorMode.Never:
+ Window.Cursor = null;
+ break;
+ case HideCursorMode.OnIdle:
+ _lastCursorMoveTime = Stopwatch.GetTimestamp();
+ break;
+ case HideCursorMode.Always:
+ Window.Cursor = _invisibleCursor;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
}
});
}
private void Renderer_Destroyed(object sender, EventArgs e)
{
- ConfigurationState.Instance.HideCursorOnIdle.Event -= HideCursorStateChanged;
+ ConfigurationState.Instance.HideCursor.Event -= HideCursorStateChanged;
ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAnriAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event -= UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
@@ -180,7 +186,7 @@ namespace Ryujinx.Ui
protected override bool OnMotionNotifyEvent(EventMotion evnt)
{
- if (_hideCursorOnIdle)
+ if (_hideCursorMode == HideCursorMode.OnIdle)
{
_lastCursorMoveTime = Stopwatch.GetTimestamp();
}
@@ -315,15 +321,28 @@ namespace Ryujinx.Ui
_toggleDockedMode = toggleDockedMode;
- if (_hideCursorOnIdle && !ConfigurationState.Instance.Hid.EnableMouse)
+ if (ConfigurationState.Instance.Hid.EnableMouse.Value)
{
- long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime;
- Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null;
+ if (_isMouseInClient)
+ {
+ Window.Cursor = _invisibleCursor;
+ }
}
-
- if (ConfigurationState.Instance.Hid.EnableMouse && _isMouseInClient)
+ else
{
- Window.Cursor = _invisibleCursor;
+ switch (_hideCursorMode)
+ {
+ case HideCursorMode.OnIdle:
+ long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime;
+ Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null;
+ break;
+ case HideCursorMode.Always:
+ Window.Cursor = _invisibleCursor;
+ break;
+ case HideCursorMode.Never:
+ Window.Cursor = null;
+ break;
+ }
}
}
@@ -775,4 +794,4 @@ namespace Ryujinx.Ui
return state;
}
}
-}
+} \ No newline at end of file