Revert "Move FloatingWindow::setupWindow() into a reusable function"
This reverts commit 6fea5af585.
Need to fix the windows build first
This commit is contained in:
@@ -102,7 +102,7 @@ FloatingWindow::FloatingWindow(MainWindowBase *parent)
|
||||
{
|
||||
if (kddwUsesQtWidgets()) {
|
||||
// For QtQuick we do it a bit later, once we have the QQuickWindow
|
||||
WidgetResizeHandler::setupWindow(windowHandle());
|
||||
setupWindow();
|
||||
}
|
||||
|
||||
DockRegistry::self()->registerFloatingWindow(this);
|
||||
@@ -145,6 +145,35 @@ FloatingWindow::~FloatingWindow()
|
||||
DockRegistry::self()->unregisterFloatingWindow(this);
|
||||
}
|
||||
|
||||
void FloatingWindow::setupWindow()
|
||||
{
|
||||
// Does some minor setup on our QWindow.
|
||||
// Like adding the drop shadow on Windows and two other workarounds.
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// On Windows with Qt 5.9 (and maybe earlier), the WM_NCALCSIZE isn't being processed unless we explicitly create the window.
|
||||
// So create it now, otherwise floating dock widgets will show a native title bar until resized.
|
||||
create();
|
||||
|
||||
if (KDDockWidgets::usesAeroSnapWithCustomDecos()) {
|
||||
# ifdef KDDOCKWIDGETS_QTWIDGETS
|
||||
m_nchittestFilter = new NCHITTESTEventFilter(this);
|
||||
qApp->installNativeEventFilter(m_nchittestFilter);
|
||||
#endif
|
||||
connect(windowHandle(), &QWindow::screenChanged, this, [this] {
|
||||
// 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 note of the margins we're using.
|
||||
SetWindowPos(HWND(winId()), 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
});
|
||||
|
||||
// Show drop-shadow:
|
||||
MARGINS margins = {0, 0, 0, 1}; // arbitrary, just needs to be > 0 it seems
|
||||
DwmExtendFrameIntoClientArea(HWND(winId()), &margins);
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(KDDOCKWIDGETS_QTWIDGETS)
|
||||
bool FloatingWindow::nativeEvent(const QByteArray &eventType, void *message, Qt5Qt6Compat::qintptr *result)
|
||||
{
|
||||
|
||||
@@ -168,6 +168,7 @@ Q_SIGNALS:
|
||||
void numFramesChanged();
|
||||
void windowStateChanged(QWindowStateChangeEvent *);
|
||||
protected:
|
||||
void setupWindow();
|
||||
void maybeCreateResizeHandler();
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(KDDOCKWIDGETS_QTWIDGETS)
|
||||
|
||||
@@ -488,37 +488,6 @@ CursorPosition WidgetResizeHandler::cursorPosition(QPoint globalPos) const
|
||||
return static_cast<CursorPosition>(result);
|
||||
}
|
||||
|
||||
/** static */
|
||||
void WidgetResizeHandler::setupWindow(QWindow *window)
|
||||
{
|
||||
// Does some minor setup on our QWindow.
|
||||
// Like adding the drop shadow on Windows and two other workarounds.
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
if (KDDockWidgets::usesAeroSnapWithCustomDecos()) {
|
||||
#ifdef KDDOCKWIDGETS_QTWIDGETS
|
||||
m_nchittestFilter = new NCHITTESTEventFilter(this);
|
||||
qApp->installNativeEventFilter(m_nchittestFilter);
|
||||
#endif
|
||||
const auto wid = HWND(window->winId());
|
||||
connect(window, &QWindow::screenChanged, this, [this] {
|
||||
// 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
|
||||
// note of the margins we're using.
|
||||
SetWindowPos(wid, 0, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
});
|
||||
|
||||
// Show drop-shadow:
|
||||
MARGINS margins = { 0, 0, 0, 1 }; // arbitrary, just needs to be > 0 it seems
|
||||
DwmExtendFrameIntoClientArea(wid, &margins);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(window);
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(KDDOCKWIDGETS_QTWIDGETS)
|
||||
bool NCHITTESTEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
Qt5Qt6Compat::qintptr *result)
|
||||
|
||||
@@ -69,8 +69,6 @@ public:
|
||||
|
||||
static int widgetResizeHandlerMargin();
|
||||
|
||||
static void setupWindow(QWindow *window);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static bool handleWindowsNativeEvent(FloatingWindow *w, const QByteArray &eventType, void *message, Qt5Qt6Compat::qintptr *result);
|
||||
#endif
|
||||
|
||||
@@ -187,7 +187,7 @@ void FloatingWindowQuick::init()
|
||||
}
|
||||
|
||||
QWidgetAdapter::setParent(m_quickWindow->contentItem());
|
||||
WidgetResizeHandler::setupWindow(m_quickWindow);
|
||||
setupWindow();
|
||||
m_quickWindow->installEventFilter(this); // for window resizing
|
||||
maybeCreateResizeHandler();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "Config.h"
|
||||
#include "FrameworkWidgetFactory.h"
|
||||
#include "TabWidgetQuick_p.h"
|
||||
#include "WidgetResizeHandler_p.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
Reference in New Issue
Block a user