ensure mouse cursor is only hidden when mouse is in renderer (#3448)

This commit is contained in:
Emmanuel Hansen 2022-07-08 18:16:30 +00:00 committed by GitHub
parent 4c2ab880ef
commit d86a116e1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 16 deletions

View File

@ -77,7 +77,7 @@ namespace Ryujinx.Ava
private IRenderer _renderer; private IRenderer _renderer;
private readonly Thread _renderingThread; private readonly Thread _renderingThread;
private bool _isMouseInClient; private bool _isMouseInRenderer;
private bool _renderingStarted; private bool _renderingStarted;
private bool _dialogShown; private bool _dialogShown;
@ -142,7 +142,6 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorState_Changed; ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorState_Changed;
_parent.PointerEnter += Parent_PointerEntered;
_parent.PointerLeave += Parent_PointerLeft; _parent.PointerLeave += Parent_PointerLeft;
_parent.PointerMoved += Parent_PointerMoved; _parent.PointerMoved += Parent_PointerMoved;
@ -157,18 +156,15 @@ namespace Ryujinx.Ava
private void Parent_PointerMoved(object sender, PointerEventArgs e) private void Parent_PointerMoved(object sender, PointerEventArgs e)
{ {
_lastCursorMoveTime = Stopwatch.GetTimestamp(); _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) private void Parent_PointerLeft(object sender, PointerEventArgs e)
{ {
Renderer.Cursor = ConfigurationState.Instance.Hid.EnableMouse ? InvisibleCursor : Cursor.Default; _isMouseInRenderer = false;
_parent.Cursor = Cursor.Default;
_isMouseInClient = false;
}
private void Parent_PointerEntered(object sender, PointerEventArgs e)
{
_isMouseInClient = true;
} }
private void SetRendererWindowSize(Size size) private void SetRendererWindowSize(Size size)
@ -898,13 +894,10 @@ namespace Ryujinx.Ava
{ {
if (ConfigurationState.Instance.Hid.EnableMouse) if (ConfigurationState.Instance.Hid.EnableMouse)
{ {
if (_isMouseInClient) Dispatcher.UIThread.Post(() =>
{ {
Dispatcher.UIThread.Post(() => _parent.Cursor = _isMouseInRenderer ? InvisibleCursor : Cursor.Default;
{ });
_parent.Cursor = InvisibleCursor;
});
}
} }
else else
{ {

View File

@ -376,6 +376,7 @@ namespace Ryujinx.Ava.Ui.Windows
ViewModel.ShowContent = true; ViewModel.ShowContent = true;
ViewModel.ShowLoadProgress = false; ViewModel.ShowLoadProgress = false;
ViewModel.IsLoadingIndeterminate = false; ViewModel.IsLoadingIndeterminate = false;
Cursor = Cursor.Default;
AppHost = null; AppHost = null;