Skip to content

Commit ef678de

Browse files
authored
fix(macos): use proper macos api to get privacy screen recorder access (flameshot-org#4617)
1 parent d888a3f commit ef678de

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/core/flameshot.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include "qhotkey.h"
88
#endif
99

10+
#if defined(Q_OS_MACOS)
11+
#include <CoreGraphics/CoreGraphics.h>
12+
#endif
13+
1014
#include "config/configresolver.h"
1115
#include "config/configwindow.h"
1216
#include "core/qguiappcurrentscreen.h"
@@ -54,11 +58,10 @@ Flameshot::Flameshot()
5458
qApp->setStyleSheet(StyleSheet);
5559

5660
#if defined(Q_OS_MACOS)
57-
// Try to take a test screenshot, MacOS will request a "Screen Recording"
58-
// permissions on the first run. Otherwise it will be hidden under the
59-
// CaptureWidget
60-
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
61-
currentScreen->grabWindow(0, 0, 0, 1, 1);
61+
// Request Screen Recording permission via the proper CoreGraphics API
62+
if (!CGPreflightScreenCaptureAccess()) {
63+
CGRequestScreenCaptureAccess();
64+
}
6265
#endif
6366
#if (defined(Q_OS_MACOS) || defined(Q_OS_WIN))
6467
// Set global shortcuts for MacOS or Windows

0 commit comments

Comments
 (0)