From 7d8a336337e26fc1fc755b400fea77a68b74030d Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Mon, 8 Jun 2026 20:47:19 +0200 Subject: [PATCH] Handle window close commands and interaction logic improvements --- UI/GUI/Windows/Window.cs | 12 ++++++++---- UI/GUI/Windows/WindowManager.cs | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/UI/GUI/Windows/Window.cs b/UI/GUI/Windows/Window.cs index 5770e6a..5cba7a0 100644 --- a/UI/GUI/Windows/Window.cs +++ b/UI/GUI/Windows/Window.cs @@ -111,7 +111,7 @@ public sealed class Window(string title, int processId, int id, IRenderSource re bool anyChildChanged; List elementsCopy; - + lock (uiElementsLock) { anyChildChanged = uiElements.Values.Any(e => e.AnyPropertyChanged); @@ -222,10 +222,14 @@ public sealed class Window(string title, int processId, int id, IRenderSource re dragOffset = new Point(pointerPosition.X - Position.X, pointerPosition.Y - Position.Y); } - if (currentInteraction != InteractionMode.None) + if (currentInteraction != InteractionMode.None || inBounds) { - interactionStartBounds = new Rectangle(Position, Size); - interactionStartPointer = pointerPosition; + if (currentInteraction != InteractionMode.None) + { + interactionStartBounds = new Rectangle(Position, Size); + interactionStartPointer = pointerPosition; + } + WindowManager.FocusWindow(this); return true; } diff --git a/UI/GUI/Windows/WindowManager.cs b/UI/GUI/Windows/WindowManager.cs index 2f6fddc..4bc7101 100644 --- a/UI/GUI/Windows/WindowManager.cs +++ b/UI/GUI/Windows/WindowManager.cs @@ -123,9 +123,24 @@ public static class WindowManager public static void CloseWindowsForProcess(int processId) { + List windowsToClose = new(); lock (windowsLock) { - windows.Remove(processId); + if (windows.TryGetValue(processId, out var processWindows)) + { + windowsToClose.AddRange(processWindows); + windows.Remove(processId); + } + } + + if (windowsToClose.Count > 0) + { + List closeCommands = new(); + foreach (var window in windowsToClose) + { + closeCommands.Add(new RenderCommand { WindowId = window.Id, ElementId = window.Id, ElementType = "WindowClose", Position = window.Position, Properties = new Dictionary() }); + } + renderSource.Render(closeCommands); } }