From cb107b127a1e85508ff326ce5fe71c73d17dc9fb Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 29 Sep 2022 15:01:59 +0800 Subject: [PATCH] win: add one more workaround of Qt bug Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/framelesshelper_win.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index 362e18d..1b964db 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -1080,6 +1080,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me case WM_DPICHANGED: { // Sync the internal window frame margins with the latest DPI. Utils::updateInternalWindowFrameMargins(data.params.getWindowHandle(), true); + // For some unknown reason, Qt sometimes won't re-paint the window contents after + // the DPI changes, and in my experiments the controls should be moved to our + // desired geometry already, the only issue is we don't get the updated appearance + // of our window. And we can workaround this issue by simply triggering a resize + // event manually. There's no need to increase/decrease the window size and then + // change it back, just give Qt our current window size is sufficient enough. + data.params.setWindowSize(data.params.getWindowSize()); } break; case WM_DWMCOMPOSITIONCHANGED: { // Re-apply the custom window frame if recovered from the basic theme.