windows: Port AeroSnap to the new API
This commit is contained in:
@@ -516,15 +516,15 @@ CursorPosition WidgetResizeHandler::cursorPosition(QPoint globalPos) const
|
||||
}
|
||||
|
||||
/** static */
|
||||
void WidgetResizeHandler::setupWindow(QWindow *window)
|
||||
void WidgetResizeHandler::setupWindow(Window::Ptr window)
|
||||
{
|
||||
// Does some minor setup on our QWindow.
|
||||
// Like adding the drop shadow on Windows and two other workarounds.
|
||||
|
||||
#if defined(Q_OS_WIN_TODO)
|
||||
#if defined(Q_OS_WIN)
|
||||
if (KDDockWidgets::usesAeroSnapWithCustomDecos()) {
|
||||
const auto wid = HWND(window->winId());
|
||||
connect(window, &QWindow::screenChanged, window, [wid] {
|
||||
const auto wid = HWND(window->handle());
|
||||
window->screenChanged.connect([wid] {
|
||||
// Qt honors our frame hijacking usually... but when screen changes we must give it a
|
||||
// nudge. Otherwise what Qt thinks is the client area is not what Windows knows it is.
|
||||
// SetWindowPos() will trigger an NCCALCSIZE message, which Qt will intercept and take
|
||||
@@ -607,9 +607,9 @@ CustomFrameHelper::~CustomFrameHelper()
|
||||
m_inDtor = true;
|
||||
}
|
||||
|
||||
void CustomFrameHelper::applyCustomFrame(QWindow *window)
|
||||
void CustomFrameHelper::applyCustomFrame(Window::Ptr window)
|
||||
{
|
||||
#ifdef Q_OS_WIN_TODO
|
||||
#ifdef Q_OS_WIN
|
||||
WidgetResizeHandler::setupWindow(window);
|
||||
#else
|
||||
Q_UNUSED(window);
|
||||
@@ -625,7 +625,7 @@ bool CustomFrameHelper::nativeEventFilter(const QByteArray &eventType, void *mes
|
||||
|
||||
QScopedValueRollback<bool> guard(m_recursionGuard, true);
|
||||
|
||||
#ifdef Q_OS_WIN_TODO
|
||||
#ifdef Q_OS_WIN
|
||||
if (m_inDtor || !KDDockWidgets::usesAeroSnapWithCustomDecos())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
|
||||
static int widgetResizeHandlerMargin();
|
||||
|
||||
static void setupWindow(QWindow *window);
|
||||
static void setupWindow(Window::Ptr);
|
||||
#ifdef Q_OS_WIN
|
||||
static bool isInterestingNativeEvent(unsigned int);
|
||||
static bool handleWindowsNativeEvent(Window::Ptr, MSG *msg, Qt5Qt6Compat::qintptr *result, const NativeFeatures &);
|
||||
@@ -194,13 +194,13 @@ class DOCKS_EXPORT CustomFrameHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef WidgetResizeHandler::NativeFeatures (*ShouldUseCustomFrame)(QWindow *);
|
||||
typedef WidgetResizeHandler::NativeFeatures (*ShouldUseCustomFrame)(Window::Ptr);
|
||||
explicit CustomFrameHelper(ShouldUseCustomFrame shouldUseCustomFrameFunc,
|
||||
QObject *parent = nullptr);
|
||||
~CustomFrameHelper() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void applyCustomFrame(QWindow *);
|
||||
void applyCustomFrame(Window::Ptr);
|
||||
|
||||
protected:
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "private/WidgetResizeHandler_p.h"
|
||||
#include "qtquick/Platform_qtquick.h"
|
||||
#include "qtquick/Window_qtquick.h"
|
||||
#include "qtquick/views/MainWindow_qtquick.h"
|
||||
#include "qtquick/views/TitleBar_qtquick.h"
|
||||
#include "qtquick/views/DropArea_qtquick.h"
|
||||
@@ -190,7 +191,7 @@ void FloatingWindow_qtquick::init()
|
||||
}
|
||||
|
||||
setParent(m_quickWindow->contentItem());
|
||||
WidgetResizeHandler::setupWindow(m_quickWindow);
|
||||
WidgetResizeHandler::setupWindow(Window::Ptr(new Window_qtquick(m_quickWindow)));
|
||||
m_quickWindow->installEventFilter(this); // for window resizing
|
||||
m_controller->maybeCreateResizeHandler();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user