mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-24 01:19:18 +01:00
fix: always set IsFocused to false when closing a window
This commit is contained in:
parent
395328eb17
commit
3f927ee7f0
4 changed files with 21 additions and 7 deletions
|
|
@ -76,6 +76,8 @@ namespace Dalamud.Game.Internal
|
||||||
|
|
||||||
private IntPtr AtkUnitBaseReceiveGlobalEventDetour(AtkUnitBase* thisPtr, ushort cmd, uint a3, IntPtr a4, uint* a5)
|
private IntPtr AtkUnitBaseReceiveGlobalEventDetour(AtkUnitBase* thisPtr, ushort cmd, uint a3, IntPtr a4, uint* a5)
|
||||||
{
|
{
|
||||||
|
Log.Information("{0}: cmd#{1} a3#{2} - HasAnyFocus:{3}", Marshal.PtrToStringAnsi(new IntPtr(thisPtr->Name)), cmd, a3, WindowSystem.HasAnyWindowSystemFocus);
|
||||||
|
|
||||||
// "Close Addon"
|
// "Close Addon"
|
||||||
if (cmd == 12 && WindowSystem.HasAnyWindowSystemFocus)
|
if (cmd == 12 && WindowSystem.HasAnyWindowSystemFocus)
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
|
||||||
|
|
@ -1082,6 +1082,10 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
|
ImGui.TextUnformatted($"WindowSystem.TimeSinceLastAnyFocus: {WindowSystem.TimeSinceLastAnyFocus.TotalMilliseconds:0}ms");
|
||||||
|
|
||||||
|
ImGui.Separator();
|
||||||
|
|
||||||
if (ImGui.Button("Add random notification"))
|
if (ImGui.Button("Add random notification"))
|
||||||
{
|
{
|
||||||
var rand = new Random();
|
var rand = new Random();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ using System.Numerics;
|
||||||
|
|
||||||
using Dalamud.Game.ClientState.Keys;
|
using Dalamud.Game.ClientState.Keys;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Windowing
|
namespace Dalamud.Interface.Windowing
|
||||||
{
|
{
|
||||||
|
|
@ -109,13 +111,7 @@ namespace Dalamud.Interface.Windowing
|
||||||
public bool IsOpen
|
public bool IsOpen
|
||||||
{
|
{
|
||||||
get => this.internalIsOpen;
|
get => this.internalIsOpen;
|
||||||
set
|
set => this.internalIsOpen = value;
|
||||||
{
|
|
||||||
this.internalIsOpen = value;
|
|
||||||
|
|
||||||
if (value == false)
|
|
||||||
this.IsFocused = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -174,6 +170,8 @@ namespace Dalamud.Interface.Windowing
|
||||||
{
|
{
|
||||||
this.internalLastIsOpen = this.internalIsOpen;
|
this.internalLastIsOpen = this.internalIsOpen;
|
||||||
this.OnClose();
|
this.OnClose();
|
||||||
|
|
||||||
|
this.IsFocused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ namespace Dalamud.Interface.Windowing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WindowSystem
|
public class WindowSystem
|
||||||
{
|
{
|
||||||
|
private static DateTimeOffset lastAnyFocus;
|
||||||
|
|
||||||
private readonly List<Window> windows = new();
|
private readonly List<Window> windows = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -28,6 +30,11 @@ namespace Dalamud.Interface.Windowing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool HasAnyWindowSystemFocus { get; internal set; }
|
public static bool HasAnyWindowSystemFocus { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the timespan since the last time any window was focused.
|
||||||
|
/// </summary>
|
||||||
|
public static TimeSpan TimeSinceLastAnyFocus => DateTimeOffset.Now - lastAnyFocus;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether any window in this <see cref="WindowSystem"/> has focus and is
|
/// Gets a value indicating whether any window in this <see cref="WindowSystem"/> has focus and is
|
||||||
/// not marked to be excluded from consideration.
|
/// not marked to be excluded from consideration.
|
||||||
|
|
@ -90,7 +97,10 @@ namespace Dalamud.Interface.Windowing
|
||||||
this.HasAnyFocus = this.windows.Any(x => x.IsFocused && x.RespectCloseHotkey);
|
this.HasAnyFocus = this.windows.Any(x => x.IsFocused && x.RespectCloseHotkey);
|
||||||
|
|
||||||
if (this.HasAnyFocus)
|
if (this.HasAnyFocus)
|
||||||
|
{
|
||||||
HasAnyWindowSystemFocus = true;
|
HasAnyWindowSystemFocus = true;
|
||||||
|
lastAnyFocus = DateTimeOffset.Now;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasNamespace)
|
if (hasNamespace)
|
||||||
ImGui.PopID();
|
ImGui.PopID();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue