1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-06 04:00:08 +00:00

Platform: Remove compatibility checks for macOS 10.10

This commit is contained in:
reuk 2024-07-01 17:21:31 +01:00
parent 6d4bf60330
commit 8ac7bfc9ca
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
8 changed files with 45 additions and 133 deletions

View file

@ -44,7 +44,6 @@ namespace juce
bool isIOSAppActive = true;
#endif
API_AVAILABLE (macos (10.10))
static auto getNativeQOS (Thread::Priority priority)
{
switch (priority)
@ -59,7 +58,6 @@ static auto getNativeQOS (Thread::Priority priority)
return QOS_CLASS_DEFAULT;
}
API_AVAILABLE (macos (10.10))
static auto getJucePriority (qos_class_t qos)
{
switch (qos)
@ -132,10 +130,7 @@ bool Thread::createNativeThread (Priority priority)
{
PosixThreadAttribute attribute { threadStackSize };
if (@available (macos 10.10, *))
pthread_attr_set_qos_class_np (attribute.get(), getNativeQOS (priority), 0);
else
PosixSchedulerPriority::getNativeSchedulerAndPriority (realtimeOptions, priority).apply (attribute);
pthread_attr_set_qos_class_np (attribute.get(), getNativeQOS (priority), 0);
struct ThreadData
{
@ -182,21 +177,7 @@ Thread::Priority Thread::getPriority() const
jassert (Thread::getCurrentThreadId() == getThreadId());
if (! isRealtime())
{
if (@available (macOS 10.10, *))
return getJucePriority (qos_class_self());
// fallback for older versions of macOS
const auto min = jmax (0, sched_get_priority_min (SCHED_OTHER));
const auto max = jmax (0, sched_get_priority_max (SCHED_OTHER));
if (min != 0 && max != 0)
{
const auto native = PosixSchedulerPriority::findCurrentSchedulerAndPriority().getPriority();
const auto mapped = jmap (native, min, max, 0, 4);
return ThreadPriorities::getJucePriority (mapped);
}
}
return getJucePriority (qos_class_self());
return {};
}
@ -205,20 +186,7 @@ bool Thread::setPriority (Priority priority)
{
jassert (Thread::getCurrentThreadId() == getThreadId());
if (@available (macOS 10.10, *))
return pthread_set_qos_class_self_np (getNativeQOS (priority), 0) == 0;
#if JUCE_ARM
// M1 platforms should never reach this code!!!!!!
jassertfalse;
#endif
// Just in case older versions of macOS support SCHED_OTHER priorities.
const auto psp = PosixSchedulerPriority::getNativeSchedulerAndPriority ({}, priority);
struct sched_param param;
param.sched_priority = psp.getPriority();
return pthread_setschedparam (pthread_self(), psp.getScheduler(), &param) == 0;
return pthread_set_qos_class_self_np (getNativeQOS (priority), 0) == 0;
}
//==============================================================================

View file

@ -32,7 +32,6 @@
==============================================================================
*/
API_AVAILABLE (macos (10.10))
static void juceFreeAccessibilityPlatformSpecificData (NSAccessibilityElement<NSAccessibility>*) {}
namespace juce
@ -45,12 +44,10 @@ class AccessibilityHandler::AccessibilityNativeImpl
{
public:
explicit AccessibilityNativeImpl (AccessibilityHandler& handler)
: accessibilityElement (AccessibilityElement::create (handler))
{
if (@available (macOS 10.10, *))
accessibilityElement = AccessibilityElement::create (handler);
}
API_AVAILABLE (macos (10.10))
NSAccessibilityElement<NSAccessibility>* getAccessibilityElement() const noexcept
{
return accessibilityElement.get();
@ -58,20 +55,15 @@ public:
private:
//==============================================================================
class API_AVAILABLE (macos (10.10)) AccessibilityElement final : public AccessibleObjCClass<NSAccessibilityElement<NSAccessibility>>
class AccessibilityElement final : public AccessibleObjCClass<NSAccessibilityElement<NSAccessibility>>
{
public:
static Holder create (AccessibilityHandler& handler)
{
if (@available (macOS 10.10, *))
{
static AccessibilityElement cls;
Holder element ([cls.createInstance() init]);
object_setInstanceVariable (element.get(), "handler", &handler);
return element;
}
return {};
static AccessibilityElement cls;
Holder element ([cls.createInstance() init]);
object_setInstanceVariable (element.get(), "handler", &handler);
return element;
}
private:
@ -825,7 +817,6 @@ private:
};
//==============================================================================
API_AVAILABLE (macos (10.10))
AccessibilityElement::Holder accessibilityElement;
//==============================================================================
@ -835,10 +826,7 @@ private:
//==============================================================================
AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation() const
{
if (@available (macOS 10.10, *))
return (AccessibilityNativeHandle*) nativeImpl->getAccessibilityElement();
return nullptr;
return (AccessibilityNativeHandle*) nativeImpl->getAccessibilityElement();
}
static bool areAnyAccessibilityClientsActive()

View file

@ -250,8 +250,7 @@ public:
[window setColorSpace: [NSColorSpace sRGBColorSpace]];
setOwner (window, this);
if (@available (macOS 10.10, *))
[window setAccessibilityElement: YES];
[window setAccessibilityElement: YES];
[window orderOut: nil];
[window setDelegate: (id<NSWindowDelegate>) window];
@ -954,16 +953,7 @@ public:
if (r.size.width < 1.0f || r.size.height < 1.0f)
return;
auto cg = []
{
if (@available (macOS 10.10, *))
return (CGContextRef) [[NSGraphicsContext currentContext] CGContext];
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
}();
auto* cg = (CGContextRef) [[NSGraphicsContext currentContext] CGContext];
drawRectWithContext (cg, r);
}
@ -2863,10 +2853,7 @@ struct JuceNSWindowClass final : public NSViewComponentPeerWrapper<ObjCClass<NSW
addMethod (@selector (accessibilitySubrole), [] (id self, SEL) -> NSAccessibilitySubrole
{
if (@available (macOS 10.10, *))
return [getAccessibleChild (self) accessibilitySubrole];
return nil;
return [getAccessibleChild (self) accessibilitySubrole];
});
addMethod (@selector (window:shouldDragDocumentWithEvent:from:withPasteboard:), [] (id self, SEL, id /*window*/, NSEvent*, NSPoint, NSPasteboard*)

View file

@ -488,17 +488,8 @@ static void selectImageForDrawing (const Image& image)
{
[NSGraphicsContext saveGraphicsState];
if (@available (macOS 10.10, *))
{
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithCGContext: juce_getImageContext (image)
flipped: false]];
return;
}
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: juce_getImageContext (image)
flipped: false]];
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithCGContext: juce_getImageContext (image)
flipped: false]];
}
static void releaseImageAfterDrawing()

View file

@ -117,18 +117,15 @@ namespace PushNotificationsDelegateDetailsOsx
notification.contentImage = [[NSImage alloc] initWithContentsOfFile: imagePath];
if (@available (macOS 10.10, *))
if (n.actions.size() > 1)
{
if (n.actions.size() > 1)
{
auto additionalActions = [NSMutableArray arrayWithCapacity: (NSUInteger) n.actions.size() - 1];
auto additionalActions = [NSMutableArray arrayWithCapacity: (NSUInteger) n.actions.size() - 1];
for (int a = 1; a < n.actions.size(); ++a)
[additionalActions addObject: [NSUserNotificationAction actionWithIdentifier: juceStringToNS (n.actions[a].identifier)
title: juceStringToNS (n.actions[a].title)]];
for (int a = 1; a < n.actions.size(); ++a)
[additionalActions addObject: [NSUserNotificationAction actionWithIdentifier: juceStringToNS (n.actions[a].identifier)
title: juceStringToNS (n.actions[a].title)]];
notification.additionalActions = additionalActions;
}
notification.additionalActions = additionalActions;
}
[notification autorelease];
@ -183,18 +180,15 @@ namespace PushNotificationsDelegateDetailsOsx
actions.add (action);
}
if (@available (macOS 10.10, *))
if (n.additionalActions != nil)
{
if (n.additionalActions != nil)
for (NSUserNotificationAction* a in n.additionalActions)
{
for (NSUserNotificationAction* a in n.additionalActions)
{
Action action;
action.identifier = nsStringToJuce (a.identifier);
action.title = nsStringToJuce (a.title);
Action action;
action.identifier = nsStringToJuce (a.identifier);
action.title = nsStringToJuce (a.title);
actions.add (action);
}
actions.add (action);
}
}
@ -503,9 +497,8 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
{
const auto actionIdentifier = nsStringToJuce ([&]
{
if (@available (macOS 10.10, *))
if (notification.additionalActivationAction != nil)
return notification.additionalActivationAction.identifier;
if (notification.additionalActivationAction != nil)
return notification.additionalActivationAction.identifier;
return notification.actionButtonTitle;
}());

View file

@ -96,7 +96,7 @@ struct StatusItemContainer : public Timer
};
//==============================================================================
struct API_AVAILABLE (macos (10.10)) ButtonBasedStatusItem final : public StatusItemContainer
struct ButtonBasedStatusItem final : public StatusItemContainer
{
//==============================================================================
ButtonBasedStatusItem (SystemTrayIconComponent& iconComp, const Image& im)
@ -388,11 +388,8 @@ class SystemTrayIconComponent::Pimpl
public:
//==============================================================================
Pimpl (SystemTrayIconComponent& iconComp, const Image& im)
: statusItemHolder (std::make_unique<ButtonBasedStatusItem> (iconComp, im))
{
if (@available (macOS 10.10, *))
statusItemHolder = std::make_unique<ButtonBasedStatusItem> (iconComp, im);
else
statusItemHolder = std::make_unique<ViewBasedStatusItem> (iconComp, im);
}
//==============================================================================

View file

@ -37,35 +37,24 @@ namespace juce
static NSURL* appendParametersToFileURL (const URL& url, NSURL* fileUrl)
{
if (@available (macOS 10.10, *))
{
const auto parameterNames = url.getParameterNames();
const auto parameterValues = url.getParameterValues();
const auto parameterNames = url.getParameterNames();
const auto parameterValues = url.getParameterValues();
jassert (parameterNames.size() == parameterValues.size());
jassert (parameterNames.size() == parameterValues.size());
if (parameterNames.isEmpty())
return fileUrl;
if (parameterNames.isEmpty())
return fileUrl;
NSUniquePtr<NSURLComponents> components ([[NSURLComponents alloc] initWithURL: fileUrl resolvingAgainstBaseURL: NO]);
NSUniquePtr<NSMutableArray> queryItems ([[NSMutableArray alloc] init]);
NSUniquePtr<NSURLComponents> components ([[NSURLComponents alloc] initWithURL: fileUrl resolvingAgainstBaseURL: NO]);
NSUniquePtr<NSMutableArray> queryItems ([[NSMutableArray alloc] init]);
for (int i = 0; i < parameterNames.size(); ++i)
[queryItems.get() addObject: [NSURLQueryItem queryItemWithName: juceStringToNS (parameterNames[i])
value: juceStringToNS (parameterValues[i])]];
for (int i = 0; i < parameterNames.size(); ++i)
[queryItems.get() addObject: [NSURLQueryItem queryItemWithName: juceStringToNS (parameterNames[i])
value: juceStringToNS (parameterValues[i])]];
[components.get() setQueryItems: queryItems.get()];
[components.get() setQueryItems: queryItems.get()];
return [components.get() URL];
}
const auto queryString = url.getQueryString();
if (queryString.isNotEmpty())
if (NSString* fileUrlString = [fileUrl absoluteString])
return [NSURL URLWithString: [fileUrlString stringByAppendingString: juceStringToNS (queryString)]];
return fileUrl;
return [components.get() URL];
}
static NSMutableURLRequest* getRequestForURL (const String& url, const StringArray* headers, const MemoryBlock* postData)
@ -426,7 +415,7 @@ private:
WebBrowserComponent::Options options;
};
struct API_AVAILABLE (macos (10.10)) WebViewDelegateClass final : public ObjCClass<NSObject>
struct WebViewDelegateClass final : public ObjCClass<NSObject>
{
WebViewDelegateClass() : ObjCClass ("JUCEWebViewDelegate_")
{

View file

@ -95,8 +95,7 @@ public:
return NSOpenGLProfileVersion3_2Core;
if (version != defaultGLVersion)
if (@available (macOS 10.10, *))
return NSOpenGLProfileVersion4_1Core;
return NSOpenGLProfileVersion4_1Core;
return NSOpenGLProfileVersionLegacy;
}(),