Skip to content

Commit 864c447

Browse files
committed
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.
1 parent 6d1a255 commit 864c447

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

WindowsEdgeLight/MainWindow.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,19 @@ private MonitorWindowContext CreateMonitorWindow(Screen screen)
11471147
}
11481148
};
11491149

1150+
window.DpiChanged += (s, dpiArgs) =>
1151+
{
1152+
ctx.DpiScaleX = dpiArgs.NewDpi.DpiScaleX;
1153+
ctx.DpiScaleY = dpiArgs.NewDpi.DpiScaleY;
1154+
1155+
window.Left = screen.WorkingArea.X / ctx.DpiScaleX;
1156+
window.Top = screen.WorkingArea.Y / ctx.DpiScaleY;
1157+
window.Width = screen.WorkingArea.Width / ctx.DpiScaleX;
1158+
window.Height = screen.WorkingArea.Height / ctx.DpiScaleY;
1159+
1160+
UpdateMonitorGeometry(ctx);
1161+
};
1162+
11501163
return ctx;
11511164
}
11521165

0 commit comments

Comments
 (0)