UI: setting: Disable Input when Out of Focus

- chore: rename InputElement_OnGotFocus/OnLostFocus to fit what it's listening to better
This commit is contained in:
GreemDev authored and KeatonTheBot committed 2026-09-25 21:29:13 -05:00
1 parent a9bf7644eb
commit d765814a1b
19 files changed
+86 -2

No files matched your search

@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Platform;
using Avalonia.Threading;
@@ -749,5 +750,34 @@ namespace Ryujinx.Ava.UI.Windows
msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)FASymbol.Checkmark);
});
}
private void AppWindow_OnGotFocus(object sender, FocusChangedEventArgs e)
{
if (!_didDisableInputUpdates)
return;
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
return;
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: true } appHost)
return;
appHost.NpadManager.UnblockInputUpdates();
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
}
private bool _didDisableInputUpdates;
private void AppWindow_OnLostFocus(object sender, RoutedEventArgs e)
{
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
return;
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: false } appHost)
return;
appHost.NpadManager.BlockInputUpdates();
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
}
}
}