diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index 7f143edc3..ccfefd241 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using ImGuiNET; +using Serilog; namespace Dalamud.Interface.Windowing { @@ -15,6 +16,8 @@ namespace Dalamud.Interface.Windowing private readonly List windows = new(); + private string lastFocusedWindowName = string.Empty; + /// /// Initializes a new instance of the class. /// @@ -94,13 +97,28 @@ namespace Dalamud.Interface.Windowing window.DrawInternal(); } - this.HasAnyFocus = this.windows.Any(x => x.IsFocused && x.RespectCloseHotkey); + var focusedWindow = this.windows.FirstOrDefault(x => x.IsFocused && x.RespectCloseHotkey); + this.HasAnyFocus = focusedWindow != default; if (this.HasAnyFocus) { + if (this.lastFocusedWindowName != focusedWindow.WindowName) + { + Log.Verbose($"WindowSystem \"{this.Namespace}\" Window \"{focusedWindow.WindowName}\" has focus now"); + this.lastFocusedWindowName = focusedWindow.WindowName; + } + HasAnyWindowSystemFocus = true; lastAnyFocus = DateTimeOffset.Now; } + else + { + if (this.lastFocusedWindowName != string.Empty) + { + Log.Verbose($"WindowSystem \"{this.Namespace}\" Window \"{this.lastFocusedWindowName}\" lost focus"); + this.lastFocusedWindowName = string.Empty; + } + } if (hasNamespace) ImGui.PopID();