From 864c447f5188421d2094caf4df14ea1526d76a81 Mon Sep 17 00:00:00 2001 From: Scott Hanselman Date: Thu, 12 Feb 2026 11:42:28 -0800 Subject: [PATCH] Fix: secondary monitor windows now handle DPI changes at runtime Secondary 'show on all monitors' windows had no DpiChanged handler, causing them to become incorrectly sized when monitor DPI changed at runtime (e.g., docking/undocking). The cached ctx.DpiScaleX/Y values also went stale, corrupting cursor hole-punch coordinates. This adds a DpiChanged event handler to each secondary window that updates the cached DPI scale, repositions/resizes the window, and rebuilds the frame geometry. --- WindowsEdgeLight/MainWindow.xaml.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/WindowsEdgeLight/MainWindow.xaml.cs b/WindowsEdgeLight/MainWindow.xaml.cs index 81a9ebc..55093b9 100644 --- a/WindowsEdgeLight/MainWindow.xaml.cs +++ b/WindowsEdgeLight/MainWindow.xaml.cs @@ -1147,6 +1147,19 @@ private MonitorWindowContext CreateMonitorWindow(Screen screen) } }; + window.DpiChanged += (s, dpiArgs) => + { + ctx.DpiScaleX = dpiArgs.NewDpi.DpiScaleX; + ctx.DpiScaleY = dpiArgs.NewDpi.DpiScaleY; + + window.Left = screen.WorkingArea.X / ctx.DpiScaleX; + window.Top = screen.WorkingArea.Y / ctx.DpiScaleY; + window.Width = screen.WorkingArea.Width / ctx.DpiScaleX; + window.Height = screen.WorkingArea.Height / ctx.DpiScaleY; + + UpdateMonitorGeometry(ctx); + }; + return ctx; }