12#include "CustomFrameHelper_p.h"
13#include "core/Logging_p.h"
14#include "core/ScopedValueRollback_p.h"
15#include "core/Utils_p.h"
16#include "core/Window_p.h"
17#include "qtcommon/Window_p.h"
19#include <QGuiApplication>
24#ifdef KDDW_FRONTEND_QT_WINDOWS
26Window::Ptr windowForHandle(
WId id)
29 for (Core::Window::Ptr w : windows) {
30 if (w->isVisible() && w->handle() ==
id) {
39CustomFrameHelper::CustomFrameHelper(ShouldUseCustomFrame func,
QObject *parent)
41 , m_shouldUseCustomFrameFunc(func)
43#if defined(KDDW_FRONTEND_QT_WINDOWS)
44 qGuiApp->installNativeEventFilter(
this);
48CustomFrameHelper::~CustomFrameHelper()
53void CustomFrameHelper::applyCustomFrame(Core::Window::Ptr window)
55#ifdef KDDW_FRONTEND_QT_WINDOWS
56 WidgetResizeHandler::setupWindow(window);
59 KDDW_ERROR(
"Not implemented on this platform");
63bool CustomFrameHelper::nativeEventFilter(
const QByteArray &eventType,
void *message,
64 Qt5Qt6Compat::qintptr *result)
66 if (m_shouldUseCustomFrameFunc ==
nullptr || m_recursionGuard)
69 ScopedValueRollback guard(m_recursionGuard,
true);
71#ifdef KDDW_FRONTEND_QT_WINDOWS
72 if (m_inDtor || !KDDockWidgets::usesAeroSnapWithCustomDecos())
75 if (eventType !=
"windows_generic_MSG")
78 auto msg =
static_cast<MSG *
>(message);
79 if (!WidgetResizeHandler::isInterestingNativeEvent(msg->message)) {
84 Window::Ptr window = KDDockWidgets::windowForHandle(
WId(msg->hwnd));
88 const WidgetResizeHandler::NativeFeatures features = m_shouldUseCustomFrameFunc(window);
89 if (!features.hasFeatures()) {
94 const char *propertyName =
"kddw_customframe_setup_ran";
95 auto windowQt =
static_cast<QtCommon::Window *
>(window.get());
96 const bool setupRan = windowQt->property(propertyName).toBool();
99 WidgetResizeHandler::setupWindow(window);
100 windowQt->setProperty(propertyName,
true);
103 return WidgetResizeHandler::handleWindowsNativeEvent(window, msg, result, features);