Skip to content

Commit

Permalink
Add support for 10.12+
Browse files Browse the repository at this point in the history
  • Loading branch information
jslegendre committed Sep 22, 2020
1 parent 093d280 commit 6629490
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
26 changes: 16 additions & 10 deletions AfloatX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
093B76EA23D5743E000F52F7 /* AXWindowUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 093B76E923D5743E000F52F7 /* AXWindowUtils.m */; };
09613B03239E014100E8C657 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 09613B02239E014100E8C657 /* Icon.icns */; };
09A55408239AE583006CB957 /* WindowTransparencyController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A55407239AE583006CB957 /* WindowTransparencyController.m */; };
09AA55F32350FFBE00356916 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09AA55F22350FFBE00356916 /* AppKit.framework */; };
09AA55F52350FFBE00356916 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09AA55F42350FFBE00356916 /* Foundation.framework */; };
09AA55FC2350FFBE00356916 /* AfloatX.m in Sources */ = {isa = PBXBuildFile; fileRef = 09AA55FB2350FFBE00356916 /* AfloatX.m */; };
09AA56002350FFBE00356916 /* ZKSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 09AA55FF2350FFBE00356916 /* ZKSwizzle.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -40,8 +38,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
09AA55F32350FFBE00356916 /* AppKit.framework in Frameworks */,
09AA55F52350FFBE00356916 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -304,12 +300,15 @@
09AA56062350FFBE00356916 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.3.6;
CURRENT_PROJECT_VERSION = 1.4.0;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = 6LAE5ASX7M;
DEVELOPMENT_TEAM = G9T88PYL48;
DSTROOT = /;
ENABLE_STRICT_OBJC_MSGSEND = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -318,22 +317,27 @@
INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins";
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.3.6;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.jslegendre.AfloatX;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = macosx;
WRAPPER_EXTENSION = bundle;
};
name = Debug;
};
09AA56072350FFBE00356916 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.3.6;
CURRENT_PROJECT_VERSION = 1.4.0;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = 6LAE5ASX7M;
DEVELOPMENT_TEAM = G9T88PYL48;
DSTROOT = /;
ENABLE_STRICT_OBJC_MSGSEND = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -342,9 +346,11 @@
INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins";
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.3.6;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.jslegendre.AfloatX;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = macosx;
WRAPPER_EXTENSION = bundle;
};
name = Release;
Expand Down
18 changes: 11 additions & 7 deletions AfloatX/AfloatX.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//Copyright © 2019 Jeremy Legendre. All rights reserved.
//

@import AppKit;
@import Foundation;
#import "AfloatX.h"
#import "AXWindowUtils.h"
#import "WindowTransparencyController.h"
Expand Down Expand Up @@ -163,8 +163,8 @@ + (void)load {
if ([blackList containsObject:NSBundle.mainBundle.bundleIdentifier])
return;

NSUInteger osx_ver = [[NSProcessInfo processInfo] operatingSystemVersion].minorVersion;
NSLog(@"%@ loaded into %@ on macOS 10.%ld", [self class], [[NSBundle mainBundle] bundleIdentifier], (long)osx_ver);
// NSUInteger osx_ver = [[NSProcessInfo processInfo] operatingSystemVersion].minorVersion;
// NSLog(@"%@ loaded into %@ on macOS 10.%ld", [self class], [[NSBundle mainBundle] bundleIdentifier], (long)osx_ver);

AfloatX *plugin = [AfloatX sharedInstance];

Expand Down Expand Up @@ -213,8 +213,9 @@ + (void)load {
transparencyItem,
nil];

[AfloatXSubmenu setItemArray:afloatXItems];

for(NSMenuItem *item in afloatXItems)
[AfloatXSubmenu addItem:item];

[AfloatXMenu addItem:[NSMenuItem separatorItem]];
[AfloatXMenu addItem:AfloatXItem];
}
Expand Down Expand Up @@ -263,13 +264,16 @@ - (CFArrayRef)_createDockMenu:(BOOL)enabled {
}

/* Create a new WindowOutliningController per window */
[windowOutlineSubmenu removeAllItems];
if (!objc_getAssociatedObject(window, "outlineController")) {
WindowOutliningController *outlineController = [WindowOutliningController new];
windowOutlineSubmenu.itemArray = [outlineController colorItems];
for(NSMenuItem *item in [outlineController colorItems])
[windowOutlineSubmenu addItem:item];
objc_setAssociatedObject(window, "outlineController", outlineController, OBJC_ASSOCIATION_RETAIN);
} else {
WindowOutliningController *outlineController = objc_getAssociatedObject(window, "outlineController");
windowOutlineSubmenu.itemArray = [outlineController colorItems];
for(NSMenuItem *item in [outlineController colorItems])
[windowOutlineSubmenu addItem:item];
}

if ([objc_getAssociatedObject(window, "isColorInverted") boolValue]) {
Expand Down
5 changes: 1 addition & 4 deletions AfloatX/ZKSwizzle/ZKSwizzle.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@
+ (void)load { \
_$ZKRegisterInterface(self, #GROUP);\
if (IMMEDIATELY) { \
[self _ZK_unconditionallySwizzle]; \
ZKSwizzle(CLASS_NAME, TARGET_CLASS); \
} \
} \
+ (void)_ZK_unconditionallySwizzle { \
ZKSwizzle(CLASS_NAME, TARGET_CLASS); \
} \
@end

// Bootstraps your swizzling class so that it requires no setup
Expand Down
10 changes: 5 additions & 5 deletions AfloatX/ZKSwizzle/ZKSwizzle.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ BOOL _ZKSwizzle(Class src, Class dest) {
classTable = [[NSMutableDictionary alloc] init];
}

if ([classTable objectForKey:NSStringFromClass(src)]) {
[NSException raise:@"Invalid Argument"
format:@"This source class (%@) was already swizzled with another, (%@)", NSStringFromClass(src), classTable[NSStringFromClass(src)]];
return NO;
}
// if ([classTable objectForKey:NSStringFromClass(src)]) {
// [NSException raise:@"Invalid Argument"
// format:@"This source class (%@) was already swizzled with another, (%@)", NSStringFromClass(src), classTable[NSStringFromClass(src)]];
// return NO;
// }

BOOL success = enumerateMethods(dest, src);
// The above method only gets instance methods. Do the same method for the metaclass of the class
Expand Down

0 comments on commit 6629490

Please sign in to comment.