mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 17:16:24 +02:00
Add unified input event queue and cursor support for window manager
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using Cosmos.Kernel.System.Graphics;
|
||||
using Cosmos.Kernel.System.Keyboard;
|
||||
using Cosmos.Kernel.System.Mouse;
|
||||
|
||||
using RemSox.Processing;
|
||||
using RemSox.UI;
|
||||
using RemSox.UI.GUI.Layout;
|
||||
using RemSox.UI.GUI.Rendering;
|
||||
using RemSox.UI.GUI.UIEelements.Controls;
|
||||
@@ -115,8 +118,13 @@ internal class DesktopProcess() : Process("Desktop Manager")
|
||||
}
|
||||
}
|
||||
|
||||
private Point lastLocalMousePos = Point.Empty;
|
||||
private bool lastLocalLeft, lastLocalRight, lastLocalMiddle;
|
||||
|
||||
internal override void Tick()
|
||||
{
|
||||
PollLocalHardware();
|
||||
|
||||
WindowManager.Update();
|
||||
|
||||
if (tickCount % 5 == 0)
|
||||
@@ -132,6 +140,55 @@ internal class DesktopProcess() : Process("Desktop Manager")
|
||||
}
|
||||
}
|
||||
|
||||
private void PollLocalHardware()
|
||||
{
|
||||
Point pos = new(MouseManager.X, MouseManager.Y);
|
||||
|
||||
if (pos != lastLocalMousePos)
|
||||
{
|
||||
WindowManager.EnqueueMouseEvent(MouseEvent.Move(pos.X, pos.Y));
|
||||
lastLocalMousePos = pos;
|
||||
}
|
||||
|
||||
bool left = MouseManager.LeftButton;
|
||||
if (left != lastLocalLeft)
|
||||
{
|
||||
WindowManager.EnqueueMouseEvent(left
|
||||
? MouseEvent.ButtonDown(pos.X, pos.Y, MouseButton.Left)
|
||||
: MouseEvent.ButtonUp(pos.X, pos.Y, MouseButton.Left));
|
||||
lastLocalLeft = left;
|
||||
}
|
||||
|
||||
bool right = MouseManager.RightButton;
|
||||
if (right != lastLocalRight)
|
||||
{
|
||||
WindowManager.EnqueueMouseEvent(right
|
||||
? MouseEvent.ButtonDown(pos.X, pos.Y, MouseButton.Right)
|
||||
: MouseEvent.ButtonUp(pos.X, pos.Y, MouseButton.Right));
|
||||
lastLocalRight = right;
|
||||
}
|
||||
|
||||
bool middle = MouseManager.MiddleButton;
|
||||
if (middle != lastLocalMiddle)
|
||||
{
|
||||
WindowManager.EnqueueMouseEvent(middle
|
||||
? MouseEvent.ButtonDown(pos.X, pos.Y, MouseButton.Middle)
|
||||
: MouseEvent.ButtonUp(pos.X, pos.Y, MouseButton.Middle));
|
||||
lastLocalMiddle = middle;
|
||||
}
|
||||
|
||||
int scroll = MouseManager.ScrollDelta;
|
||||
if (scroll != 0)
|
||||
{
|
||||
WindowManager.EnqueueMouseEvent(MouseEvent.Wheel(pos.X, pos.Y, scroll));
|
||||
}
|
||||
|
||||
while (KeyboardManager.TryReadKey(out KeyEvent? keyEvent) && keyEvent is not null)
|
||||
{
|
||||
WindowManager.EnqueueKeyEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWindowButtons()
|
||||
{
|
||||
List<Window> allWindows = WindowManager.GetAllWindows()
|
||||
|
||||
Reference in New Issue
Block a user