Files
Steven Downer 1abf001afc fix(ffi): map EnableFontSmoothing to the font smoothing flag (#2397)
PerformanceFlagsType::EnableFontSmoothing was mapped to
ENABLE_DESKTOP_COMPOSITION (0x100), so a client asking for font
smoothing through the bindings got desktop composition instead, and the
server drew text without smoothing. Only PerformanceFlags::new_default()
set font smoothing (0x80).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:31:14 -05:00
..

IronRDP FFI

Diplomat-based FFI for IronRDP.

Currently, only the .NET target is officially supported.

How to build

  • Install required tools: cargo xtask ffi install

    • For .NET, note that dotnet is also a requirement that you will need to install on your own.
  • Build the shared library: cargo xtask ffi build (alternatively, in release mode: cargo xtask ffi build --release)

  • Build the bindings: cargo xtask ffi bindings

At this point, you may build and run the examples for .NET:

  • dotnet run --project Devolutions.IronRdp.ConnectExample
  • dotnet run --project Devolutions.IronRdp.AvaloniaExample

Dynamic resize

ClientConnector.WithDynamicChannelDisplayControl() requests the Display Control channel (MS-RDPEDISP). The server opens it and sends its capabilities some time after the connection is established, so ActiveStage.EncodedResize returns null until then. Read ActiveStage.DisplayControlState after each Process call: it moves from Pending to Ready when the capabilities arrive, which is when to send the first resize. Unavailable means the channel was not requested. ActiveStage.DisplayControlCapabilities exposes the server's monitor count and area limits once Ready.

Touch and pen input (MS-RDPEI)

  • Attach the channel before connecting: connector.WithDynamicChannelRdpei(maxTouchContacts, showTouchVisuals).
  • Feed toolkit touch events to a TouchFrameBuilder.New(maxTouchContacts) with Push(touchId, TouchPhase, x, y) or PushWithPressure, in desktop coordinates.
  • Feed pen samples to a PenFrameBuilder.New() with Push(penId, PenPhase, x, y) or PushWithAttributes for buttons, pressure, rotation and tilt; one pen is tracked at a time.
  • Once activeStage.RdpeiInputState.Touch (or .Pen) is true, activeStage.EncodeRdpeiTouch(builder) or EncodeRdpeiPen(builder) returns the frame to write to the transport, or null when nothing is pending. It throws while the channel is not ready or the server suspended input, and the frames stay pending. One frame carries at most 32767 touch or pen frames, so call again while HasPendingFrames is true.
  • activeStage.EncodeRdpeiDismissHovering(contactId) tells the server to stop tracking a hovering touch contact.
  • Call CancelAll() when the window loses focus, Reset() when the session ends, and dispose the builders with it: a long suspension can leave tens of thousands of frames pending in native memory.

Migrating from 2026.10.19

  • Properties replace the GetX() and SetX() methods they duplicated.
  • Only these types are IDisposable: ActiveStage, ActiveStageOutput, ActiveStageOutputIterator, ClipboardMessage, ClipboardSvcMessage, CredsspProcessGenerator, DecodedImage, DecodedPointer, FfiFileContentsResponse, FormatDataResponse, PenFrameBuilder, TouchFrameBuilder, VecU8, WinCliprdr and WriteBuf. Every other type is released by its finalizer, so drop using and Dispose() on it.
  • Dispose WinCliprdr on the thread that created it, because only that thread can remove its window subclass.
  • Dispose a CredsspProcessGenerator before the next call on its CredsspSequence.
  • DecodedImage.Data is gone: size a buffer with DataSize and copy into it with FillData. ResponseFrame, WindowingOrders and DecodedPointer.Data return a VecU8 instead of a BytesSlice.
  • WindowingOrders reports an encoding failure as IronRdpErrorKind.EncodeError instead of Generic.
  • A native object rejects overlapping calls with InvalidOperationException. Serialize access to ActiveStage and DecodedImage across the PDU loop, input handlers and clipboard, as the Avalonia example does with one lock.
  • FastPathInputEventIterator.Encode() returns the Fast-Path Input PDUs for the events of one InputDatabase.Apply as a VecU8, ready for Framed.Write. It reads no ActiveStage or DecodedImage, so call it outside that lock and input no longer waits on frame decoding. ActiveStage.ProcessFastpathInput sends the same bytes; keep it, under the lock, only when PointerSoftwareRendering is on, because it also redraws the pointer in the image. InputDatabase tracks pressed keys and buttons, so keep calling Apply from one thread.