0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 23:25:46 +00:00

[GUI] Fix always hide cursor mode not hiding the cursor until it was moved (#4927)

* gtk: Add missing isMouseInClient check for hide-cursor

* ava: Add missing events and default isCursorInRenderer to true

This is necessary because we don't receive a initial PointerEnter event for some reason.
This commit is contained in:
TSRBerry 2023-05-14 16:34:31 +02:00 committed by GitHub
parent 17ba217940
commit 22202be394
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 20 deletions

View file

@ -86,7 +86,7 @@ namespace Ryujinx.Ava
private KeyboardHotkeyState _prevHotkeyState; private KeyboardHotkeyState _prevHotkeyState;
private long _lastCursorMoveTime; private long _lastCursorMoveTime;
private bool _isCursorInRenderer; private bool _isCursorInRenderer = true;
private bool _isStopped; private bool _isStopped;
private bool _isActive; private bool _isActive;
@ -160,7 +160,9 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.HideCursor.Event += HideCursorState_Changed; ConfigurationState.Instance.HideCursor.Event += HideCursorState_Changed;
_topLevel.PointerMoved += TopLevel_PointerMoved; _topLevel.PointerMoved += TopLevel_PointerEnterOrMoved;
_topLevel.PointerEnter += TopLevel_PointerEnterOrMoved;
_topLevel.PointerLeave += TopLevel_PointerLeave;
if (OperatingSystem.IsWindows()) if (OperatingSystem.IsWindows())
{ {
@ -183,7 +185,7 @@ namespace Ryujinx.Ava
_gpuCancellationTokenSource = new CancellationTokenSource(); _gpuCancellationTokenSource = new CancellationTokenSource();
} }
private void TopLevel_PointerMoved(object sender, PointerEventArgs e) private void TopLevel_PointerEnterOrMoved(object sender, PointerEventArgs e)
{ {
if (sender is MainWindow window) if (sender is MainWindow window)
{ {
@ -201,6 +203,12 @@ namespace Ryujinx.Ava
} }
} }
} }
private void TopLevel_PointerLeave(object sender, PointerEventArgs e)
{
_isCursorInRenderer = false;
}
private void UpdateScalingFilterLevel(object sender, ReactiveEventArgs<int> e) private void UpdateScalingFilterLevel(object sender, ReactiveEventArgs<int> e)
{ {
_renderer.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value); _renderer.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
@ -446,7 +454,9 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel; ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAntiAliasing; ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAntiAliasing;
_topLevel.PointerMoved -= TopLevel_PointerMoved; _topLevel.PointerMoved -= TopLevel_PointerEnterOrMoved;
_topLevel.PointerEnter -= TopLevel_PointerEnterOrMoved;
_topLevel.PointerLeave -= TopLevel_PointerLeave;
_gpuCancellationTokenSource.Cancel(); _gpuCancellationTokenSource.Cancel();
_gpuCancellationTokenSource.Dispose(); _gpuCancellationTokenSource.Dispose();

View file

@ -321,27 +321,27 @@ namespace Ryujinx.Ui
_toggleDockedMode = toggleDockedMode; _toggleDockedMode = toggleDockedMode;
if (ConfigurationState.Instance.Hid.EnableMouse.Value) if (_isMouseInClient)
{ {
if (_isMouseInClient) if (ConfigurationState.Instance.Hid.EnableMouse.Value)
{ {
Window.Cursor = _invisibleCursor; Window.Cursor = _invisibleCursor;
} }
} else
else
{
switch (_hideCursorMode)
{ {
case HideCursorMode.OnIdle: switch (_hideCursorMode)
long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime; {
Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null; case HideCursorMode.OnIdle:
break; long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime;
case HideCursorMode.Always: Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null;
Window.Cursor = _invisibleCursor; break;
break; case HideCursorMode.Always:
case HideCursorMode.Never: Window.Cursor = _invisibleCursor;
Window.Cursor = null; break;
break; case HideCursorMode.Never:
Window.Cursor = null;
break;
}
} }
} }
} }