mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 04:53:12 +08:00
Merge pull request #16168 from peppy/windows-key-when-inactive
Avoid blocking windows key usage when the osu! window is not active
This commit is contained in:
commit
2ea31c26a5
@ -14,6 +14,7 @@ namespace osu.Desktop.Windows
|
|||||||
{
|
{
|
||||||
private Bindable<bool> disableWinKey;
|
private Bindable<bool> disableWinKey;
|
||||||
private IBindable<bool> localUserPlaying;
|
private IBindable<bool> localUserPlaying;
|
||||||
|
private IBindable<bool> isActive;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
@ -24,13 +25,16 @@ namespace osu.Desktop.Windows
|
|||||||
localUserPlaying = localUserInfo.IsPlaying.GetBoundCopy();
|
localUserPlaying = localUserInfo.IsPlaying.GetBoundCopy();
|
||||||
localUserPlaying.BindValueChanged(_ => updateBlocking());
|
localUserPlaying.BindValueChanged(_ => updateBlocking());
|
||||||
|
|
||||||
|
isActive = host.IsActive.GetBoundCopy();
|
||||||
|
isActive.BindValueChanged(_ => updateBlocking());
|
||||||
|
|
||||||
disableWinKey = config.GetBindable<bool>(OsuSetting.GameplayDisableWinKey);
|
disableWinKey = config.GetBindable<bool>(OsuSetting.GameplayDisableWinKey);
|
||||||
disableWinKey.BindValueChanged(_ => updateBlocking(), true);
|
disableWinKey.BindValueChanged(_ => updateBlocking(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBlocking()
|
private void updateBlocking()
|
||||||
{
|
{
|
||||||
bool shouldDisable = disableWinKey.Value && localUserPlaying.Value;
|
bool shouldDisable = isActive.Value && disableWinKey.Value && localUserPlaying.Value;
|
||||||
|
|
||||||
if (shouldDisable)
|
if (shouldDisable)
|
||||||
host.InputThread.Scheduler.Add(WindowsKey.Disable);
|
host.InputThread.Scheduler.Add(WindowsKey.Disable);
|
||||||
|
Loading…
Reference in New Issue
Block a user