Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/src/platform/mac/objc/window_blur.m
StratoSDK / crates / strato-ui-renderer / src / platform / mac / objc / window_blur.m
1#import "window_blur.h"
2 
3static NSString *const kApplicationServicesFramework =
4 @"/System/Library/Frameworks/ApplicationServices.framework";
5 
6// Returns a function pointer to the private function named `func` in the given
7// `library`. Returns NULL if the function does not exist.
8static void *GetFunctionByName(NSString *library, char *func) {
9 CFBundleRef bundle;
10 CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)library,
11 kCFURLPOSIXPathStyle, true);
12 CFStringRef functionName =
13 CFStringCreateWithCString(kCFAllocatorDefault, func, kCFStringEncodingASCII);
14 bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
15 void *f = NULL;
16 if (bundle) {
17 f = CFBundleGetFunctionPointerForName(bundle, functionName);
18 CFRelease(bundle);
19 }
20 CFRelease(functionName);
21 CFRelease(bundleURL);
22 return f;
23}
24 
25CGSSetWindowBackgroundBlurRadiusFunction *GetCGSSetWindowBackgroundBlurRadiusFunction(void) {
26 static BOOL tried = NO;
27 static CGSSetWindowBackgroundBlurRadiusFunction *function = NULL;
28 if (!tried) {
29 function =
30 GetFunctionByName(kApplicationServicesFramework, "CGSSetWindowBackgroundBlurRadius");
31 tried = YES;
32 }
33 return function;
34}
35