From 03c2a26820691493f5ebe86f64e0e360b0561642 Mon Sep 17 00:00:00 2001 From: Zhao Yuhang <2546789017@qq.com> Date: 周六, 23 12月 2023 17:20:31 +0800 Subject: [PATCH] fix demo acrylic --- src/widgets/widgetwindowagent_win.cpp | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/widgets/widgetwindowagent_win.cpp b/src/widgets/widgetwindowagent_win.cpp index 2a67ebb..fb9dce3 100644 --- a/src/widgets/widgetwindowagent_win.cpp +++ b/src/widgets/widgetwindowagent_win.cpp @@ -3,12 +3,13 @@ #include <QtGui/QPainter> #include <QWKCore/qwindowkit_windows.h> +#include <QWKCore/qwkconfig.h> #include <QWKCore/private/nativeeventfilter_p.h> namespace QWK { +#if QWINDOWKIT_CONFIG(ENABLE_WINDOWS_SYSTEM_BORDER) class WidgetBorderHandler : public QObject, public NativeEventFilter { - Q_OBJECT public: explicit WidgetBorderHandler(QWidget *widget, AbstractWindowContext *ctx) : QObject(ctx), widget(widget), ctx(ctx) { @@ -35,7 +36,7 @@ bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override { Q_UNUSED(eventType) - auto msg = reinterpret_cast<const MSG *>(message); + const auto msg = static_cast<const MSG *>(message); switch (msg->message) { case WM_DPICHANGED: { updateGeometry(); @@ -65,9 +66,11 @@ } bool eventFilter(QObject *obj, QEvent *event) override { + Q_UNUSED(obj) switch (event->type()) { case QEvent::Paint: { - if (widget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) + if (widget->windowState() & + (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen)) break; auto paintEvent = static_cast<QPaintEvent *>(event); @@ -81,7 +84,7 @@ ®ion, }; ctx->virtual_hook(AbstractWindowContext::DrawWindows10BorderHook, args); - return true; + break; } case QEvent::WindowStateChange: { @@ -104,15 +107,16 @@ QWidget *widget; AbstractWindowContext *ctx; }; +#endif void WidgetWindowAgentPrivate::setupWindows10BorderWorkaround() { +#if QWINDOWKIT_CONFIG(ENABLE_WINDOWS_SYSTEM_BORDER) // Install painting hook auto ctx = context.get(); if (ctx->property("needBorderPainter").toBool()) { std::ignore = new WidgetBorderHandler(hostWidget, ctx); } +#endif } } - -#include "widgetwindowagent_win.moc" \ No newline at end of file -- Gitblit v1.9.1