Skip to content

Commit 2fce3c5

Browse files
emmaussgrokys
andauthored
remove win32 dialog dpi hack (#18923)
Co-authored-by: Steven Kirk <[email protected]>
1 parent 10fb435 commit 2fce3c5

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
127127
}
128128

129129
case WindowsMessage.WM_DPICHANGED:
130-
if (!_ignoreDpiChanges)
131130
{
132131
_dpi = (uint)wParam >> 16;
133132
var newDisplayRect = Marshal.PtrToStructure<RECT>(lParam);
@@ -149,19 +148,6 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
149148

150149
return IntPtr.Zero;
151150
}
152-
else
153-
{
154-
// In case parent is on another screen with different scaling, window will have header scaled with
155-
// parent's scaling factor, so need to update frame
156-
SetWindowPos(hWnd,
157-
IntPtr.Zero, 0, 0, 0, 0,
158-
SetWindowPosFlags.SWP_FRAMECHANGED |
159-
SetWindowPosFlags.SWP_NOSIZE |
160-
SetWindowPosFlags.SWP_NOMOVE |
161-
SetWindowPosFlags.SWP_NOZORDER |
162-
SetWindowPosFlags.SWP_NOACTIVATE);
163-
}
164-
break;
165151

166152
case WindowsMessage.WM_GETICON:
167153
if (_iconImpl == null)

src/Windows/Avalonia.Win32/WindowImpl.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ internal partial class WindowImpl : IWindowImpl, EglGlPlatformSurface.IEglWindow
104104
private bool _shown;
105105
private bool _hiddenWindowIsParent;
106106
private uint _langid;
107-
private bool _ignoreDpiChanges;
108107
internal bool _ignoreWmChar;
109108
private WindowTransparencyLevel _transparencyLevel;
110109
private readonly WindowTransparencyLevel _defaultTransparencyLevel;
@@ -730,20 +729,7 @@ public void SetParent(IWindowImpl? parent)
730729

731730
_hiddenWindowIsParent = parentHwnd == OffscreenParentWindow.Handle;
732731

733-
// I can't find mention of this *anywhere* online, but it seems that setting
734-
// GWL_HWNDPARENT to a window which is on the non-primary monitor can cause two
735-
// WM_DPICHANGED messages to be sent: the first changing the DPI to the parent's DPI,
736-
// then another changing the DPI back. This then causes Windows to provide an incorrect
737-
// suggested new rectangle to the WM_DPICHANGED message if the window is immediately
738-
// moved to the parent window's monitor (e.g. when using
739-
// WindowStartupLocation.CenterOwner) causing the window to be shown with an incorrect
740-
// size.
741-
//
742-
// Just ignore any WM_DPICHANGED while we're setting the parent as this shouldn't
743-
// change the DPI anyway.
744-
_ignoreDpiChanges = true;
745732
SetWindowLongPtr(_hwnd, (int)WindowLongParam.GWL_HWNDPARENT, parentHwnd);
746-
_ignoreDpiChanges = false;
747733

748734
// Windows doesn't seem to respect the HWND_TOPMOST flag of a window when showing an owned window for the first time.
749735
// So we set the HWND_TOPMOST again before the owned window is shown. This only needs to be done once.

0 commit comments

Comments
 (0)