Skip to content

Commit e497f47

Browse files
MitnitskyCopilot
andauthored
fix(macos): make fullscreen capture overlay configurable (flameshot-org#4622)
macOS showFullScreen() triggers a native fullscreen space transition animation when capturing. Replace with show() using FramelessWindowHint, WindowStaysOnTopHint, and Qt::Tool flags to avoid the animation. Add a 'useNativeFullscreen' config option (default: off) so users who prefer the native fullscreen behavior can re-enable it from Settings > General. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent caf1703 commit e497f47

6 files changed

Lines changed: 53 additions & 2 deletions

File tree

src/config/generalconf.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ GeneralConf::GeneralConf(QWidget* parent)
5757
#if !defined(Q_OS_MACOS)
5858
initCaptureActiveMonitor();
5959
#endif
60+
#if defined(Q_OS_MACOS)
61+
initUseNativeFullscreen();
62+
#endif
6063
#if defined(Q_OS_LINUX)
6164
initUseX11LegacyScreenshot();
6265
#endif
@@ -127,6 +130,9 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
127130
#if !defined(Q_OS_MACOS)
128131
m_captureActiveMonitor->setChecked(config.captureActiveMonitor());
129132
#endif
133+
#if defined(Q_OS_MACOS)
134+
m_useNativeFullscreen->setChecked(config.useNativeFullscreen());
135+
#endif
130136
#if defined(Q_OS_LINUX)
131137
m_useX11LegacyScreenshot->setChecked(config.useX11LegacyScreenshot());
132138
#endif
@@ -937,6 +943,29 @@ void GeneralConf::captureActiveMonitorChanged(bool checked)
937943
}
938944
#endif
939945

946+
#if defined(Q_OS_MACOS)
947+
void GeneralConf::initUseNativeFullscreen()
948+
{
949+
m_useNativeFullscreen =
950+
new QCheckBox(tr("Use native fullscreen for capture overlay"), this);
951+
m_useNativeFullscreen->setToolTip(
952+
tr("Use macOS native fullscreen mode for the capture overlay. "
953+
"When disabled (default), the overlay avoids the fullscreen "
954+
"desktop animation."));
955+
m_scrollAreaLayout->addWidget(m_useNativeFullscreen);
956+
957+
connect(m_useNativeFullscreen,
958+
&QCheckBox::clicked,
959+
this,
960+
&GeneralConf::useNativeFullscreenChanged);
961+
}
962+
963+
void GeneralConf::useNativeFullscreenChanged(bool checked)
964+
{
965+
ConfigHandler().setUseNativeFullscreen(checked);
966+
}
967+
#endif
968+
940969
#if defined(Q_OS_LINUX)
941970
void GeneralConf::initUseX11LegacyScreenshot()
942971
{

src/config/generalconf.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ private slots:
6464
#if !defined(Q_OS_MACOS)
6565
void captureActiveMonitorChanged(bool checked);
6666
#endif
67+
#if defined(Q_OS_MACOS)
68+
void useNativeFullscreenChanged(bool checked);
69+
#endif
6770
#if defined(Q_OS_LINUX)
6871
void useX11LegacyScreenshotChanged(bool checked);
6972
#endif
@@ -108,6 +111,9 @@ private slots:
108111
#if !defined(Q_OS_MACOS)
109112
void initCaptureActiveMonitor();
110113
#endif
114+
#if defined(Q_OS_MACOS)
115+
void initUseNativeFullscreen();
116+
#endif
111117
#if defined(Q_OS_LINUX)
112118
void initUseX11LegacyScreenshot();
113119
#endif
@@ -162,6 +168,9 @@ private slots:
162168
#if !defined(Q_OS_MACOS)
163169
QCheckBox* m_captureActiveMonitor;
164170
#endif
171+
#if defined(Q_OS_MACOS)
172+
QCheckBox* m_useNativeFullscreen;
173+
#endif
165174
#if defined(Q_OS_LINUX)
166175
QCheckBox* m_useX11LegacyScreenshot;
167176
#endif

src/core/flameshot.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req)
162162
#ifdef Q_OS_WIN
163163
m_captureWindow->show();
164164
#elif defined(Q_OS_MACOS)
165-
// In "Emulate fullscreen mode"
166-
m_captureWindow->showFullScreen();
165+
if (ConfigHandler().useNativeFullscreen()) {
166+
m_captureWindow->showFullScreen();
167+
} else {
168+
m_captureWindow->show();
169+
}
167170
m_captureWindow->activateWindow();
168171
m_captureWindow->raise();
169172
#else

src/utils/confighandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
9494
OPTION("copyPathAfterSave" ,Bool ( false )),
9595
OPTION("antialiasingPinZoom" ,Bool ( true )),
9696
OPTION("useJpgForClipboard" ,Bool ( false )),
97+
#if defined(Q_OS_MACOS)
98+
OPTION("useNativeFullscreen" ,Bool ( false )),
99+
#endif
97100
OPTION("uploadWithoutConfirmation" ,Bool ( false )),
98101
OPTION("saveAfterCopy" ,Bool ( false )),
99102
OPTION("savePath" ,ExistingDir ( )),

src/utils/confighandler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ class ConfigHandler : public QObject
120120
CONFIG_GETTER_SETTER(saveAsFileExtension, setSaveAsFileExtension, QString)
121121
CONFIG_GETTER_SETTER(antialiasingPinZoom, setAntialiasingPinZoom, bool)
122122
CONFIG_GETTER_SETTER(useJpgForClipboard, setUseJpgForClipboard, bool)
123+
#if defined(Q_OS_MACOS)
124+
CONFIG_GETTER_SETTER(useNativeFullscreen, setUseNativeFullscreen, bool)
125+
#endif
123126
CONFIG_GETTER_SETTER(uploadWithoutConfirmation,
124127
setUploadWithoutConfirmation,
125128
bool)

src/widgets/capture/capturewidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
164164
windowHandle()->setScreen(selectedScreen);
165165
}
166166
#elif defined(Q_OS_MACOS)
167+
if (!ConfigHandler().useNativeFullscreen()) {
168+
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint |
169+
Qt::Tool);
170+
}
167171
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
168172
move(currentScreen->geometry().x(), currentScreen->geometry().y());
169173
resize(currentScreen->size());

0 commit comments

Comments
 (0)