mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix closing child window minimizing parent on windows.
This commit is contained in:
@@ -392,6 +392,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
public bool IsMinimized;
|
||||
public string Title = "";
|
||||
public bool IsVisible;
|
||||
public IClydeWindow? Owner;
|
||||
|
||||
public bool DisposeOnClose;
|
||||
|
||||
|
||||
@@ -212,7 +212,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
) : CmdBase;
|
||||
|
||||
private sealed record CmdWinDestroy(
|
||||
nint Window
|
||||
nint Window,
|
||||
bool hadOwner
|
||||
) : CmdBase;
|
||||
|
||||
private sealed record GlfwWindowCreateResult(
|
||||
|
||||
@@ -165,6 +165,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
renderer,
|
||||
parameters,
|
||||
(nint) share,
|
||||
// We have to pass the owner window in the Cmd here instead of reading it off parameters,
|
||||
// in case the owner window is closed between sending and handling of this cmd.
|
||||
(nint) owner,
|
||||
tcs));
|
||||
|
||||
@@ -206,13 +208,30 @@ namespace Robust.Client.Graphics.Clyde
|
||||
// So we send the TCS back to the game thread
|
||||
// which processes events in the correct order and has better control of stuff during init.
|
||||
var reg = WinThreadSetupWindow(window);
|
||||
reg.Owner = parameters.Owner;
|
||||
|
||||
SendEvent(new EventWindowCreate(new GlfwWindowCreateResult(reg, null), tcs));
|
||||
}
|
||||
|
||||
private void WinThreadWinDestroy(CmdWinDestroy cmd)
|
||||
{
|
||||
GLFW.DestroyWindow((Window*) cmd.Window);
|
||||
var window = (Window*) cmd.Window;
|
||||
|
||||
if (OperatingSystem.IsWindows() && cmd.hadOwner)
|
||||
{
|
||||
// On Windows, closing the child window causes the owner to be minimized, apparently.
|
||||
// Clear owner on close to avoid this.
|
||||
|
||||
var hWnd = (void*) GLFW.GetWin32Window(window);
|
||||
DebugTools.Assert(hWnd != null);
|
||||
|
||||
Win32.SetWindowLongPtrW(
|
||||
hWnd,
|
||||
Win32.GWLP_HWNDPARENT,
|
||||
0);
|
||||
}
|
||||
|
||||
GLFW.DestroyWindow(window);
|
||||
}
|
||||
|
||||
public void WindowSetTitle(WindowReg window, string title)
|
||||
@@ -435,7 +454,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
reg.IsDisposed = true;
|
||||
|
||||
SendCmd(new CmdWinDestroy((nint) reg.GlfwWindow));
|
||||
SendCmd(new CmdWinDestroy((nint) reg.GlfwWindow, window.Owner != null));
|
||||
|
||||
_windows.Remove(reg);
|
||||
_clyde._windowHandles.Remove(reg.Handle);
|
||||
|
||||
Reference in New Issue
Block a user