From f7c2852fd5d31b146bac97485548ee5df12e05d5 Mon Sep 17 00:00:00 2001 From: Julien Maille Date: Sat, 28 Nov 2026 14:01:38 +0100 Subject: [PATCH] fix(widgets): ignore title controls in other Win32 windows --- src/widgets/widgetwindowagent.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/widgets/widgetwindowagent.cpp b/src/widgets/widgetwindowagent.cpp index 0ae4fed..82ee46d 100644 --- a/src/widgets/widgetwindowagent.cpp +++ b/src/widgets/widgetwindowagent.cpp @@ -8,11 +8,34 @@ #include #include #include +#include #include "widgetitemdelegate_p.h" namespace QWK { +#if defined(Q_OS_WINDOWS) && !QWINDOWKIT_CONFIG(FORCE_QT_WINDOW_CONTEXT) + namespace { + class WindowBoundWidgetItemDelegate final : public WidgetItemDelegate { + public: + explicit WindowBoundWidgetItemDelegate(QWidget *host) : m_host(host) { + } + + QRect mapGeometryToScene(const QObject *obj) const override { + const auto *widget = static_cast(obj); + const auto *window = widget->window(); + if (!m_host || window != m_host->window()) { + return {}; + } + return {widget->mapTo(window, QPoint(0, 0)), widget->size()}; + } + + private: + QPointer m_host; + }; + } +#endif + /*! \class WidgetWindowAgent \brief WindowAgentBase is the window agent for QtWidgets. @@ -70,7 +93,11 @@ namespace QWK { // various hooks. // w->setAttribute(Qt::WA_NativeWindow); // ### FIXME: Check +#if defined(Q_OS_WINDOWS) && !QWINDOWKIT_CONFIG(FORCE_QT_WINDOW_CONTEXT) + d->setup(w, new WindowBoundWidgetItemDelegate(w)); +#else d->setup(w, new WidgetItemDelegate()); +#endif d->hostWidget = w; #ifdef Q_OS_MAC