win: minor fix

This commit is contained in:
Zhao Yuhang 2023-10-19 20:13:34 +08:00
parent aa489b25d0
commit 2cb8ec0aeb
4 changed files with 13 additions and 13 deletions

View File

@ -87,6 +87,7 @@ public:
bool qpaReady = false;
quint32 qpaWaitTime = 0;
QTimer repaintTimer{};
bool repaintedOnce = false;
};
FRAMELESSHELPER_END_NAMESPACE

View File

@ -87,6 +87,7 @@ public:
QSizePolicy savedSizePolicy = {};
quint32 qpaWaitTime = 0;
QTimer repaintTimer{};
bool repaintedOnce = false;
};
FRAMELESSHELPER_END_NAMESPACE

View File

@ -410,10 +410,7 @@ void FramelessQuickHelperPrivate::repaintAllChildren()
void FramelessQuickHelperPrivate::doRepaintAllChildren()
{
repaintTimer.stop();
static bool firstTime = true;
if (firstTime) {
firstTime = false;
} else {
if (repaintedOnce) {
Q_Q(const FramelessQuickHelper);
QQuickWindow *window = q->window();
if (!window) {
@ -423,7 +420,7 @@ void FramelessQuickHelperPrivate::doRepaintAllChildren()
// Sync the internal window frame margins with the latest DPI, otherwise
// we will get wrong window sizes after the DPI change.
std::ignore = Utils::updateInternalWindowFrameMargins(window, true);
#endif // Q_OS_WINDOWS
#endif // Q_OS_WINDOWS \
// No need to repaint the window when it's hidden.
if (!window->isVisible()) {
return;
@ -446,6 +443,8 @@ void FramelessQuickHelperPrivate::doRepaintAllChildren()
}
}
#endif
} else {
repaintedOnce = true;
}
}

View File

@ -375,18 +375,17 @@ void FramelessWidgetsHelperPrivate::repaintAllChildren()
void FramelessWidgetsHelperPrivate::doRepaintAllChildren()
{
repaintTimer.stop();
if (repaintedOnce) {
if (!window) {
return;
}
static bool firstTime = true;
if (firstTime) {
firstTime = false;
} else {
forceWidgetRepaint(window);
const QList<QWidget *> widgets = window->findChildren<QWidget *>();
for (auto &&widget : std::as_const(widgets)) {
forceWidgetRepaint(widget);
}
} else {
repaintedOnce = true;
}
}