From 2a3c368cf1dc00378d0f00e7f9da6fced5456c26 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Tue, 1 Dec 2020 17:01:35 +0200 Subject: [PATCH] MacOS - Take test screenshot on start, MacOS will request a 'Screen Recording' permissions on the first run --- src/core/controller.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index b9405685..446f958e 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -38,6 +38,11 @@ #include "src/core/globalshortcutfilter.h" #endif +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) +#include +#endif + // Controller is the core component of Flameshot, creates the trayIcon and // launches the capture widget @@ -68,6 +73,15 @@ Controller::Controller() QString StyleSheet = CaptureButton::globalStyleSheet(); qApp->setStyleSheet(StyleSheet); + +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) + // Try to take a test screenshot, MacOS will request a "Screen Recording" + // permissions on the first run. Otherwise it will be hidden under the + // CaptureWidget + QScreen* currentScreen = QGuiApplication::screenAt(QCursor::pos()); + currentScreen->grabWindow(QApplication::desktop()->winId(), 0, 0, 1, 1); +#endif } Controller::~Controller()