win: minor improvements
This commit is contained in:
parent
a1b0568630
commit
5670a28559
|
@ -86,7 +86,6 @@ public:
|
|||
bool qpaReady = false;
|
||||
quint32 qpaWaitTime = 0;
|
||||
QTimer repaintTimer{};
|
||||
bool repaintedOnce = false;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -86,7 +86,6 @@ public:
|
|||
QSizePolicy savedSizePolicy = {};
|
||||
quint32 qpaWaitTime = 0;
|
||||
QTimer repaintTimer{};
|
||||
bool repaintedOnce = false;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -72,7 +72,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
using namespace Global;
|
||||
|
||||
static constexpr const auto kRepaintTimerInterval = 500;
|
||||
static constexpr const auto kRepaintTimerInterval = 300;
|
||||
|
||||
struct FramelessQuickHelperExtraData : public FramelessExtraData
|
||||
{
|
||||
|
@ -414,42 +414,38 @@ void FramelessQuickHelperPrivate::repaintAllChildren()
|
|||
void FramelessQuickHelperPrivate::doRepaintAllChildren()
|
||||
{
|
||||
repaintTimer.stop();
|
||||
if (repaintedOnce) {
|
||||
Q_Q(const FramelessQuickHelper);
|
||||
QQuickWindow *window = q->window();
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
#if (defined(Q_OS_WINDOWS) && (QT_VERSION != QT_VERSION_CHECK(6, 5, 3)) && (QT_VERSION != QT_VERSION_CHECK(6, 6, 0)))
|
||||
// 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
|
||||
// No need to repaint the window when it's hidden.
|
||||
if (!window->isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (!((window->windowState() & (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen)) || q->isWindowFixedSize())) {
|
||||
const QSize originalSize = window->size();
|
||||
static constexpr const auto margins = QMargins{ 1, 1, 1, 1 };
|
||||
window->resize(originalSize.shrunkBy(margins));
|
||||
window->resize(originalSize.grownBy(margins));
|
||||
window->resize(originalSize);
|
||||
}
|
||||
window->requestUpdate();
|
||||
#if 0 // Calling QWindow::requestUpdate() should be enough.
|
||||
const QList<QQuickItem *> items = window->findChildren<QQuickItem *>();
|
||||
for (auto &&item : std::as_const(items)) {
|
||||
// Only items with the "QQuickItem::ItemHasContents" flag enabled are allowed to call "update()".
|
||||
// And don't repaint the item if it's hidden.
|
||||
if ((item->flags() & QQuickItem::ItemHasContents) && item->isVisible()) {
|
||||
item->update();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
repaintedOnce = true;
|
||||
Q_Q(const FramelessQuickHelper);
|
||||
QQuickWindow *window = q->window();
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
#if (defined(Q_OS_WINDOWS) && (QT_VERSION != QT_VERSION_CHECK(6, 5, 3)) && (QT_VERSION != QT_VERSION_CHECK(6, 6, 0)))
|
||||
// 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
|
||||
// No need to repaint the window when it's hidden.
|
||||
if (!window->isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (!((window->windowState() & (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen)) || q->isWindowFixedSize())) {
|
||||
const QSize originalSize = window->size();
|
||||
static constexpr const auto margins = QMargins{ 1, 1, 1, 1 };
|
||||
window->resize(originalSize.shrunkBy(margins));
|
||||
window->resize(originalSize.grownBy(margins));
|
||||
window->resize(originalSize);
|
||||
}
|
||||
window->requestUpdate();
|
||||
#if 0 // Calling QWindow::requestUpdate() should be enough.
|
||||
const QList<QQuickItem *> items = window->findChildren<QQuickItem *>();
|
||||
for (auto &&item : std::as_const(items)) {
|
||||
// Only items with the "QQuickItem::ItemHasContents" flag enabled are allowed to call "update()".
|
||||
// And don't repaint the item if it's hidden.
|
||||
if ((item->flags() & QQuickItem::ItemHasContents) && item->isVisible()) {
|
||||
item->update();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
quint32 FramelessQuickHelperPrivate::readyWaitTime() const
|
||||
|
|
|
@ -71,7 +71,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
using namespace Global;
|
||||
|
||||
static constexpr const auto kRepaintTimerInterval = 500;
|
||||
static constexpr const auto kRepaintTimerInterval = 300;
|
||||
|
||||
struct FramelessWidgetsHelperExtraData : public FramelessExtraData
|
||||
{
|
||||
|
@ -378,17 +378,13 @@ void FramelessWidgetsHelperPrivate::repaintAllChildren()
|
|||
void FramelessWidgetsHelperPrivate::doRepaintAllChildren()
|
||||
{
|
||||
repaintTimer.stop();
|
||||
if (repaintedOnce) {
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
forceWidgetRepaint(window);
|
||||
const QList<QWidget *> widgets = window->findChildren<QWidget *>();
|
||||
for (auto &&widget : std::as_const(widgets)) {
|
||||
forceWidgetRepaint(widget);
|
||||
}
|
||||
} else {
|
||||
repaintedOnce = true;
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
forceWidgetRepaint(window);
|
||||
const QList<QWidget *> widgets = window->findChildren<QWidget *>();
|
||||
for (auto &&widget : std::as_const(widgets)) {
|
||||
forceWidgetRepaint(widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue