Restore canonical macOS window geometry

Ignore the transient 640x480 Qt fallback geometry on macOS and restore the application default instead, while preserving deliberate user-sized windows.

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-08-24 18:38:07 +08:00
parent 71e4812bdf
commit 52901041ed
2 changed files with 39 additions and 4 deletions
+11 -1
View File
@@ -65,6 +65,8 @@ class MainWindow(AppQMainWindow):
QtCore.QSize(1800, 960) if PLATFORM != 'Darwin' else DEFAULT_WINDOW_SIZE_DARWIN
)
QT_FALLBACK_WINDOW_SIZE = QtCore.QSize(640, 480)
def __init__(self, *args, **kwargs):
"""Create and register the built-in application pages."""
super().__init__(*args, **kwargs)
@@ -251,7 +253,15 @@ class MainWindow(AppQMainWindow):
restored = False
if restored:
if (
restored
and PLATFORM == 'Darwin'
and self.size() == self.QT_FALLBACK_WINDOW_SIZE
):
self._applyDefaultWindowSize(
'saved macOS main-window geometry restored to the Qt fallback size'
)
elif restored:
logger.info(
f'restored main-window geometry: {self.geometry().getRect()}'
)
+28 -3
View File
@@ -82,6 +82,7 @@ class _GeometryWindow(AppQMainWindow):
DEFAULT_WINDOW_SIZE = QtCore.QSize(700, 500)
QT_FALLBACK_WINDOW_SIZE = MainWindow.QT_FALLBACK_WINDOW_SIZE
_applyDefaultWindowSize = MainWindow._applyDefaultWindowSize
_restoreLegacyWindowSize = MainWindow._restoreLegacyWindowSize
_restoreMainWindowState = MainWindow._restoreMainWindowState
@@ -359,8 +360,8 @@ class MainWindowGeometryTest(unittest.TestCase):
window.close()
window.deleteLater()
def testValidIntentional640By480GeometryIsPreserved(self):
"""Never reinterpret a successful small user geometry as Qt fallback."""
def testDarwinRestoredQtFallbackSizeUsesCanonicalDefault(self):
"""Replace macOS Qt fallback dimensions with the product default."""
with isolatedSettings():
expected = QtCore.QRect(40, 50, 640, 480)
AppSettings.set(
@@ -370,7 +371,31 @@ class MainWindowGeometryTest(unittest.TestCase):
window = _GeometryWindow()
with patch('Furious.Qt.QtWidgets.moveToCenter') as moveToCenter:
with patch('Furious.Window.MainWindow.PLATFORM', 'Darwin'), patch(
'Furious.Qt.QtWidgets.moveToCenter'
) as moveToCenter:
window.show()
self.assertEqual(window.size(), window.DEFAULT_WINDOW_SIZE)
moveToCenter.assert_not_called()
window.close()
window.deleteLater()
def testNonDarwinRestored640By480GeometryIsPreserved(self):
"""Preserve a successful 640 by 480 restoration outside macOS."""
with isolatedSettings():
expected = QtCore.QRect(40, 50, 640, 480)
AppSettings.set(
'AppMainWindowGeometry',
self._saveGeometry(expected),
)
window = _GeometryWindow()
with patch('Furious.Window.MainWindow.PLATFORM', 'Windows'), patch(
'Furious.Qt.QtWidgets.moveToCenter'
) as moveToCenter:
window.show()
self.assertEqual(window.size(), expected.size())