openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

Tray menu flyout renders squished after display scaling change until dismissed and reopened

Open christineyan4 opened this issue 6 months ago • 1 comments

Description

When Windows display scaling is changed (e.g. 100% to 125%) while the tray app is running, the right-click context menu renders squished/compressed on its first open after the DPI change. Dismissing the menu and right-clicking again renders it correctly at the new scale.

Steps to Reproduce

  1. Launch the tray app at 100% display scaling
  2. Right-click the tray icon - menu renders correctly
  3. Dismiss the menu
  4. Change Windows display scaling (Settings > Display > Scale) to 125% or higher
  5. Right-click the tray icon again - menu is squished/compressed
  6. Dismiss and right-click again - menu now renders correctly

Root Cause

The TrayMenuWindow is created once at startup and reused across DPI changes. When SizeToContent() calls MenuPanel.Measure(), it returns stale layout values from the previous DPI - the XAML layout pass hasn't re-rendered at the new scale yet. On the second open, the layout has updated internally, so measurement is correct.

Possible Fixes

  • Listen for DPI change events and force a layout invalidation before measuring
  • Recreate the TrayMenuWindow on DPI change (note: care needed around the WndProc fail-fast bug referenced in TrayMenuWindow.xaml.cs line 134-136)
  • Force an additional UpdateLayout() / InvalidateMeasure() cycle in SizeToContent() before measuring

Environment

  • Windows 11 ARM64
  • Tested at 100%, 125%, 150%, 200% scaling

christineyan4 avatar May 05 '26 20:05 christineyan4

Hi Christine — Copilot here, commenting as a bot on Scott's behalf.

Thank you for the crisp DPI repro and root-cause notes. That made this much easier to turn around safely. Scott asked me to pass along his thanks as well.

I merged a targeted fix to master in 32830a0. The tray menu now sizes itself against the target cursor monitor DPI on show instead of reusing stale hidden-window measurements, and it invalidates cached popup/flyout geometry when DPI or XAML rasterization scale changes. That should address the first-open-after-scale-change squishing you reported while keeping the normal WinUI pages on the platform-managed DPI path.

Validated with the full repo build plus Shared and Tray test suites before merging. Closing this as fixed, and thanks again for catching it.

shanselman avatar May 05 '26 21:05 shanselman