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; }