chore: clean up mouse drag to resize/move logic a little bit
1. No longer fallback to use move(), since all known platforms
support startSystemMove(), and it's unlikely going to work
if it's not supported on a specific platform.
2. Fix titlebar move check missing `window()->`.
This amends a10bbb4e8d
This commit is contained in:
@@ -115,7 +115,6 @@ void TitleBar::mousePressEvent(QMouseEvent *event)
|
||||
}
|
||||
|
||||
m_dragPending = true;
|
||||
m_moveStartPos = event->pos();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -129,17 +128,18 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
bool optionalMaximized = false;
|
||||
#if defined(Q_OS_WIN)
|
||||
optionalMaximized = isMaximized();
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
const bool shouldAcceptDrag = !window()->isMaximized() && !window()->isFullScreen();
|
||||
#else
|
||||
const bool shouldAcceptDrag = !window()->isFullScreen();
|
||||
#endif
|
||||
|
||||
if (event->buttons() & Qt::LeftButton && m_dragPending && shouldAcceptDrag) {
|
||||
|
||||
if (event->buttons() & Qt::LeftButton && m_dragPending
|
||||
&& !window()->isFullScreen() && !optionalMaximized) {
|
||||
|
||||
if (QWindow *wh = window()->windowHandle()) {
|
||||
if (!wh->startSystemMove())
|
||||
window()->move(event->globalPosition().toPoint() - m_moveStartPos);
|
||||
if (wh->startSystemMove()) {
|
||||
m_dragPending = false;
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user