Merge pull request #91 from cxa/master

Remove shadow on macOS 12
This commit is contained in:
Felix Kratz 2021-10-30 17:24:36 +02:00 committed by GitHub
commit 154ca1ba29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -342,7 +342,7 @@ void bar_set_blur_radius(struct bar* bar) {
void bar_create_window(struct bar* bar) {
uint64_t set_tags = kCGSStickyTagBit | kCGSDisableShadowTagBit | kCGSHighQualityResamplingTagBit;
if (__builtin_available(macOS 12.0, *)) set_tags = kCGSStickyTagBit;
if (__builtin_available(macOS 12.0, *)) set_tags = kCGSStickyTagBit | kCGSHighQualityResamplingTagBit;
CFTypeRef frame_region;
bar_create_frame(bar, &frame_region);
@ -356,6 +356,17 @@ void bar_create_window(struct bar* bar) {
SLSSetWindowOpacity(g_connection, bar->id, 0);
bar_set_blur_radius(bar);
if (__builtin_available(macOS 12.0, *)) { // workaround: disable shadow on macOS 12
CFIndex shadow_density = 0;
CFNumberRef shadow_density_cf = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &shadow_density);
const void *keys[1] = { CFSTR("com.apple.WindowShadowDensity") };
const void *values[1] = { shadow_density_cf };
CFDictionaryRef shadow_props_cf = CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CGSWindowSetShadowProperties(bar->id, shadow_props_cf);
CFRelease(shadow_density_cf);
CFRelease(shadow_props_cf);
}
SLSSetWindowLevel(g_connection, bar->id, g_bar_manager.window_level);
bar->context = SLWindowContextCreate(g_connection, bar->id, 0);
CGContextSetInterpolationQuality(bar->context, kCGInterpolationNone);

View file

@ -19,7 +19,7 @@ extern CGError SLSAddActivationRegion(uint32_t cid, uint32_t wid, CFTypeRef regi
extern CGError SLSAddTrackingRect(uint32_t cid, uint32_t wid, CGRect rect);
extern CGError SLSClearActivationRegion(uint32_t cid, uint32_t wid);
extern CGError SLSRemoveAllTrackingAreas(uint32_t cid, uint32_t wid);
extern CGError CGSWindowSetShadowProperties(int wid, CFDictionaryRef properties);
#define kCGSDisableShadowTagBit (1 << 3)
#define kCGSHighQualityResamplingTagBit (1 << 4)