Skip to content

Commit

Permalink
feat: support DTK_TITLE_DRAG_WINDOW on mac
Browse files Browse the repository at this point in the history
Change-Id: I930b80e46997f069095b092944e8aaf9a2694305
  • Loading branch information
Iceyer committed Nov 27, 2017
1 parent 63ee224 commit 20782b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/dtitlebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dtitlebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dx11widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 20782b5

Please sign in to comment.