From f3721da17996168489778327459084dd227690d6 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周六, 23 12月 2023 23:29:39 +0800 Subject: [PATCH] Adjust paint event handler --- src/widgets/widgetwindowagent_win.cpp | 15 ++++++++++++++- src/core/contexts/abstractwindowcontext_p.h | 2 +- src/core/windowagentbase.h | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext_p.h b/src/core/contexts/abstractwindowcontext_p.h index fec421e..db4b5cc 100644 --- a/src/core/contexts/abstractwindowcontext_p.h +++ b/src/core/contexts/abstractwindowcontext_p.h @@ -88,7 +88,7 @@ #endif QObject *m_titleBar{}; - std::array<QObject *, WindowAgentBase::NumSystemButton> m_systemButtons{}; + std::array<QObject *, WindowAgentBase::Close + 1> m_systemButtons{}; QVariantHash m_windowAttributes; diff --git a/src/core/windowagentbase.h b/src/core/windowagentbase.h index 00ccff1..c6507c6 100644 --- a/src/core/windowagentbase.h +++ b/src/core/windowagentbase.h @@ -24,7 +24,6 @@ Minimize, Maximize, Close, - NumSystemButton, }; Q_ENUM(SystemButton) diff --git a/src/widgets/widgetwindowagent_win.cpp b/src/widgets/widgetwindowagent_win.cpp index fb9dce3..7901bac 100644 --- a/src/widgets/widgetwindowagent_win.cpp +++ b/src/widgets/widgetwindowagent_win.cpp @@ -9,6 +9,9 @@ namespace QWK { #if QWINDOWKIT_CONFIG(ENABLE_WINDOWS_SYSTEM_BORDER) + + class WidgetBorderHandler; + class WidgetBorderHandler : public QObject, public NativeEventFilter { public: explicit WidgetBorderHandler(QWidget *widget, AbstractWindowContext *ctx) @@ -73,6 +76,16 @@ (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen)) break; + // Friend class helping to call `event` + class HackedWidget : public QWidget { + public: + friend class WidgetBorderHandler; + }; + + // Let the widget paint first + static_cast<HackedWidget *>(widget)->event(event); + + // Draw border auto paintEvent = static_cast<QPaintEvent *>(event); auto rect = paintEvent->rect(); auto region = paintEvent->region(); @@ -84,7 +97,7 @@ ®ion, }; ctx->virtual_hook(AbstractWindowContext::DrawWindows10BorderHook, args); - break; + return true; } case QEvent::WindowStateChange: { -- Gitblit v1.9.1