diff --git a/framelesswindowsmanager.cpp b/framelesswindowsmanager.cpp index 83ab4c1..d65a5d5 100644 --- a/framelesswindowsmanager.cpp +++ b/framelesswindowsmanager.cpp @@ -26,6 +26,8 @@ #include #include "utilities.h" #ifdef Q_OS_WINDOWS +#include +#include #include "framelesshelper_win32.h" #else #include "framelesshelper.h" @@ -44,7 +46,20 @@ void FramelessWindowsManager::addWindow(const QWindow *window) return; } #ifdef Q_OS_WINDOWS - FramelessHelperWin::addFramelessWindow(const_cast(window)); + const auto win = const_cast(window); + FramelessHelperWin::addFramelessWindow(win); + // Work-around a Win32 multi-monitor bug. + QObject::connect(win, &QWindow::screenChanged, [win](QScreen *screen){ + Q_UNUSED(screen); + const QSize originalSize = win->size(); + // Don't make the tempSize too large/small otherwise the user will see the resize. + const QSize tempSize = originalSize + QSize{1, 1}; + // Do a resize manually to forcely trigger the re-layout and re-paint of the window. + win->resize(tempSize); + // We need to let the OS have enough time to do the actual change. + QThread::msleep(500); // FIXME: is it enough? + win->resize(originalSize); + }); #else framelessHelper()->removeWindowFrame(const_cast(window)); #endif