From 20782b5502b0452bc17f15b4736043d53d42a878 Mon Sep 17 00:00:00 2001 From: Iceyer Date: Mon, 27 Nov 2017 13:04:06 +0800 Subject: [PATCH] feat: support DTK_TITLE_DRAG_WINDOW on mac Change-Id: I930b80e46997f069095b092944e8aaf9a2694305 --- src/src.pro | 17 ++++++++++------- src/widgets/dtitlebar.cpp | 4 ++-- src/widgets/dtitlebar.h | 2 +- src/widgets/dx11widget.cpp | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/src.pro b/src/src.pro index f833b62d8..4e4159fae 100644 --- a/src/src.pro +++ b/src/src.pro @@ -13,20 +13,23 @@ greaterThan(QT_MAJOR_VERSION, 4) { greaterThan(QT_MAJOR_VERSION, 5)|greaterThan(QT_MINOR_VERSION, 7): QT += gui-private else: QT += platformsupport-private } - -macx* { - CONFIG += link_pkgconfig - PKGCONFIG += dtkcore -} linux* { QT += x11extras dbus CONFIG += link_pkgconfig PKGCONFIG += x11 xext dtkcore -} else { +} + +mac* { QT += svg + DEFINES += DTK_TITLE_DRAG_WINDOW + CONFIG += link_pkgconfig + PKGCONFIG += dtkcore } -win32* { +win* { + QT += svg + DEFINES += DTK_TITLE_DRAG_WINDOW + #DEPENDS dtkcore INCLUDEPATH += $$INCLUDE_INSTALL_DIR\libdtk-$$VERSION\DCore LIBS += -L$$LIB_INSTALL_DIR -ldtkcore diff --git a/src/widgets/dtitlebar.cpp b/src/widgets/dtitlebar.cpp index 1597cc452..d6dcda532 100644 --- a/src/widgets/dtitlebar.cpp +++ b/src/widgets/dtitlebar.cpp @@ -518,7 +518,7 @@ void DTitlebar::mousePressEvent(QMouseEvent *event) return; } -#ifdef Q_OS_WIN +#ifdef DTK_TITLE_DRAG_WINDOW Q_EMIT mousePosPressed(event->buttons(), event->globalPos()); #endif Q_EMIT mousePressed(event->buttons()); @@ -828,7 +828,7 @@ void DTitlebar::mouseMoveEvent(QMouseEvent *event) Q_EMIT mouseMoving(button); } -#ifdef Q_OS_WIN +#ifdef DTK_TITLE_DRAG_WINDOW D_D(DTitlebar); if (d->mousePressed) { Q_EMIT mousePosMoving(button, event->globalPos()); diff --git a/src/widgets/dtitlebar.h b/src/widgets/dtitlebar.h index 6c5d5caec..a1531118b 100644 --- a/src/widgets/dtitlebar.h +++ b/src/widgets/dtitlebar.h @@ -60,7 +60,7 @@ class LIBDTKWIDGETSHARED_EXPORT DTitlebar : public QWidget, public DTK_CORE_NAME void mousePressed(Qt::MouseButtons buttons); void mouseMoving(Qt::MouseButton botton); -#ifdef Q_OS_WIN +#ifdef DTK_TITLE_DRAG_WINDOW void mousePosPressed(Qt::MouseButtons buttons, QPoint pos); void mousePosMoving(Qt::MouseButton botton, QPoint pos); #endif diff --git a/src/widgets/dx11widget.cpp b/src/widgets/dx11widget.cpp index 3ec8c3320..6682f4f1b 100644 --- a/src/widgets/dx11widget.cpp +++ b/src/widgets/dx11widget.cpp @@ -201,7 +201,7 @@ DX11Widget::DX11Widget(DX11WidgetPrivate &dd, QWidget *parent) #ifdef Q_OS_LINUX XUtils::SetMouseTransparent(this, true); #endif -#ifdef Q_OS_WIN +#ifdef DTK_TITLE_DRAG_WINDOW connect(d->titlebar, &DTitlebar::mousePosMoving, this, [ = ](Qt::MouseButton /*botton*/, QPoint pos) { move(pos - d->m_LastMousePos);