From 762e0f6064776b64bc8642a3352755727b2211f1 Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Wed, 13 May 2009 14:57:00 -0400 Subject: [PATCH] Second Revision (from Archive) --- WindowBlur.xcodeproj/project.pbxproj | 78 ++++++++++++------------- WindowBlurSIMBL.h | 7 ++- WindowBlurSIMBL.m | 87 +++++++++++++++++++++++++++- WindowBlurWindowHack.h | 14 ----- WindowBlurWindowHack.m | 84 --------------------------- 5 files changed, 128 insertions(+), 142 deletions(-) delete mode 100644 WindowBlurWindowHack.h delete mode 100644 WindowBlurWindowHack.m diff --git a/WindowBlur.xcodeproj/project.pbxproj b/WindowBlur.xcodeproj/project.pbxproj index 31930cc..eee1d88 100644 --- a/WindowBlur.xcodeproj/project.pbxproj +++ b/WindowBlur.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; FA22EE5F0FBA6A6D003C3105 /* WindowBlurSIMBL.m in Sources */ = {isa = PBXBuildFile; fileRef = FA22EE5E0FBA6A6D003C3105 /* WindowBlurSIMBL.m */; }; - FA22EE640FBA6C19003C3105 /* WindowBlurWindowHack.m in Sources */ = {isa = PBXBuildFile; fileRef = FA22EE630FBA6C19003C3105 /* WindowBlurWindowHack.m */; }; + FAD8547F0FBB47340089E0E2 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD8547E0FBB47340089E0E2 /* QuartzCore.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -24,24 +24,23 @@ D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; FA22EE5D0FBA6A6D003C3105 /* WindowBlurSIMBL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBlurSIMBL.h; sourceTree = ""; }; FA22EE5E0FBA6A6D003C3105 /* WindowBlurSIMBL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WindowBlurSIMBL.m; sourceTree = ""; }; - FA22EE620FBA6C19003C3105 /* WindowBlurWindowHack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBlurWindowHack.h; sourceTree = ""; }; - FA22EE630FBA6C19003C3105 /* WindowBlurWindowHack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WindowBlurWindowHack.m; sourceTree = ""; }; - FA22EE820FBA737C003C3105 /* CarbonHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CarbonHelpers.h; sourceTree = ""; }; - FA22EE830FBA737C003C3105 /* CGSAccessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSAccessibility.h; sourceTree = ""; }; - FA22EE840FBA737C003C3105 /* CGSCIFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSCIFilter.h; sourceTree = ""; }; - FA22EE850FBA737C003C3105 /* CGSConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSConnection.h; sourceTree = ""; }; - FA22EE860FBA737C003C3105 /* CGSCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSCursor.h; sourceTree = ""; }; - FA22EE870FBA737C003C3105 /* CGSDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSDebug.h; sourceTree = ""; }; - FA22EE880FBA737C003C3105 /* CGSDisplays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSDisplays.h; sourceTree = ""; }; - FA22EE890FBA737C003C3105 /* CGSHotKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSHotKeys.h; sourceTree = ""; }; - FA22EE8A0FBA737C003C3105 /* CGSInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSInternal.h; sourceTree = ""; }; - FA22EE8B0FBA737C003C3105 /* CGSMisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSMisc.h; sourceTree = ""; }; - FA22EE8C0FBA737C003C3105 /* CGSNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSNotifications.h; sourceTree = ""; }; - FA22EE8D0FBA737C003C3105 /* CGSRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSRegion.h; sourceTree = ""; }; - FA22EE8E0FBA737C003C3105 /* CGSSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSSession.h; sourceTree = ""; }; - FA22EE8F0FBA737C003C3105 /* CGSTransitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSTransitions.h; sourceTree = ""; }; - FA22EE900FBA737C003C3105 /* CGSWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSWindow.h; sourceTree = ""; }; - FA22EE910FBA737C003C3105 /* CGSWorkspace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSWorkspace.h; sourceTree = ""; }; + FAD854000FBB1F040089E0E2 /* CarbonHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CarbonHelpers.h; sourceTree = ""; }; + FAD854010FBB1F040089E0E2 /* CGSAccessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSAccessibility.h; sourceTree = ""; }; + FAD854020FBB1F040089E0E2 /* CGSCIFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSCIFilter.h; sourceTree = ""; }; + FAD854030FBB1F040089E0E2 /* CGSConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSConnection.h; sourceTree = ""; }; + FAD854040FBB1F040089E0E2 /* CGSCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSCursor.h; sourceTree = ""; }; + FAD854050FBB1F040089E0E2 /* CGSDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSDebug.h; sourceTree = ""; }; + FAD854060FBB1F040089E0E2 /* CGSDisplays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSDisplays.h; sourceTree = ""; }; + FAD854070FBB1F040089E0E2 /* CGSHotKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSHotKeys.h; sourceTree = ""; }; + FAD854080FBB1F040089E0E2 /* CGSInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSInternal.h; sourceTree = ""; }; + FAD854090FBB1F040089E0E2 /* CGSMisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSMisc.h; sourceTree = ""; }; + FAD8540A0FBB1F040089E0E2 /* CGSNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSNotifications.h; sourceTree = ""; }; + FAD8540B0FBB1F040089E0E2 /* CGSRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSRegion.h; sourceTree = ""; }; + FAD8540C0FBB1F040089E0E2 /* CGSSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSSession.h; sourceTree = ""; }; + FAD8540D0FBB1F040089E0E2 /* CGSTransitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSTransitions.h; sourceTree = ""; }; + FAD8540E0FBB1F040089E0E2 /* CGSWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSWindow.h; sourceTree = ""; }; + FAD8540F0FBB1F040089E0E2 /* CGSWorkspace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSWorkspace.h; sourceTree = ""; }; + FAD8547E0FBB47340089E0E2 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -50,6 +49,7 @@ buildActionMask = 2147483647; files = ( 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, + FAD8547F0FBB47340089E0E2 /* QuartzCore.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -91,8 +91,6 @@ children = ( FA22EE5D0FBA6A6D003C3105 /* WindowBlurSIMBL.h */, FA22EE5E0FBA6A6D003C3105 /* WindowBlurSIMBL.m */, - FA22EE620FBA6C19003C3105 /* WindowBlurWindowHack.h */, - FA22EE630FBA6C19003C3105 /* WindowBlurWindowHack.m */, ); name = Classes; sourceTree = ""; @@ -101,6 +99,7 @@ isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + FAD8547E0FBB47340089E0E2 /* QuartzCore.framework */, ); name = "Linked Frameworks"; sourceTree = ""; @@ -126,31 +125,31 @@ 32C88E010371C26100C91783 /* Other Sources */ = { isa = PBXGroup; children = ( - FA22EE810FBA737C003C3105 /* CGSInternal */, + FAD853FF0FBB1F040089E0E2 /* CGSInternal */, 32DBCF630370AF2F00C91783 /* WindowBlur_Prefix.pch */, ); name = "Other Sources"; sourceTree = ""; }; - FA22EE810FBA737C003C3105 /* CGSInternal */ = { + FAD853FF0FBB1F040089E0E2 /* CGSInternal */ = { isa = PBXGroup; children = ( - FA22EE820FBA737C003C3105 /* CarbonHelpers.h */, - FA22EE830FBA737C003C3105 /* CGSAccessibility.h */, - FA22EE840FBA737C003C3105 /* CGSCIFilter.h */, - FA22EE850FBA737C003C3105 /* CGSConnection.h */, - FA22EE860FBA737C003C3105 /* CGSCursor.h */, - FA22EE870FBA737C003C3105 /* CGSDebug.h */, - FA22EE880FBA737C003C3105 /* CGSDisplays.h */, - FA22EE890FBA737C003C3105 /* CGSHotKeys.h */, - FA22EE8A0FBA737C003C3105 /* CGSInternal.h */, - FA22EE8B0FBA737C003C3105 /* CGSMisc.h */, - FA22EE8C0FBA737C003C3105 /* CGSNotifications.h */, - FA22EE8D0FBA737C003C3105 /* CGSRegion.h */, - FA22EE8E0FBA737C003C3105 /* CGSSession.h */, - FA22EE8F0FBA737C003C3105 /* CGSTransitions.h */, - FA22EE900FBA737C003C3105 /* CGSWindow.h */, - FA22EE910FBA737C003C3105 /* CGSWorkspace.h */, + FAD854000FBB1F040089E0E2 /* CarbonHelpers.h */, + FAD854010FBB1F040089E0E2 /* CGSAccessibility.h */, + FAD854020FBB1F040089E0E2 /* CGSCIFilter.h */, + FAD854030FBB1F040089E0E2 /* CGSConnection.h */, + FAD854040FBB1F040089E0E2 /* CGSCursor.h */, + FAD854050FBB1F040089E0E2 /* CGSDebug.h */, + FAD854060FBB1F040089E0E2 /* CGSDisplays.h */, + FAD854070FBB1F040089E0E2 /* CGSHotKeys.h */, + FAD854080FBB1F040089E0E2 /* CGSInternal.h */, + FAD854090FBB1F040089E0E2 /* CGSMisc.h */, + FAD8540A0FBB1F040089E0E2 /* CGSNotifications.h */, + FAD8540B0FBB1F040089E0E2 /* CGSRegion.h */, + FAD8540C0FBB1F040089E0E2 /* CGSSession.h */, + FAD8540D0FBB1F040089E0E2 /* CGSTransitions.h */, + FAD8540E0FBB1F040089E0E2 /* CGSWindow.h */, + FAD8540F0FBB1F040089E0E2 /* CGSWorkspace.h */, ); path = CGSInternal; sourceTree = ""; @@ -210,7 +209,6 @@ buildActionMask = 2147483647; files = ( FA22EE5F0FBA6A6D003C3105 /* WindowBlurSIMBL.m in Sources */, - FA22EE640FBA6C19003C3105 /* WindowBlurWindowHack.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WindowBlurSIMBL.h b/WindowBlurSIMBL.h index 984b057..cc23150 100644 --- a/WindowBlurSIMBL.h +++ b/WindowBlurSIMBL.h @@ -7,11 +7,12 @@ // #import +#import void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel); -@interface WindowBlurSIMBL : NSObject { - -} +@interface WindowBlurWindowHack : NSWindow +@end +@interface WindowBlurSIMBL : NSObject {} @end \ No newline at end of file diff --git a/WindowBlurSIMBL.m b/WindowBlurSIMBL.m index 49b8bdc..c50f0e0 100644 --- a/WindowBlurSIMBL.m +++ b/WindowBlurSIMBL.m @@ -7,7 +7,7 @@ // #import "WindowBlurSIMBL.h" -#import "WindowBlurWindowHack.h" +#import "CGSInternal.h" #import void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel) @@ -34,6 +34,91 @@ void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel) } } +static NSMutableDictionary *instanceIDToIvars = nil; +static BOOL needToSwizzleDealloc = YES; + +@implementation WindowBlurWindowHack + +- (id)PRE__instanceID +{ + return [NSValue valueWithPointer:self]; +} + +- (NSMutableDictionary *)PRE__ivars +{ + NSMutableDictionary *ivars; + + if (needToSwizzleDealloc) + { + MethodSwizzle([NSWindow class], + @selector(dealloc), + @selector(PRE__deallocSwizzler)); + needToSwizzleDealloc = NO; + } + + if (instanceIDToIvars == nil) + { + instanceIDToIvars = [[NSMutableDictionary alloc] init]; + } + + ivars = [instanceIDToIvars objectForKey:[self PRE__instanceID]]; + if (ivars == nil) + { + ivars = [NSMutableDictionary dictionary]; + [instanceIDToIvars setObject:ivars forKey:[self PRE__instanceID]]; + } + + return ivars; +} + +- (void)PRE__deallocSwizzler +{ + [instanceIDToIvars removeObjectForKey:[self PRE__instanceID]]; + if ([instanceIDToIvars count] == 0) + { + [instanceIDToIvars release]; + instanceIDToIvars = nil; + } + + [self PRE__deallocSwizzler]; +} + +- (void)display { + #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (floor(NSAppKitVersionNumber) > 824) { + NSString *filterName; + if (!(filterName = [[NSUserDefaults standardUserDefaults] stringForKey:@"WindowBlurSIMBL-FilterName"])) { + filterName = @"CIGaussianBlur"; + } + NSDictionary *filterValues; + if (!(filterValues = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"WindowBlurSIMBL-FilterValues"])) { + filterValues = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:2.0] forKey:@"inputRadius"]; + } + NSMutableDictionary *optionsDict = [NSMutableDictionary dictionaryWithDictionary:filterValues]; + if (![optionsDict objectForKey:@"inputCenter"]) { + [optionsDict setObject:[CIVector vectorWithX:0.0 Y:0.0] forKey:@"inputCenter"]; + } + CGSConnectionID con = CGSMainConnectionID(); + if (con) { + NSNumber *filterNumber; + int filter; + if (filterNumber = [[self PRE__ivars] objectForKey:@"filter"]) { + filter = [filterNumber intValue]; + CGSRemoveWindowFilter(con, [self windowNumber], filter); + } + if (noErr == CGSNewCIFilterByName(con, (CFStringRef)filterName, &filter)) { + CGSSetCIFilterValuesFromDictionary(con, filter, (CFDictionaryRef)optionsDict); + CGSAddWindowFilter(con, [self windowNumber], filter, kCGWindowFilterUnderlay); + [[self PRE__ivars] setObject:[NSNumber numberWithInt:filter] forKey:@"filter"]; + } + } + } + #endif + [super display]; +} + +@end + @implementation WindowBlurSIMBL + (void)load { diff --git a/WindowBlurWindowHack.h b/WindowBlurWindowHack.h deleted file mode 100644 index a811b44..0000000 --- a/WindowBlurWindowHack.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// WindowBlurWindowHack.h -// WindowBlur -// -// Created by Joseph Spiros on 5/12/09. -// Copyright 2009 __MyCompanyName__. All rights reserved. -// - -#import - -@interface WindowBlurWindowHack : NSWindow - - -@end diff --git a/WindowBlurWindowHack.m b/WindowBlurWindowHack.m deleted file mode 100644 index 16696a1..0000000 --- a/WindowBlurWindowHack.m +++ /dev/null @@ -1,84 +0,0 @@ -// -// WindowBlurWindowHack.m -// WindowBlur -// -// Created by Joseph Spiros on 5/12/09. -// Copyright 2009 __MyCompanyName__. All rights reserved. -// - -#import "WindowBlurSIMBL.h" -#import "WindowBlurWindowHack.h" -#import "CGSInternal.h" - -static NSMutableDictionary *instanceIDToIvars = nil; -static BOOL needToSwizzleDealloc = YES; - -@implementation WindowBlurWindowHack - -- (id)PRE__instanceID -{ - return [NSValue valueWithPointer:self]; -} - -- (NSMutableDictionary *)PRE__ivars -{ - NSMutableDictionary *ivars; - - if (needToSwizzleDealloc) - { - MethodSwizzle([NSWindow class], - @selector(dealloc), - @selector(PRE__deallocSwizzler)); - needToSwizzleDealloc = NO; - } - - if (instanceIDToIvars == nil) - { - instanceIDToIvars = [[NSMutableDictionary alloc] init]; - } - - ivars = [instanceIDToIvars objectForKey:[self PRE__instanceID]]; - if (ivars == nil) - { - ivars = [NSMutableDictionary dictionary]; - [instanceIDToIvars setObject:ivars forKey:[self PRE__instanceID]]; - } - - return ivars; -} - -- (void)PRE__deallocSwizzler -{ - [instanceIDToIvars removeObjectForKey:[self PRE__instanceID]]; - if ([instanceIDToIvars count] == 0) - { - [instanceIDToIvars release]; - instanceIDToIvars = nil; - } - - [self PRE__deallocSwizzler]; -} - -- (void)update { - if ([[[self PRE__ivars] objectForKey:@"blurred"] boolValue] != YES) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if (floor(NSAppKitVersionNumber) > 824) { - NSLog(@"AppKit Check Confirmed"); - CGSConnectionID con = CGSMainConnectionID(); - if (con) { - NSLog(@"CGSConnection Confirmed"); - int blurFilter; - if (noErr == CGSNewCIFilterByName(con, (CFStringRef)@"CIGaussianBlur", &blurFilter)) { - NSLog(@"Should work!"); - NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:2.0] forKey:@"inputRadius"]; - CGSSetCIFilterValuesFromDictionary(con, blurFilter, (CFDictionaryRef)optionsDict); - CGSAddWindowFilter(con, [self windowNumber], blurFilter, kCGWindowFilterUnderlay); - [[self PRE__ivars] setObject:[NSNumber numberWithBool:YES] forKey:@"blurred"]; - } - } - } -#endif - } -} - -@end -- 2.20.1