From 1eaff569c907ea94ab4701ba87f25c419f3a03f4 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 3 Jan 2025 11:15:31 -0500 Subject: [PATCH] Fix mac deprecation using __MAC_OS_X_VERSION_MIN_REQUIRED (available don't work as expected) --- Linphone/tool/native/DesktopToolsMacOsNative.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Linphone/tool/native/DesktopToolsMacOsNative.mm b/Linphone/tool/native/DesktopToolsMacOsNative.mm index e43a15fc5..6ace95b52 100644 --- a/Linphone/tool/native/DesktopToolsMacOsNative.mm +++ b/Linphone/tool/native/DesktopToolsMacOsNative.mm @@ -6,6 +6,7 @@ #include #include #include +#include void DesktopTools::init(){ } @@ -170,6 +171,7 @@ QImage DesktopTools::getWindowIcon(void *window) { } QImage DesktopTools::takeScreenshot(void *window) { +#if __MAC_OS_X_VERSION_MIN_REQUIRED > 140000 __block bool haveAccess = false; // Must be call from main thread! If not, you may be in deadlock. dispatch_sync(dispatch_get_main_queue(), ^{ @@ -246,9 +248,14 @@ QImage DesktopTools::takeScreenshot(void *window) { [capture release]; return image; // Deprecated: - //CGWindowID windowId = *(CGWindowID*)&window; - //CGImageRef capture = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowId, kCGWindowImageBoundsIgnoreFraming); - //return CGImageToQImage(capture); +#else +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + CGWindowID windowId = *(CGWindowID*)&window; + CGImageRef capture = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowId, kCGWindowImageBoundsIgnoreFraming); +#pragma clang diagnostic pop + return CGImageToQImage(capture); +#endif }