From 033e48044cc9f0bffefab52237ae0ca8197b2b87 Mon Sep 17 00:00:00 2001 From: Tech-Tac Date: Thu, 16 Jul 2026 17:45:58 +0300 Subject: [PATCH] fix: maximize the window when the image size matches the screen size (#179) This is to avoid the window appearing maximized while not actually being maximized which leads to some frustration and confusion about window borders and breaking Fitts' law on the close button. This is common for example when viewing screenshots of the same screen size. --- app/mainwindow.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 860bb89..8e6b20c 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -229,15 +229,22 @@ void MainWindow::adjustWindowSizeBySceneRect() // we can show the picture by increase the window size. QSize finalSize = (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) ? sceneSizeWithMargins : screenSize; - // We have a very reasonable sizeHint() value ;P - this->resize(finalSize.expandedTo(this->sizeHint())); + + // to avoid the window appearing maximized while not being actually maximized + // which is common when viewing screenshots of the same screen size + if (finalSize == screenSize) { + showMaximized(); + } else { + // We have a very reasonable sizeHint() value ;P + this->resize(finalSize.expandedTo(this->sizeHint())); + centerWindow(); + } // We're sure the window can display the whole thing with 1:1 scale. // The old window size may cause fitInView call from resize() and the // above resize() call won't reset the scale back to 1:1, so we // just call resetScale() here to ensure the thing is no longer scaled. m_graphicsView->resetScale(); - centerWindow(); } else { // toggle maximum showMaximized();