Skip to content

Commit

Permalink
don't need to track focus ourselves
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Dec 2, 2022
1 parent b7137fe commit 64e68f9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions addons/imgui-godot/ImGuiGodot/InternalViewports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ internal class GodotImGuiWindow : IDisposable
private readonly GCHandle _gcHandle;
private readonly ImGuiViewportPtr _vp;

private bool _focused;
public Window GodotWindow { get; init; }
public SubViewport LayerSvp { get; init; }

Expand All @@ -35,8 +34,6 @@ public GodotImGuiWindow(ImGuiViewportPtr vp)
TransparentBg = true
};

GodotWindow.FocusEntered += () => _focused = true;
GodotWindow.FocusExited += () => _focused = false;
GodotWindow.CloseRequested += () => _vp.PlatformRequestClose = true;
GodotWindow.SizeChanged += () => _vp.PlatformRequestResize = true;
GodotWindow.WindowInput += OnWindowInput;
Expand All @@ -59,8 +56,6 @@ public GodotImGuiWindow(ImGuiViewportPtr vp, Window gw)
_vp = vp;
_vp.PlatformHandle = (IntPtr)_gcHandle;
GodotWindow = gw;
GodotWindow.FocusEntered += () => _focused = true;
GodotWindow.FocusExited += () => _focused = false;
}

public void Dispose()
Expand Down Expand Up @@ -104,12 +99,12 @@ public Vector2i GetWindowSize()

public void SetWindowFocus()
{
GodotWindow.MoveToForeground();
GodotWindow.GrabFocus();
}

public bool GetWindowFocus()
{
return _focused;
return GodotWindow.HasFocus();
}

public bool GetWindowMinimized()
Expand Down

0 comments on commit 64e68f9

Please sign in to comment.