From e2d6582ddd7309a907a3ba1ce5977bcac09621b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 14 Aug 2026 20:49:38 +0200 Subject: [PATCH] Workaround macOS fit to canvas size Workaround another "magic" macOS bug that does not make sense. I don't like doing this, but what are the alternatives? --- src/app/GUI/mainwindow.cpp | 9 +++++++++ src/core/Private/document.h | 3 +++ src/ui/dialogs/scenesettingsdialog.cpp | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index 2b5c68ee8..42f2e5ef3 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -499,6 +499,15 @@ void MainWindow::setupDocument() if (mTimeline) { mTimeline->stopPreview(); } }); +#ifdef Q_OS_MAC + // https://github.com/friction2d/friction/pull/736 + connect(&mDocument, &Document::fitCanvasToSize, this, []() { + const auto target = KeyFocusTarget::KFT_getCurrentTarget(); + const auto cwTarget = dynamic_cast(target); + if (cwTarget) { cwTarget->fitCanvasToSize(); } + }); +#endif + // set defaults mDocument.setPath(""); mDocument.fDrawPathManual = false; diff --git a/src/core/Private/document.h b/src/core/Private/document.h index 4f1d8b126..992e0a032 100644 --- a/src/core/Private/document.h +++ b/src/core/Private/document.h @@ -258,6 +258,9 @@ class CORE_EXPORT Document : public SingleWidgetTarget { void openApplyExpressionDialog(QrealAnimator* const target); void newVideo(const VideoBox::VideoSpecs specs); void currentPixelColor(const QColor &color); + + // https://github.com/friction2d/friction/pull/736 + void fitCanvasToSize(); }; #endif // DOCUMENT_H diff --git a/src/ui/dialogs/scenesettingsdialog.cpp b/src/ui/dialogs/scenesettingsdialog.cpp index 7403fb555..b22343bff 100644 --- a/src/ui/dialogs/scenesettingsdialog.cpp +++ b/src/ui/dialogs/scenesettingsdialog.cpp @@ -369,6 +369,10 @@ void SceneSettingsDialog::sNewSceneDialog(Document& document, newCanvas->anim_setAbsFrame(newCanvas->getFrameRange().fMin); dialog->close(); docPtr->actionFinished(); +#ifdef Q_OS_MAC + // https://github.com/friction2d/friction/pull/736 + emit docPtr->fitCanvasToSize(); +#endif }); dialog->show();