From 92d850c2a9fa8f926be560d0cb4aa5f3172457fd Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Wed, 17 May 2023 13:22:42 +0800 Subject: [PATCH] add support for Qt 6.6's DPR change event --- src/core/framelesshelper_qt.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/framelesshelper_qt.cpp b/src/core/framelesshelper_qt.cpp index 0a37cc0..97a05ca 100644 --- a/src/core/framelesshelper_qt.cpp +++ b/src/core/framelesshelper_qt.cpp @@ -162,9 +162,13 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) return QObject::eventFilter(object, event); } const QEvent::Type type = event->type(); - // We are only interested in some specific mouse events. + // We are only interested in some specific mouse events (plus DPR change event since Qt 6.6). if ((type != QEvent::MouseButtonPress) && (type != QEvent::MouseButtonRelease) - && (type != QEvent::MouseButtonDblClick) && (type != QEvent::MouseMove)) { + && (type != QEvent::MouseButtonDblClick) && (type != QEvent::MouseMove) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) + && (type != QEvent::DevicePixelRatioChange) +#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) + ) { return QObject::eventFilter(object, event); } const auto window = qobject_cast(object); @@ -176,6 +180,12 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) } const QtHelperData data = g_qtHelper()->data.value(windowId); g_qtHelper()->mutex.unlock(); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) + if (type == QEvent::DevicePixelRatioChange) { + data.params.forceChildrenRepaint(500); + return QObject::eventFilter(object, event); + } +#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) const auto mouseEvent = static_cast(event); const Qt::MouseButton button = mouseEvent->button(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))