win: minor improvements
This commit is contained in:
parent
a1b0568630
commit
5670a28559
|
@ -86,7 +86,6 @@ 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
|
||||||
|
|
|
@ -86,7 +86,6 @@ public:
|
||||||
QSizePolicy savedSizePolicy = {};
|
QSizePolicy savedSizePolicy = {};
|
||||||
quint32 qpaWaitTime = 0;
|
quint32 qpaWaitTime = 0;
|
||||||
QTimer repaintTimer{};
|
QTimer repaintTimer{};
|
||||||
bool repaintedOnce = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -72,7 +72,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
static constexpr const auto kRepaintTimerInterval = 500;
|
static constexpr const auto kRepaintTimerInterval = 300;
|
||||||
|
|
||||||
struct FramelessQuickHelperExtraData : public FramelessExtraData
|
struct FramelessQuickHelperExtraData : public FramelessExtraData
|
||||||
{
|
{
|
||||||
|
@ -414,42 +414,38 @@ void FramelessQuickHelperPrivate::repaintAllChildren()
|
||||||
void FramelessQuickHelperPrivate::doRepaintAllChildren()
|
void FramelessQuickHelperPrivate::doRepaintAllChildren()
|
||||||
{
|
{
|
||||||
repaintTimer.stop();
|
repaintTimer.stop();
|
||||||
if (repaintedOnce) {
|
Q_Q(const FramelessQuickHelper);
|
||||||
Q_Q(const FramelessQuickHelper);
|
QQuickWindow *window = q->window();
|
||||||
QQuickWindow *window = q->window();
|
if (!window) {
|
||||||
if (!window) {
|
return;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
#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
|
quint32 FramelessQuickHelperPrivate::readyWaitTime() const
|
||||||
|
|
|
@ -71,7 +71,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
static constexpr const auto kRepaintTimerInterval = 500;
|
static constexpr const auto kRepaintTimerInterval = 300;
|
||||||
|
|
||||||
struct FramelessWidgetsHelperExtraData : public FramelessExtraData
|
struct FramelessWidgetsHelperExtraData : public FramelessExtraData
|
||||||
{
|
{
|
||||||
|
@ -378,17 +378,13 @@ void FramelessWidgetsHelperPrivate::repaintAllChildren()
|
||||||
void FramelessWidgetsHelperPrivate::doRepaintAllChildren()
|
void FramelessWidgetsHelperPrivate::doRepaintAllChildren()
|
||||||
{
|
{
|
||||||
repaintTimer.stop();
|
repaintTimer.stop();
|
||||||
if (repaintedOnce) {
|
if (!window) {
|
||||||
if (!window) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue