Always show focus indicator if focused

This commit is contained in:
Soreepeong 2024-03-01 00:46:23 +09:00
parent 6b875bbcb5
commit 16022ea46a

View file

@ -75,14 +75,21 @@ internal sealed partial class ActiveNotification
ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoFocusOnAppearing |
ImGuiWindowFlags.NoDocking); ImGuiWindowFlags.NoDocking);
var isTakingKeyboardInput = ImGui.IsWindowFocused() && ImGui.GetIO().WantTextInput; var isFocused = ImGui.IsWindowFocused();
var isHovered = ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem); var isHovered = ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
var isTakingKeyboardInput = isFocused && ImGui.GetIO().WantTextInput;
var warrantsExtension = var warrantsExtension =
this.ExtensionDurationSinceLastInterest > TimeSpan.Zero this.ExtensionDurationSinceLastInterest > TimeSpan.Zero
&& (isHovered || isTakingKeyboardInput); && (isHovered || isTakingKeyboardInput);
this.EffectiveExpiry = this.CalculateEffectiveExpiry(ref warrantsExtension); this.EffectiveExpiry = this.CalculateEffectiveExpiry(ref warrantsExtension);
if (!isTakingKeyboardInput && !isHovered && isFocused)
{
ImGui.SetWindowFocus(null);
isFocused = false;
}
if (DateTime.Now > this.EffectiveExpiry) if (DateTime.Now > this.EffectiveExpiry)
this.DismissNow(NotificationDismissReason.Timeout); this.DismissNow(NotificationDismissReason.Timeout);
@ -105,8 +112,8 @@ internal sealed partial class ActiveNotification
ImGui.PopStyleVar(); ImGui.PopStyleVar();
} }
if (isTakingKeyboardInput) if (isFocused)
this.DrawKeyboardInputIndicator(); this.DrawFocusIndicator();
this.DrawExpiryBar(this.EffectiveExpiry, warrantsExtension); this.DrawExpiryBar(this.EffectiveExpiry, warrantsExtension);
if (ImGui.IsWindowHovered()) if (ImGui.IsWindowHovered())
@ -218,7 +225,7 @@ internal sealed partial class ActiveNotification
ImGui.PopClipRect(); ImGui.PopClipRect();
} }
private void DrawKeyboardInputIndicator() private void DrawFocusIndicator()
{ {
var windowPos = ImGui.GetWindowPos(); var windowPos = ImGui.GetWindowPos();
var windowSize = ImGui.GetWindowSize(); var windowSize = ImGui.GetWindowSize();