Compare commits
1 Commits
a6e0de9db9
...
aero_suppo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b90d912b2 |
@@ -154,6 +154,10 @@ if (NOT WIN32 AND NOT APPLE)
|
|||||||
target_link_libraries(kddockwidgets PUBLIC Qt5::X11Extras)
|
target_link_libraries(kddockwidgets PUBLIC Qt5::X11Extras)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries(kddockwidgets PUBLIC Qt5::GuiPrivate)
|
||||||
|
endif()
|
||||||
|
|
||||||
install (TARGETS kddockwidgets kddockwidgets_multisplitter
|
install (TARGETS kddockwidgets kddockwidgets_multisplitter
|
||||||
EXPORT kddockwidgetsTargets
|
EXPORT kddockwidgetsTargets
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
|
|||||||
@@ -32,6 +32,14 @@
|
|||||||
# include <QtX11Extras/QX11Info>
|
# include <QtX11Extras/QX11Info>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
# include <QMargins>
|
||||||
|
# include <QWindow>
|
||||||
|
# include <QVariant>
|
||||||
|
# include <qpa/qplatformnativeinterface.h>
|
||||||
|
# include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace KDDockWidgets {
|
namespace KDDockWidgets {
|
||||||
|
|
||||||
inline bool isLeftButtonPressed()
|
inline bool isLeftButtonPressed()
|
||||||
@@ -92,6 +100,33 @@ inline int screenNumberForWidget(const QWidget *w)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
inline void extendClientAreaOverTitleBar(QWindow *window)
|
||||||
|
{
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QPlatformWindow *platformWindow = window->handle();
|
||||||
|
if (!platformWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto hwnd = HWND(window->winId());
|
||||||
|
const auto style = GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||||
|
const auto exStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||||
|
|
||||||
|
const RECT arbitraryClientRect = { 0, 0, 800, 800 };
|
||||||
|
RECT ncRect = arbitraryClientRect;
|
||||||
|
|
||||||
|
AdjustWindowRectEx(&ncRect, style, FALSE, exStyle);
|
||||||
|
const int titleBarHeight = arbitraryClientRect.top - ncRect.top;
|
||||||
|
|
||||||
|
const QVariant newMargins = QVariant::fromValue(QMargins(0, -titleBarHeight, 0, 0));
|
||||||
|
window->setProperty("_q_windowsCustomMargins", newMargins);
|
||||||
|
QGuiApplication::platformNativeInterface()->setWindowProperty(platformWindow, QStringLiteral("WindowsCustomMargins"), newMargins);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QMargins);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -215,8 +215,8 @@ bool WidgetResizeHandler::handleWindowsNativeEvent(FloatingWindow *w, const QByt
|
|||||||
|
|
||||||
auto msg = static_cast<MSG *>(message);
|
auto msg = static_cast<MSG *>(message);
|
||||||
if (msg->message == WM_NCCALCSIZE) {
|
if (msg->message == WM_NCCALCSIZE) {
|
||||||
*result = 0;
|
// Let's use Qt's "WindowCustomMargins" instead, otherwise QWindow won't know
|
||||||
return true;
|
return false;
|
||||||
} else if (msg->message == WM_NCHITTEST) {
|
} else if (msg->message == WM_NCHITTEST) {
|
||||||
|
|
||||||
if (DragController::instance()->isInClientDrag()) {
|
if (DragController::instance()->isInClientDrag()) {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include "Utils_p.h"
|
#include "Utils_p.h"
|
||||||
#include "DropArea_p.h"
|
#include "DropArea_p.h"
|
||||||
#include "TitleBar_p.h"
|
#include "TitleBar_p.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -60,6 +59,21 @@ bool FloatingWindowWidget::event(QEvent *ev)
|
|||||||
return FloatingWindow::event(ev);
|
return FloatingWindow::event(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
bool FloatingWindowWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
|
||||||
|
{
|
||||||
|
if (!KDDockWidgets::usesAeroSnapWithCustomDecos() || eventType != "windows_generic_MSG")
|
||||||
|
return QWidget::nativeEvent(eventType, message, result);
|
||||||
|
|
||||||
|
auto m = static_cast<MSG*>(message);
|
||||||
|
if (m->message != WM_DPICHANGED)
|
||||||
|
return QWidget::nativeEvent(eventType, message, result);
|
||||||
|
|
||||||
|
KDDockWidgets::extendClientAreaOverTitleBar(windowHandle());
|
||||||
|
return QWidget::nativeEvent(eventType, message, result);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void FloatingWindowWidget::init()
|
void FloatingWindowWidget::init()
|
||||||
{
|
{
|
||||||
m_vlayout->setSpacing(0);
|
m_vlayout->setSpacing(0);
|
||||||
@@ -69,4 +83,7 @@ void FloatingWindowWidget::init()
|
|||||||
|
|
||||||
if (!KDDockWidgets::usesNativeDraggingAndResizing())
|
if (!KDDockWidgets::usesNativeDraggingAndResizing())
|
||||||
m_vlayout->setContentsMargins(4, 4, 4, 4);
|
m_vlayout->setContentsMargins(4, 4, 4, 4);
|
||||||
|
|
||||||
|
if (KDDockWidgets::usesAeroSnapWithCustomDecos())
|
||||||
|
KDDockWidgets::extendClientAreaOverTitleBar(windowHandle());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
bool event(QEvent *ev) override;
|
bool event(QEvent *ev) override;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
Q_DISABLE_COPY(FloatingWindowWidget)
|
Q_DISABLE_COPY(FloatingWindowWidget)
|
||||||
|
|||||||
Reference in New Issue
Block a user