From a10bbb4e8d1166cae5c02dc7c0dfefd4e46482e6 Mon Sep 17 00:00:00 2001 From: Tech-Tac Date: Fri, 17 Jul 2026 19:38:01 +0300 Subject: [PATCH] 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. --- app/mainwindow.cpp | 9 +++++++-- app/titlebar.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 8e6b20c..14a6c1e 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -353,7 +353,12 @@ void MainWindow::leaveEvent(QEvent *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_oldMousePos = event->pos(); // qDebug() << m_oldMousePos << m_graphicsView->transform().m11() @@ -366,7 +371,7 @@ void MainWindow::mousePressEvent(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()) { move(event->globalPosition().toPoint() - m_oldMousePos); } diff --git a/app/titlebar.cpp b/app/titlebar.cpp index 6ada30e..c5f538d 100644 --- a/app/titlebar.cpp +++ b/app/titlebar.cpp @@ -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 - && !window()->isMaximized() && !window()->isFullScreen()) { + && !window()->isFullScreen() && !optionalMaximized) { + if (QWindow *wh = window()->windowHandle()) { if (!wh->startSystemMove()) window()->move(event->globalPosition().toPoint() - m_moveStartPos);