StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | #import "window_blur.h" |
| 2 | |
| 3 | static 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. |
| 8 | static 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 | |
| 25 | CGSSetWindowBackgroundBlurRadiusFunction *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 |