Avoid blocking windows key usage when the osu! window is not active

As discussed in https://github.com/ppy/osu/discussions/16147.
This commit is contained in:
Dean Herbert 2021-12-20 17:38:14 +09:00
parent 51386bb48d
commit 090c3e84e7
1 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ public class GameplayWinKeyBlocker : Component
{
private Bindable<bool> disableWinKey;
private IBindable<bool> localUserPlaying;
private IBindable<bool> isActive;
[Resolved]
private GameHost host { get; set; }
@ -24,13 +25,16 @@ private void load(ILocalUserPlayInfo localUserInfo, OsuConfigManager config)
localUserPlaying = localUserInfo.IsPlaying.GetBoundCopy();
localUserPlaying.BindValueChanged(_ => updateBlocking());
isActive = host.IsActive.GetBoundCopy();
isActive.BindValueChanged(_ => updateBlocking());
disableWinKey = config.GetBindable<bool>(OsuSetting.GameplayDisableWinKey);
disableWinKey.BindValueChanged(_ => updateBlocking(), true);
}
private void updateBlocking()
{
bool shouldDisable = disableWinKey.Value && localUserPlaying.Value;
bool shouldDisable = isActive.Value && disableWinKey.Value && localUserPlaying.Value;
if (shouldDisable)
host.InputThread.Scheduler.Add(WindowsKey.Disable);