diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs index 3c7cf684a..94f6d3f87 100644 --- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs +++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs @@ -6,6 +6,7 @@ using CheapLoc; using Dalamud.Configuration.Internal; using Dalamud.Hooking; using Dalamud.Interface.Internal; +using Dalamud.Interface.Windowing; using FFXIVClientStructs.FFXIV.Component.GUI; using Serilog; @@ -75,10 +76,8 @@ namespace Dalamud.Game.Internal private IntPtr AtkUnitBaseReceiveGlobalEventDetour(AtkUnitBase* thisPtr, ushort cmd, uint a3, IntPtr a4, uint* a5) { - var di = Service.Get(); - // "Close Addon" - if (cmd == 12 && di.WindowSystem.HasAnyFocus) + if (cmd == 12 && WindowSystem.HasAnyWindowSystemFocus) return IntPtr.Zero; return this.hookAtkUnitBaseReceiveGlobalEvent.Original(thisPtr, cmd, a3, a4, a5); diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 82d48f44a..a82204651 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -16,6 +16,7 @@ using Dalamud.Game.Internal.DXGI; using Dalamud.Hooking; using Dalamud.Hooking.Internal; using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.Windowing; using Dalamud.Utility; using ImGuiNET; using ImGuiScene; @@ -639,6 +640,8 @@ namespace Dalamud.Interface.Internal this.LastImGuiIoPtr = ImGui.GetIO(); this.lastWantCapture = this.LastImGuiIoPtr.WantCaptureMouse; + WindowSystem.HasAnyWindowSystemFocus = false; + this.Draw?.Invoke(); Service.Get().Draw(); } diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index a87a6b2fa..9b062bc1b 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -17,11 +17,17 @@ namespace Dalamud.Interface.Windowing /// Initializes a new instance of the class. /// /// The name/ID-space of this . - public WindowSystem(string imNamespace = null) + public WindowSystem(string? imNamespace = null) { this.Namespace = imNamespace; } + /// + /// Gets a value indicating whether any contains any + /// that has focus and is not marked to be excluded from consideration. + /// + public static bool HasAnyWindowSystemFocus { get; internal set; } + /// /// Gets a value indicating whether any window in this has focus and is /// not marked to be excluded from consideration. @@ -31,7 +37,7 @@ namespace Dalamud.Interface.Windowing /// /// Gets or sets the name/ID-space of this . /// - public string Namespace { get; set; } + public string? Namespace { get; set; } /// /// Add a window to this . @@ -83,6 +89,9 @@ namespace Dalamud.Interface.Windowing this.HasAnyFocus = this.windows.Any(x => x.IsFocused && x.RespectCloseHotkey); + if (this.HasAnyFocus) + HasAnyWindowSystemFocus = true; + if (hasNamespace) ImGui.PopID(); }