win: add one more workaround of Qt bug

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-09-29 15:01:59 +08:00
parent d1a410b498
commit cb107b127a
1 changed files with 7 additions and 0 deletions

View File

@ -1080,6 +1080,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
case WM_DPICHANGED: { case WM_DPICHANGED: {
// Sync the internal window frame margins with the latest DPI. // Sync the internal window frame margins with the latest DPI.
Utils::updateInternalWindowFrameMargins(data.params.getWindowHandle(), true); 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; } break;
case WM_DWMCOMPOSITIONCHANGED: { case WM_DWMCOMPOSITIONCHANGED: {
// Re-apply the custom window frame if recovered from the basic theme. // Re-apply the custom window frame if recovered from the basic theme.