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; bool qpaReady = false;
quint32 qpaWaitTime = 0; quint32 qpaWaitTime = 0;
QTimer repaintTimer{}; QTimer repaintTimer{};
bool repaintedOnce = false;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

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

View File

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

View File

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