Move window input handling logic from Kernel to WindowManager

This commit is contained in:
Stone_Red
2026-06-08 13:34:42 +02:00
parent 4561e1f997
commit 3522493689
2 changed files with 38 additions and 57 deletions
+37
View File
@@ -3,6 +3,8 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Cosmos.Kernel.System.Graphics;
using Cosmos.Kernel.System.Mouse;
using RemSox.Processing;
using RemSox.UI.GUI.Rendering;
@@ -18,8 +20,43 @@ public static class WindowManager
private static Window? focusedWindow;
private static Window? activeInteractWindow = null;
private static Point lastPointerPosition = Point.Empty;
private static bool wasLeftButtonDown = false;
private static int mousePollCounter = 0;
private static readonly MuliRenderSource renderSource = new([]);
public static void Update()
{
mousePollCounter++;
MouseManager.Poll();
Point pointerPosition = new((int)MouseManager.X, (int)MouseManager.Y);
bool leftButtonDown = MouseManager.LeftButton;
if (leftButtonDown && !wasLeftButtonDown)
{
activeInteractWindow = TryBeginInteract(pointerPosition);
}
else if (leftButtonDown && activeInteractWindow is not null)
{
activeInteractWindow.UpdateInteraction(pointerPosition);
}
else if (!leftButtonDown && activeInteractWindow is not null)
{
activeInteractWindow.EndInteraction();
activeInteractWindow = null;
}
wasLeftButtonDown = leftButtonDown;
Canvas canvas = FullScreenCanvas.GetFullScreenCanvas();
CanvasRenderSource.CompositeAndDisplay(canvas, pointerPosition);
lastPointerPosition = pointerPosition;
}
public static void AddRenderSource(IRenderSource source) => renderSource.AddSource(source);
public static void RemoveRenderSource(IRenderSource source) => renderSource.RemoveSource(source);