Skip to content

Commit

Permalink
chore(macos): remove code for dropped versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazer committed Dec 25, 2024
1 parent 00cfddc commit 9ee1221
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions src/platform/macos/permissions_manager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
#include "src/logging.h"

namespace platf {
// Even though the following two functions are available starting in macOS 10.15, they weren't
// actually in the Mac SDK until Xcode 12.2, the first to include the SDK for macOS 11
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 110000 // __MAC_11_0
// If they're not in the SDK then we can use our own function definitions.
// Need to use weak import so that this will link in macOS 10.14 and earlier
extern "C" bool
CGPreflightScreenCaptureAccess(void) __attribute__((weak_import));
extern "C" bool
CGRequestScreenCaptureAccess(void) __attribute__((weak_import));
#endif

namespace {
auto
screen_capture_allowed = std::atomic { false };
Expand All @@ -41,30 +30,12 @@

bool
PermissionsManager::request_screen_capture_permission() {
// This will generate a warning about CGPreflightScreenCaptureAccess and
// CGRequestScreenCaptureAccess being unavailable before macOS 10.15, but
// we have a guard to prevent it from being called on those earlier systems.
// Unfortunately the supported way to silence this warning, using @available,
// produces linker errors for __isPlatformVersionAtLeast, so we have to use
// a different method.
// We also ignore "tautological-pointer-compare" because when compiling with
// Xcode 12.2 and later, these functions are not weakly linked and will never
// be null, and therefore generate this warning. Since we are weakly linking
// when compiling with earlier Xcode versions, the check for null is
// necessary, and so we ignore the warning.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:((NSOperatingSystemVersion) { 10, 15, 0 })] &&
// Double check that these weakly-linked symbols have been loaded:
CGPreflightScreenCaptureAccess != nullptr && CGRequestScreenCaptureAccess != nullptr &&
!CGPreflightScreenCaptureAccess()) {
if (!CGPreflightScreenCaptureAccess()) {
BOOST_LOG(error) << "No screen capture permission!";
BOOST_LOG(error) << "Please activate it in 'System Preferences' -> 'Privacy' -> 'Screen Recording'";
CGRequestScreenCaptureAccess();
return true;
}
#pragma clang diagnostic pop
// Record that we determined that we have the screen capture permission.
screen_capture_allowed = true;
return false;
Expand Down

0 comments on commit 9ee1221

Please sign in to comment.