chore: allow dragging window from titlebar when maximized (#178)
This better matches titlebar behavior of Windows and KDE, and probably a lot more other environments, it also allows for easier unmaximizing because the current titlebar has no dedicated maximize/restore button. Note: This is somewhat problematic on Windows, thus we only apply the change to other platforms for now.
This commit is contained in:
@@ -353,7 +353,12 @@ void MainWindow::leaveEvent(QEvent *event)
|
|||||||
|
|
||||||
void MainWindow::mousePressEvent(QMouseEvent *event)
|
void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton && !isMaximized()) {
|
bool optionalMaximized = false;
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
optionalMaximized = isMaximized();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (event->buttons() & Qt::LeftButton && !optionalMaximized && !isFullScreen()) {
|
||||||
m_clickedOnWindow = true;
|
m_clickedOnWindow = true;
|
||||||
m_oldMousePos = event->pos();
|
m_oldMousePos = event->pos();
|
||||||
// qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
|
// qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
|
||||||
@@ -366,7 +371,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow && !isMaximized() && !isFullScreen()) {
|
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow) {
|
||||||
if (!window()->windowHandle()->startSystemMove()) {
|
if (!window()->windowHandle()->startSystemMove()) {
|
||||||
move(event->globalPosition().toPoint() - m_oldMousePos);
|
move(event->globalPosition().toPoint() - m_oldMousePos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,8 +129,14 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool optionalMaximized = false;
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
optionalMaximized = isMaximized();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (event->buttons() & Qt::LeftButton && m_dragPending
|
if (event->buttons() & Qt::LeftButton && m_dragPending
|
||||||
&& !window()->isMaximized() && !window()->isFullScreen()) {
|
&& !window()->isFullScreen() && !optionalMaximized) {
|
||||||
|
|
||||||
if (QWindow *wh = window()->windowHandle()) {
|
if (QWindow *wh = window()->windowHandle()) {
|
||||||
if (!wh->startSystemMove())
|
if (!wh->startSystemMove())
|
||||||
window()->move(event->globalPosition().toPoint() - m_moveStartPos);
|
window()->move(event->globalPosition().toPoint() - m_moveStartPos);
|
||||||
|
|||||||
Reference in New Issue
Block a user