Log windowSystem focus changes

This commit is contained in:
Raymond 2021-09-03 06:39:31 -04:00
parent 3e1a018799
commit 2c6834b4ba

View file

@ -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<Window> windows = new();
private string lastFocusedWindowName = string.Empty;
/// <summary>
/// Initializes a new instance of the <see cref="WindowSystem"/> class.
/// </summary>
@ -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();