Skip to content

feat(rdp): multi-monitor & virtual screens, 3-mode window workflow, mstsc-grade clipboard, and NativeAOT support - #4

Closed
heartacker wants to merge 15 commits into
AtomUICommunity:masterfrom
heartacker:PR
Closed

heartacker wants to merge 15 commits into
AtomUICommunity:masterfrom
heartacker:PR

Conversation

@heartacker

Copy link
Copy Markdown
Contributor

Summary / 概述

This PR builds on v0.1.79 (origin/master + EGFX / RdpFrameComposer / FullScreenConnectionBar) to deliver a comprehensive, release-grade upgrade to CxShell's RDP experience, windowing workflow, and NativeAOT publishing pipeline.

本 PR 基于 v0.1.79(origin/master 的 EGFX、RdpFrameComposer 与 FullScreenConnectionBar),对 CxShell 的 RDP 远程桌面体验、窗口交互体系与 NativeAOT 发布能力进行了发布级增强。


Key Innovations & Features / 创新性特性与核心功能

1. Multi-Monitor, Secondary Windows & Virtual Screen Suite / 独立窗体专属多显示器与创新虚拟屏体系

  • Dynamic Multi-Monitor & Mixed DPI (ABI v15): Uses FreeRDP disp dynamic channel to push arbitrary multi-monitor layouts with per-monitor physical resolution and DPI scaling (100%/125%/150%/200%).
  • Windowed Secondary Monitors & Cross-Screen Drag: Secondary monitors (RdpMonitorWindow) can switch freely between fullscreen and windowed modes, with global hit-testing for smooth cross-screen dragging of remote windows.
  • Ultrawide Virtual Dual-Screen & Local PBP Merge:
    • Split a single local ultrawide monitor into two logical remote monitors;
    • Merge two local PBP monitors into a single remote ultrawide desktop;
    • Create virtual secondary monitor windows even on a single-monitor machine, with 1px seam/bleed and odd-pixel alignment fixes.
  • 动态多显示器与混合 DPI(ABI v15):通过 FreeRDP disp 动态通道按屏幕独立上报物理分辨率与混合 DPI 缩放。
  • 副屏窗口化与跨屏丝滑拖拽:副屏(RdpMonitorWindow)支持自由窗口化切换,并通过全局命中测试实现远程应用跨屏拖拽。
  • 创新带鱼屏与虚拟多屏模式:支持单块带鱼屏拆分为远端双屏、本地双屏 PBP 合并为远端带鱼屏、以及单屏电脑新增虚拟副屏窗体,并修复了接缝 1px 渗色与奇偶像素对齐问题。

2. Unified 3-Mode Window Workflow & 4-State Immersive Maximize / 三模式窗口体系与四状态沉浸式最大化

  • 3-Mode RDP Open Selector: Default (main window tab) / MultiTab (RdpWorkspaceWindow, single-monitor) / Standalone (DetachedTabWindow, exclusive host for multi-monitor & virtual screens), with seamless live transfer between containers and automatic single-monitor reset when moving back to multi-tab windows.
  • 4-State Immersive Window Model: Minimize / Normal / Immersive Maximize (maximizing automatically hides title bar while keeping the taskbar) / FullScreen, unified across all windows on top of FullScreenConnectionBar.
  • 三种打开模式:会话设置提供 默认(主窗口标签页)/ 多标签(RdpWorkspaceWindow,单屏)/ 独立窗体(DetachedTabWindow,独占多屏与虚拟屏),支持不断开会话在窗口间无缝流转,从独立窗体移回多标签窗口时自动关闭副屏并收敛回单屏。
  • 四状态沉浸式窗口模型:统一为 最小化 / 窗口化 / 窗口最大化(自动进入沉浸式、保留任务栏)/ 全屏,全项目统一复用 FullScreenConnectionBar 悬浮栏,补齐会话编辑按钮、右键菜单与完整中英文 LocalizationService 覆盖。

3. mstsc-Grade Cross-Platform Clipboard & Input Experience / 媲美 mstsc 的跨平台剪贴板与输入体验

  • Bidirectional Image / File / Rich-Text Clipboard (ABI v14): Supports CF_DIB/PNG images, HTML/RTF rich text, and files/folders with LockClipboardData large-file snapshot locking, Windows real-time HWND_MESSAGE listener (AddClipboardFormatListener), macOS/Linux polling, sequence-number anti-loop deduplication, and drag-and-drop local file paste.
  • Remote Pointer Shape & Lock-Key Sync (ABI v12–v13): Real-time cross-platform remote cursor rendering (freerdp_image_copy_from_pointer_data) and automatic CapsLock / NumLock / ScrollLock state synchronization.
  • UDP Multitransport & Manual Security Mode Selector: Enables FreeRDP UDP-FECR | UDP-FECL for low-latency WAN sessions and adds an explicit per-session security mode override (Auto / Negotiate / NLA / TLS / RDP).
  • 跨平台双向剪贴板与拖拽粘贴(ABI v14):支持图片(CF_DIB/PNG)、富文本(HTML/RTF)与文件/文件夹双向同步、大文件锁定(LockClipboardData)、Windows 实时剪贴板监听、macOS/Linux 轮询、防回环去重及拖拽本地文件直接粘贴。
  • 光标形状与锁定键同步(ABI v12–v13):实时同步远端鼠标光标位图与热点,连接时自动同步 CapsLock / NumLock / ScrollLock 状态。
  • UDP 多传输与手动安全模式:开启 FreeRDP UDP 多传输通道降低弱网延迟,并在会话编辑页提供手动安全协议选择(保留自动缓存)。

4. NativeAOT Publishing & Zero-Warning Build / NativeAOT 发布支持与零告警构建

  • Added Services/AppJsonContext.cs (source-generated JSON contexts) and generic JsonStringEnumConverter<TEnum>, removed reflection sorting in DataGridSourceAdapter, configured PublishAot + TrimmerRootAssembly, and resolved all C# / Avalonia build warnings (0 errors, 0 warnings).
  • 新增 AppJsonContext 源生成 JSON 上下文与泛型枚举转换器,移除 DataGridSourceAdapter 反射排序,补齐 PublishAot 配置并清零全部编译器与 Avalonia 告警(0 Error, 0 Warning)。

Problems Solved & Scenarios Optimized / 解决的问题与优化的场景

  • Stuck on "Loading remote desktop" / MSVC FreeRDP build failure: Guarded optional native exports against EntryPointNotFoundException and defined WIN32_LEAN_AND_MEAN / NOMINMAX before <windows.h> to prevent NIIF_NONE macro conflict with FreeRDP 3.x <freerdp/rail.h>.
  • High-latency WAN & legacy hosts: UDP multitransport improves smoothness over public networks; explicit security mode selector avoids unnecessary fallback handshakes on special hosts.
  • Daily RDP productivity: Seamless copy/paste of screenshots, formatted documents, and files, live cursor feedback, accurate lock-key state, and flexible multi-monitor / ultrawide workflows without disconnecting active sessions.

Commit Breakdown / 提交结构(8 Release-Grade Commits)

  1. fix(rdp): guard optional native exports and define WIN32_LEAN_AND_MEAN for CxRdpBridge
  2. perf(rdp): enable FreeRDP UDP multitransport for low-latency sessions
  3. feat(rdp): add manual security mode selector in session editor
  4. feat(rdp): sync CapsLock/NumLock/ScrollLock state with remote session
  5. feat(rdp): sync remote mouse pointer shape across platforms
  6. feat(rdp): add cross-platform image/file/rich-text clipboard, drag-and-drop paste, and large file locking
  7. feat(rdp): add 3-mode RDP window workflow, 4-state immersive maximize, unified FullScreenConnectionBar, and multi-monitor/virtual screen suite
  8. feat(aot): support NativeAOT publishing and resolve all compiler/Avalonia warnings

Test Plan / 验证结果

  • dotnet test CxShell.Tests/CxShell.Tests.csproj -c Release: 727/727 passed, 0 errors, 0 warnings.
  • tools/build-rdp-bridge.ps1: Verified MSVC Release build of CxRdpBridge.dll against FreeRDP 3.32.2.

Added:
- Enabled FreeRDP Multitransport (UDP-FECR and UDP-FECL) in CxRdpBridge.

Changed:
- Configured FreeRDP_SupportMultitransport=TRUE and FreeRDP_MultitransportFlags in connection_thread before handshake.

Fixed:
- Reduced head-of-line blocking and frame/input latency over high-latency or lossy WAN links.

Technical Approach:
- Advertise TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL during RDP negotiation in native/CxRdpBridge/cxrdp_bridge.cpp. Servers or firewalls that disallow UDP automatically fall back to pure TCP during handshake without breaking compatibility.
Added:
- Per-session RdpSecurityMode setting (Auto, Negotiate, NLA, TLS, RDP) in SessionInfo and SessionEditDialog with full zh-CN/en-US localization.

Changed:
- RdpBridgeClient.Connect now prioritizes an explicit RdpSecurityMode over the host-level RdpSecurityProfileCache hint when configured.

Fixed:
- Allows locking specific legacy or hardened RDP hosts to a known-good security protocol without waiting for fallback probing.

Technical Approach:
- Reuse the existing cxrdp_set_security_profile (API 7) native export without bumping the bridge ABI; Auto mode continues to delegate to RdpSecurityProfileCache.
Added:
- Native ABI v12 export cxrdp_sync_lock_keys and CX_RDP_CAPABILITY_SYNC_LOCK_KEYS capability bit.
- Per-session RdpSyncLockKeys toggle (default true) in SessionInfo and SessionEditDialog.

Changed:
- RdpView reads Windows lock-key states via GetKeyState and synchronizes them to the remote host upon connection.

Fixed:
- Eliminates CapsLock/NumLock state mismatch between local and remote desktops when typing passwords or text.

Technical Approach:
- Invoke freerdp_input_send_synchronize_event in native/CxRdpBridge/cxrdp_bridge.cpp with standard RDP sync flags (ScrollLock=0x01, NumLock=0x02, CapsLock=0x04), guarded by native API/capability checks in RdpBridgeClient.
Added:
- Native ABI v13 export cxrdp_set_pointer_callback and CX_RDP_CAPABILITY_POINTER_SHAPE capability bit.
- Cross-platform Avalonia Cursor construction and disposal in RdpView for custom remote cursors, null cursor, and default arrow fallback.

Changed:
- Registered FreeRDP graphics pointer callbacks (Pointer_New, Free, Set, SetNull, SetDefault) in cx_post_connect.

Fixed:
- Replaces the static arrow cursor over RDP viewports with live remote pointer shapes (I-beam, resize handles, hand pointers, etc.).

Technical Approach:
- Decode arbitrary-bpp remote pointer masks to BGRA32 via freerdp_image_copy_from_pointer_data in CxRdpBridge, marshal pixel buffers to UI thread in RdpViewModel, and safely dispose previous WriteableBitmap/Cursor instances in RdpView.
…d-drop paste, and large file locking

Added:
- Services/RdpClipboardImageHelper.cs for cross-platform CF_DIB/PNG, HTML/RTF rich text, and file list (CF_HDROP / text/uri-list) clipboard conversion with SHA-256 anti-loop hashing.
- Services/WindowsClipboardListener.cs using a dedicated HWND_MESSAGE window (AddClipboardFormatListener) for zero-delay Windows clipboard change notifications, plus 800ms polling on macOS/Linux.
- Drag-and-drop local file/folder paste directly onto the RDP viewport.
- Per-session RdpEnableClipboardLock toggle (LockClipboardData) and native ABI v14 clipboard extension declarations.

Changed:
- Extended RdpBridgeClient, RdpViewModel, and RdpView to synchronize files, images, rich text, and plain text with Windows clipboard sequence-number deduplication.

Fixed:
- Enables mstsc-grade bidirectional image, rich text, and file clipboard workflows and prevents clipboard feedback loops.

Technical Approach:
- Extend cxrdp_bridge.h to API v14 (CX_RDP_CAPABILITY_CLIPBOARD_IMAGE/FILES/RICH_TEXT/LOCK) with managed capability gating and EntryPointNotFoundException fallbacks.
…, unified FullScreenConnectionBar, and multi-monitor/virtual screen suite

Added:
- 3-mode RdpWindowMode selector (Default / MultiTab / Standalone) in SessionEditDialog with backward compatibility for RdpOpenInStandaloneWindow.
- Standalone multi-tab RDP window (RdpWorkspaceWindow) and session tree context menu actions to open RDP sessions in multi-tab or standalone windows.
- Multi-monitor & virtual screen suite exclusive to DetachedTabWindow: FreeRDP dynamic multi-monitor layout (ABI v15, mixed DPI), secondary monitor windows (RdpMonitorWindow), slice surface renderer (RdpSliceSurface), cross-screen drag, ultrawide virtual dual-screen & PBP merge, and automatic single-monitor reset when moving back to multi-tab windows.
- Session edit buttons in SessionTreeView and SessionManagerWindow, plus right-click context menus and AtomUI tooltips across window title bars and tabs.
- Complete zh-CN and en-US localization in LocalizationService.

Changed:
- Unified all windows (MainWindow, DetachedTabWindow, RdpWorkspaceWindow, RdpMonitorWindow) on origin FullScreenConnectionBar with optional multi-tab and multi-monitor extensions and borderless Text buttons.
- Maximizing DetachedTabWindow now enters immersive mode (hiding title bar while keeping taskbar) directly, unifying the 4-state window model (Minimize / Normal / Immersive Maximize / FullScreen).

Fixed:
- Eliminated duplicate tooltips, misaligned tab close buttons, and redundant taskbar-mode buttons while preserving upstream v0.1.79 desktop loading and reconnect overlays.

Technical Approach:
- Extend FullScreenConnectionBar with opt-in ShowTabSwitcher, ShowMultiMonitorButton, ShowFullScreenButton, and SetExternalPopupOpen without altering default MainWindow behavior; enforce single-monitor boundary in multi-tab containers via RdpView.ResetToSingleMonitor().
…om normalized layout bounds

Fixed:
- Multi-monitor display corruption in right-left, top-bottom, and bottom-top arrangements.

Technical Approach:
- Snap adjacent monitors tightly against the host viewport's effective pixel dimensions (hostPixelW/hostPixelH) before computing relative MS-RDPEDISP coordinates so there are zero gaps or overlaps.
- Compute every monitor's framebuffer slice rectangle directly from (layout.Left - minLayoutX, layout.Top - minLayoutY, layout.Width, layout.Height) instead of raw physical Screen.Bounds.
… CxRdpBridge

Fixed:
- Multi-monitor layout requests were silently ignored because cxrdp_resize_monitors and FreeRDP_UseMultimon/FreeRDP_ForceMultimon were missing from cxrdp_bridge.cpp after rebasing onto origin/master.

Technical Approach:
- Enable FreeRDP_UseMultimon and FreeRDP_ForceMultimon with an initial primary rdpMonitor definition during pre-connect so Windows servers negotiate CS_MONITOR.
- Expose CX_RDP_CAPABILITY_MULTI_MONITOR and implement cxrdp_resize_monitors forwarding DISPLAY_CONTROL_MONITOR_LAYOUT arrays through DispClientContext.SendMonitorLayout.
@heartacker
heartacker force-pushed the PR branch 2 times, most recently from 67c9508 to 49eb7f2 Compare November 24, 2026 08:39
- 在 native/CxRdpBridge/cxrdp_bridge.cpp 补齐 cxrdp_set_clipboard_image_callback / cxrdp_set_clipboard_files_callback / cxrdp_set_clipboard_rich_text / cxrdp_set_clipboard_image / cxrdp_set_clipboard_files 导出,严格对齐 cxrdp_bridge.h 4 参数图片签名
- 补齐 FileGroupDescriptorW、FileContents 分块读写、PNG/CF_DIB、HTML/RTF 与 LockClipboardData 文件锁定协议处理
- 在 cxrdp_get_capabilities() 中开启 CLIPBOARD_IMAGE / CLIPBOARD_FILES / CLIPBOARD_RICH_TEXT 能力位(api=15, caps=0xFFFFF)
xiaochengzjc pushed a commit that referenced this pull request Nov 25, 2026
Cherry-picked from PR #4 (0aaf785) minus the NativeAOT publish
properties: TrimmerRootAssembly plus the reflection fallback resolver
has not been validated on a real AOT artifact, so AOT stays out of the
release pipeline for now. The recursive native asset glob is also
reverted so the published layout is unchanged.
xiaochengzjc pushed a commit that referenced this pull request Nov 25, 2026
Brings over RdpMonitorWindow, RdpSliceSurface and the monitor popup in
RdpView: each local screen or virtual screen gets its own window showing a
zero-copy slice of the remote framebuffer, with ultrawide split/merge
modes and live layout switching.

The rest of the PR's 238d480 is left out. The 3-mode window workflow
duplicated the existing tab/detached model, its Tunnel key handler
swallowed ESC before the remote could see it, and its window went to
WindowDecorations.None without the popover suppression that fixes the
black strip at the top. DetachedTabWindow also stopped being an explicit
choice once maximizing it started entering immersive mode on its own.
@heartacker heartacker closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant