mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-07 23:41:47 +02:00
Add unified input event queue and cursor support for window manager
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Cosmos.Kernel.System.Graphics;
|
||||
using Cosmos.Kernel.System.Graphics.Fonts;
|
||||
using Cosmos.Kernel.System.Mouse;
|
||||
|
||||
using RemSox.UI.GUI.UIEelements;
|
||||
using RemSox.Utils;
|
||||
@@ -26,6 +25,8 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
private static bool isPositionDirty = true;
|
||||
private static Point lastPointerPosition = new(-1, -1);
|
||||
|
||||
private static Point cursorPosition;
|
||||
|
||||
private static readonly Lock renderLock = new();
|
||||
|
||||
public void Render(IEnumerable<RenderCommand> commands)
|
||||
@@ -56,6 +57,11 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
RemovePrimitives(command.WindowId, command.ElementId);
|
||||
break;
|
||||
|
||||
case RenderCommandType.SetCursor:
|
||||
cursorPosition = command.Position;
|
||||
isPositionDirty = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (windowCanvases.ContainsKey(command.WindowId))
|
||||
{
|
||||
@@ -70,7 +76,7 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
public void Composite()
|
||||
{
|
||||
Canvas screenCanvas = FullScreenCanvas.GetFullScreenCanvas();
|
||||
Point pointerPosition = new(MouseManager.X, MouseManager.Y);
|
||||
Point pointerPosition = cursorPosition;
|
||||
|
||||
lock (renderLock)
|
||||
{
|
||||
|
||||
@@ -90,6 +90,11 @@ public class RenderCommand
|
||||
|
||||
case RenderCommandType.RemovePrimitives:
|
||||
break;
|
||||
|
||||
case RenderCommandType.SetCursor:
|
||||
WriteInt16(s, Position.X);
|
||||
WriteInt16(s, Position.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +159,10 @@ public class RenderCommand
|
||||
|
||||
case RenderCommandType.RemovePrimitives:
|
||||
break;
|
||||
|
||||
case RenderCommandType.SetCursor:
|
||||
pos = new Point(ReadInt16(data, ref offset), ReadInt16(data, ref offset));
|
||||
break;
|
||||
}
|
||||
|
||||
return new RenderCommand
|
||||
|
||||
@@ -15,4 +15,6 @@ public enum RenderCommandType : byte
|
||||
DrawPoint = 0x16,
|
||||
|
||||
RemovePrimitives = 0x20,
|
||||
|
||||
SetCursor = 0x30,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user