From d86a116e1e936594e6b375098ab52120a1b67d29 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Fri, 8 Jul 2022 18:16:30 +0000 Subject: [PATCH] ensure mouse cursor is only hidden when mouse is in renderer (#3448) --- Ryujinx.Ava/AppHost.cs | 25 ++++++++-------------- Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs | 1 + 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Ryujinx.Ava/AppHost.cs b/Ryujinx.Ava/AppHost.cs index 518b2ffcf2..55693ed381 100644 --- a/Ryujinx.Ava/AppHost.cs +++ b/Ryujinx.Ava/AppHost.cs @@ -77,7 +77,7 @@ namespace Ryujinx.Ava private IRenderer _renderer; private readonly Thread _renderingThread; - private bool _isMouseInClient; + private bool _isMouseInRenderer; private bool _renderingStarted; private bool _dialogShown; @@ -142,7 +142,6 @@ namespace Ryujinx.Ava ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorState_Changed; - _parent.PointerEnter += Parent_PointerEntered; _parent.PointerLeave += Parent_PointerLeft; _parent.PointerMoved += Parent_PointerMoved; @@ -157,18 +156,15 @@ namespace Ryujinx.Ava private void Parent_PointerMoved(object sender, PointerEventArgs e) { _lastCursorMoveTime = Stopwatch.GetTimestamp(); + var p = e.GetCurrentPoint(_parent).Position; + var r = _parent.InputHitTest(p); + _isMouseInRenderer = r == Renderer; } private void Parent_PointerLeft(object sender, PointerEventArgs e) { - Renderer.Cursor = ConfigurationState.Instance.Hid.EnableMouse ? InvisibleCursor : Cursor.Default; - - _isMouseInClient = false; - } - - private void Parent_PointerEntered(object sender, PointerEventArgs e) - { - _isMouseInClient = true; + _isMouseInRenderer = false; + _parent.Cursor = Cursor.Default; } private void SetRendererWindowSize(Size size) @@ -898,13 +894,10 @@ namespace Ryujinx.Ava { if (ConfigurationState.Instance.Hid.EnableMouse) { - if (_isMouseInClient) + Dispatcher.UIThread.Post(() => { - Dispatcher.UIThread.Post(() => - { - _parent.Cursor = InvisibleCursor; - }); - } + _parent.Cursor = _isMouseInRenderer ? InvisibleCursor : Cursor.Default; + }); } else { diff --git a/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs index 48e0b04849..bea84e3b50 100644 --- a/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs @@ -376,6 +376,7 @@ namespace Ryujinx.Ava.Ui.Windows ViewModel.ShowContent = true; ViewModel.ShowLoadProgress = false; ViewModel.IsLoadingIndeterminate = false; + Cursor = Cursor.Default; AppHost = null;