File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040#endif
4141
4242#include < dwmapi.h>
43+ #include < shellscalingapi.h>
4344#include < unknwn.h>
4445#include < windows.ui.xaml.hosting.desktopwindowxamlsource.h>
4546#include < winrt/Windows.Foundation.h>
@@ -3240,7 +3241,18 @@ class PopupWindow {
32403241 if (!GetMonitorInfoW (monitor, &info)) {
32413242 return ;
32423243 }
3243- const UINT dpi = GetDpiForWindow (hwnd_);
3244+ // Size for the monitor the popup is GOING to, not the one the hidden
3245+ // window happens to be parked on (GetDpiForWindow): when the two
3246+ // disagree — mixed-DPI setups, or a DPI topology change (RDP
3247+ // reconnect, resolution flip) since the window was placed — the old
3248+ // code sized at the stale scale and left WM_DPICHANGED's mid-
3249+ // SetWindowPos suggested-rect rescue racing the explicit size
3250+ // (observed in the wild: a quarter-size popup at 200%).
3251+ UINT dpi = 0 ;
3252+ UINT dpiYIgnored = 0 ;
3253+ if (FAILED (GetDpiForMonitor (monitor, MDT_EFFECTIVE_DPI , &dpi, &dpiYIgnored)) || dpi == 0 ) {
3254+ dpi = GetDpiForWindow (hwnd_);
3255+ }
32443256 const int width = DipsToPixels (CurrentWidthDips (), dpi);
32453257 const int height = DipsToPixels (kPopupHeightDips , dpi);
32463258 const RECT & work = info.rcWork ;
You can’t perform that action at this time.
0 commit comments