mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Add ScreenInfo render command for desktop size synchronization
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Cosmos.Kernel.System.Graphics;
|
||||
using Cosmos.Kernel.System.Keyboard;
|
||||
|
||||
using RemSox.Networking;
|
||||
@@ -38,6 +39,19 @@ internal sealed class RemoteDesktopProcess() : Process("Remote Desktop Server")
|
||||
|
||||
server.ListenTo<string>("SyncRequest", async _ =>
|
||||
{
|
||||
Canvas canvas = FullScreenCanvas.GetFullScreenCanvas();
|
||||
RenderCommand screenInfo = new()
|
||||
{
|
||||
Type = RenderCommandType.ScreenInfo,
|
||||
WindowId = 0,
|
||||
ElementId = 0,
|
||||
Properties = new()
|
||||
{
|
||||
["Width"] = (int)canvas.Mode.Width,
|
||||
["Height"] = (int)canvas.Mode.Height,
|
||||
},
|
||||
};
|
||||
networkSource?.Render([screenInfo]);
|
||||
WindowManager.InvalidateAll();
|
||||
});
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
private static Point lastPointerPosition = new(-1, -1);
|
||||
|
||||
private static Point cursorPosition;
|
||||
private static int screenWidth, screenHeight;
|
||||
|
||||
private static readonly Lock renderLock = new();
|
||||
|
||||
@@ -62,6 +63,12 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
isPositionDirty = true;
|
||||
break;
|
||||
|
||||
case RenderCommandType.ScreenInfo:
|
||||
screenWidth = Get(command.Properties, "Width", 640);
|
||||
screenHeight = Get(command.Properties, "Height", 480);
|
||||
isPositionDirty = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (windowCanvases.ContainsKey(command.WindowId))
|
||||
{
|
||||
|
||||
@@ -95,6 +95,11 @@ public class RenderCommand
|
||||
WriteInt16(s, Position.X);
|
||||
WriteInt16(s, Position.Y);
|
||||
break;
|
||||
|
||||
case RenderCommandType.ScreenInfo:
|
||||
WriteUInt16(s, GetProp("Width", 0));
|
||||
WriteUInt16(s, GetProp("Height", 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +168,11 @@ public class RenderCommand
|
||||
case RenderCommandType.SetCursor:
|
||||
pos = new Point(ReadInt16(data, ref offset), ReadInt16(data, ref offset));
|
||||
break;
|
||||
|
||||
case RenderCommandType.ScreenInfo:
|
||||
props["Width"] = ReadUInt16(data, ref offset);
|
||||
props["Height"] = ReadUInt16(data, ref offset);
|
||||
break;
|
||||
}
|
||||
|
||||
return new RenderCommand
|
||||
|
||||
@@ -17,4 +17,6 @@ public enum RenderCommandType : byte
|
||||
RemovePrimitives = 0x20,
|
||||
|
||||
SetCursor = 0x30,
|
||||
|
||||
ScreenInfo = 0xF0,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user