From a4b45aee7bc49ea4629588720a47f5dee21f3aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Tue, 15 Oct 2013 14:58:42 +0900 Subject: [PATCH 1/9] Added Focus follows mouse option --- Afloat.h | 2 + Afloat.m | 28 +- AfloatStorage.h | 3 + AfloatStorage.m | 33 +- en.lproj/Afloat.nib/designable.nib | 557 ++++----------------------- en.lproj/Afloat.nib/keyedobjects.nib | Bin 4778 -> 4152 bytes 6 files changed, 142 insertions(+), 481 deletions(-) diff --git a/Afloat.h b/Afloat.h index 8ae455f..724175f 100644 --- a/Afloat.h +++ b/Afloat.h @@ -30,6 +30,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - (IBAction) makeMoreTransparent:(id) sender; - (IBAction) makeLessTransparent:(id) sender; +- (IBAction) toggleFocusFollowsMouse:(id)sender; + - (IBAction) showAdjustEffectsPanel:(id) sender; - (CGFloat) currentAlphaValueForWindow:(NSWindow*) w; diff --git a/Afloat.m b/Afloat.m index 36f7c9d..8f88f9d 100644 --- a/Afloat.m +++ b/Afloat.m @@ -141,6 +141,11 @@ - (void) install { // Scripting support. [self installScriptingSupport]; + + // Set up tracking rectangles + for(NSWindow *window in [NSApp windows]) { + [self beginTrackingWindow:window]; + } } - (NSUInteger) indexForInstallingInMenu:(NSMenu*) m { @@ -180,6 +185,8 @@ - (BOOL) validateMenuItem:(NSMenuItem*) item { return c != nil; } else if ([item action] == @selector(showWindowFileInFinder:)) return [[self currentWindow] representedURL]? [[[self currentWindow] representedURL] isFileURL] : NO; + else if ([item action] == @selector(toggleFocusFollowsMouse:)) + [item setState:[[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue] ? NSOnState : NSOffState]; return YES; } @@ -309,11 +316,6 @@ - (void) setAlphaValue:(CGFloat) f forWindow:(NSWindow*) window animated:(BOOL) [AfloatStorage setSharedValue:[NSNumber numberWithFloat:f] window:window key:kAfloatLastAlphaValueKey]; - if (f == 1.0) - [self endTrackingWindow:window]; - else - [self beginTrackingWindow:window]; - if (animate) { [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:0.3]; @@ -366,10 +368,18 @@ - (void) mouseEntered:(NSEvent*) e { L0Log(@"%@", e); [self animateFadeInForWindow:[e window]]; + + BOOL focusFollowsMouse = [[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]; + BOOL commandDown = [NSEvent modifierFlags] & NSCommandKeyMask ? YES : NO; + if(((focusFollowsMouse && !commandDown) || (!focusFollowsMouse && commandDown)) && ![[e window] isKeyWindow]) { + [[e window] makeKeyAndOrderFront:nil]; + [NSApp activateIgnoringOtherApps:YES]; + } } - (void) windowDidBecomeMain:(NSNotification*) n { [self animateFadeInForWindow:[n object]]; + [self beginTrackingWindow:[n object]]; } - (void) animateFadeInForWindow:(NSWindow*) w { @@ -390,6 +400,7 @@ - (void) mouseExited:(NSEvent*) e { - (void) windowDidResignMain:(NSNotification*) n { [self animateFadeOutForWindow:[n object]]; + [self beginTrackingWindow:[n object]]; } - (void) animateFadeOutForWindow:(NSWindow*) w { @@ -406,6 +417,13 @@ - (void) animateFadeOutForWindow:(NSWindow*) w { } +- (IBAction) toggleFocusFollowsMouse:(id)sender { + BOOL enable = ![[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]; + + [AfloatStorage setGlobalValue:@(enable) + forKey:@"FocusFollowsMouse"]; +} + - (IBAction) showAdjustEffectsPanel:(id) sender { NSWindow* w = [self currentWindow]; if (!w) { NSBeep(); return; } diff --git a/AfloatStorage.h b/AfloatStorage.h index 8731542..4a9dfee 100644 --- a/AfloatStorage.h +++ b/AfloatStorage.h @@ -23,6 +23,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + (id) sharedValueForWindow:(NSWindow*) w key:(NSString*) k; + (void) setSharedValue:(id) v window:(NSWindow*) w key:(NSString*) k; ++ (id) globalValueForKey:(NSString *) k; ++ (void) setGlobalValue:(id) v forKey:(NSString *) k; + - (id) valueForWindow:(NSWindow*) w key:(NSString*) k; - (void) setValue:(id) v forWindow:(NSWindow*) w key:(NSString*) k; diff --git a/AfloatStorage.m b/AfloatStorage.m index de16a18..c1c08e1 100644 --- a/AfloatStorage.m +++ b/AfloatStorage.m @@ -101,9 +101,6 @@ - (BOOL) canSaveWindow:(NSWindow*) w category:(NSString**) cat key:(NSString**) if (key) *key = [w frameAutosaveName]; return YES; } - - - return NO; } @@ -155,6 +152,36 @@ + (void) setSharedValue:(id) v window:(NSWindow*) w key:(NSString*) k { [[self sharedStorage] setValue:v forWindow:w key:k]; } ++ (void)_withGlobalStorage:(BOOL (^)(NSMutableDictionary *storage)) block +{ + NSString *bundleIdentifier = [[NSBundle bundleForClass:self] bundleIdentifier]; + NSString *storagePath = [[NSString stringWithFormat:@"~/Library/Preferences/%@.plist", bundleIdentifier] stringByExpandingTildeInPath]; + NSDistributedLock *lock = [NSDistributedLock lockWithPath:[storagePath stringByAppendingPathExtension:@"lock"]]; + + NSMutableDictionary *storage = [NSMutableDictionary dictionaryWithContentsOfFile:storagePath] + ?: [NSMutableDictionary new]; + if(block(storage)) + [storage writeToFile:storagePath atomically:YES]; + + [lock unlock]; +} + ++ (id) globalValueForKey:(NSString *) k { + __block id value; + [self _withGlobalStorage:^(NSMutableDictionary *storage) { + value = [storage objectForKey:k]; + return NO; + }]; + return value; +} + ++ (void) setGlobalValue:(id) v forKey:(NSString *) k { + [self _withGlobalStorage:^(NSMutableDictionary *storage) { + [storage setObject:v forKey:k]; + return YES; + }]; +} + @synthesize delegate = _delegate; @end diff --git a/en.lproj/Afloat.nib/designable.nib b/en.lproj/Afloat.nib/designable.nib index 30efd19..9c4d6b4 100644 --- a/en.lproj/Afloat.nib/designable.nib +++ b/en.lproj/Afloat.nib/designable.nib @@ -1,473 +1,84 @@ - - - - 1050 - 9C31 - 644 - 949.26 - 352.00 - - YES - - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - - - YES - - Afloat - - - FirstResponder - - - NSApplication - - - - - YES - - - Keep Afloat - a - 1310985 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - - - - Transparency - - 1048576 - 2147483647 - - - submenuAction: - - Transparency - - YES - - - Translucent - 1 - 1310985 - 2147483647 - - - - - - Opaque - 0 - 1310985 - 2147483647 - - - - - - Make Less Transparent - 75ysA - 1310720 - 2147483647 - - - - - - Make More Transparent - 75ytA - 1310720 - 2147483647 - - - - - - - - - Turn Overlays Back to Normal - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Adjust Effects - f - 1310985 - 2147483647 - - - - - - YES - YES - - - 2147483647 - - - - - - U2hvdyBXaW5kb3cncyBGaWxlIGluIEZpbmRlcg - 75yAA - 1310720 - 2147483647 - - - - - - - - - YES - - - _menuWithItems - - - - 12 - - - - toggleAlwaysOnTop: - - - - 13 - - - - makeTranslucent: - - - - 14 - - - - makeOpaque: - - - - 15 - - - - makeLessTransparent: - - - - 16 - - - - makeMoreTransparent: - - - - 17 - - - - showAdjustEffectsPanel: - - - - 18 - - - - disableAllOverlays: - - - - 20 - - - - showWindowFileInFinder: - - - - 23 - - - - - YES - - 0 - - YES - - - - - - -2 - - - RmlsZSdzIE93bmVyA - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - YES - - - - - - - - - - - - 2 - - - - - 4 - - - - - 5 - - - YES - - - - - - 6 - - - YES - - - - - - - - - 7 - - - - - 8 - - - - - 9 - - - - - 10 - - - - - 11 - - - - - 19 - - - - - 21 - - - - - 22 - - - - - - - YES - - YES - -1.IBPluginDependency - -2.IBPluginDependency - -3.IBPluginDependency - 1.IBEditorWindowLastContentRect - 1.IBPluginDependency - 1.editorWindowContentRectSynchronizationRect - 10.IBPluginDependency - 11.IBPluginDependency - 19.IBPluginDependency - 2.IBPluginDependency - 21.IBPluginDependency - 22.IBPluginDependency - 4.IBPluginDependency - 5.IBPluginDependency - 6.IBEditorWindowLastContentRect - 6.IBPluginDependency - 6.editorWindowContentRectSynchronizationRect - 7.IBPluginDependency - 8.IBPluginDependency - 9.IBPluginDependency - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{338, 394}, {294, 123}} - com.apple.InterfaceBuilder.CocoaPlugin - {{170, 454}, {185, 73}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{632, 414}, {253, 83}} - com.apple.InterfaceBuilder.CocoaPlugin - {{355, 424}, {253, 83}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - YES - - YES - - - YES - - - - - YES - - YES - - - YES - - - - 23 - - - - YES - - Afloat - NSObject - - YES - - YES - disableAllOverlays: - makeLessTransparent: - makeMoreTransparent: - makeOpaque: - makeTranslucent: - showAdjustEffectsPanel: - showWindowFileInFinder: - toggleAlwaysOnTop: - - - YES - id - id - id - id - id - id - id - id - - - - _menuWithItems - NSMenu - - - IBProjectSource - Afloat.h - - - - NSObject - - IBProjectSource - AfloatStorage.h - - - - NSObject - - IBProjectSource - JRSwizzle.h - - - - - 0 - ../Afloat.xcodeproj - 3 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/en.lproj/Afloat.nib/keyedobjects.nib b/en.lproj/Afloat.nib/keyedobjects.nib index b6c18756b1749d8e9eefc810b5ce58ce5ced784a..1955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N%LlR(AIDCA1)0S8 zix&;I;-k0?AH&D-3EYlP;tqTYcjD8y3!lMf@i}}RU%(gfC43oo;~sp4TC|o%XdSib zBD$E?(WU}% zC+sQgnGzKCjC3x078=fu;FqyO^GtTsU4#*g;ucovF7{aVKAz$NTn?AVjo`*})49c5 znp@4SKQj&SdBN4aC%-?`)53GQFqzqzk?ftPrN z&*F3V{`_EmI6sju<`?ib-^3?*hrg1)j=z<^gWtg4%WvVg^4s{w`R)7;ekZ?+f0loq zKfoX3KjOdOzv92)zvWK}{e*!+flwq=2{l54kQ7qF5@ETpLbz7AURWip7H${r6*dX? z2@eQQ3A=>7!n?xXg!hFHgpulvm3eR2DGw-Hm2Jv?<*0H@`MYvl zIiY-}e4&b}tg5Q68fuo>MeVANQ;XCJwNeeKv()+O0<}iHT&-2>)Mk~cH>x+Ox2boi zcd6^tyVd*D&FT~CGwL37pZblaXx+6QTCUbp>#gyDn*Tl7|a zxxPZbTE9lWPG70tpx>&u>3`P$qCcuXraz%SsXwJZtv{nbr@x@Tr0>>W(f8{6^ppA* z0W&ZpFeXqJXbr3kJQ#Q=@M7R(;A?g;8nDG^&k-#;r!1ahq|6ahI{q zxZC)RagVXl_^olj@jK)9#%ALo<6+|wV~erX*k(L#Y&UioJB^o&-Nq>bgd+lxh(a_H zAcUACn{*@RkQ~yJ^d@~tkeo~M$oXUtxqu8NL&-2Qf?PsIlF?)=8Am3NiDVL)PRd9H zsU#sXi_9VONHtkV!o(sGVv{&&BF$tOxst3PtH^3{BWWXdg7?R9{x^Q&e|LP6`~L@K CZg}wk From 413dc15a1789285f7808c87d4a72ce7f77eb938e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Tue, 15 Oct 2013 15:02:19 +0900 Subject: [PATCH 2/9] Cleanup --- Afloat.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Afloat.m b/Afloat.m index 8f88f9d..2db4c19 100644 --- a/Afloat.m +++ b/Afloat.m @@ -418,9 +418,7 @@ - (void) animateFadeOutForWindow:(NSWindow*) w { } - (IBAction) toggleFocusFollowsMouse:(id)sender { - BOOL enable = ![[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]; - - [AfloatStorage setGlobalValue:@(enable) + [AfloatStorage setGlobalValue:@([[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]) forKey:@"FocusFollowsMouse"]; } From 30d96a8edb6fa89ed1010573350946b81c22473f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Tue, 15 Oct 2013 15:11:04 +0900 Subject: [PATCH 3/9] Fixed typo --- Afloat.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Afloat.m b/Afloat.m index 2db4c19..e9aafc4 100644 --- a/Afloat.m +++ b/Afloat.m @@ -418,7 +418,7 @@ - (void) animateFadeOutForWindow:(NSWindow*) w { } - (IBAction) toggleFocusFollowsMouse:(id)sender { - [AfloatStorage setGlobalValue:@([[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]) + [AfloatStorage setGlobalValue:@(![[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]) forKey:@"FocusFollowsMouse"]; } From 1f2ed5e6bcb6ef58fcd8a6fe1b8655f33cc3c875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Wed, 16 Oct 2013 17:29:04 +0900 Subject: [PATCH 4/9] Actually acquires a lock on the global storage now. --- AfloatStorage.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AfloatStorage.m b/AfloatStorage.m index c1c08e1..66c21d8 100644 --- a/AfloatStorage.m +++ b/AfloatStorage.m @@ -158,6 +158,10 @@ + (void)_withGlobalStorage:(BOOL (^)(NSMutableDictionary *storage)) block NSString *storagePath = [[NSString stringWithFormat:@"~/Library/Preferences/%@.plist", bundleIdentifier] stringByExpandingTildeInPath]; NSDistributedLock *lock = [NSDistributedLock lockWithPath:[storagePath stringByAppendingPathExtension:@"lock"]]; + while(![lock tryLock]) { + usleep(100); + } + NSMutableDictionary *storage = [NSMutableDictionary dictionaryWithContentsOfFile:storagePath] ?: [NSMutableDictionary new]; if(block(storage)) From 6f9b3e9dbec4c658f4cf3e130574dbd5d2795a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Tue, 22 Oct 2013 21:06:53 +0900 Subject: [PATCH 5/9] Fixed crasher --- AfloatStorage.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/AfloatStorage.m b/AfloatStorage.m index 66c21d8..add7076 100644 --- a/AfloatStorage.m +++ b/AfloatStorage.m @@ -49,7 +49,10 @@ - (id) valueForWindow:(NSWindow*) w key:(NSString*) k { - (void) setValue:(id) v forWindow:(NSWindow*) w key:(NSString*) k { NSMutableDictionary* d = [self mutableDictionaryForWindow:w]; - [d setObject:v forKey:k]; + if(v) + [d setObject:v forKey:k]; + else + [d removeObjectForKey:k]; [self saveWindowIfRequired:w]; } @@ -181,7 +184,10 @@ + (id) globalValueForKey:(NSString *) k { + (void) setGlobalValue:(id) v forKey:(NSString *) k { [self _withGlobalStorage:^(NSMutableDictionary *storage) { - [storage setObject:v forKey:k]; + if(v) + [storage setObject:v forKey:k]; + else + [storage removeObjectForKey:k]; return YES; }]; } From d667180c23d6421c56fd953a1fc259a3d16ab04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Wed, 23 Oct 2013 01:12:24 +0900 Subject: [PATCH 6/9] Changed focus follows mouse shortcut to not conflict with fullscreen --- en.lproj/Afloat.nib/designable.nib | 4 ++-- en.lproj/Afloat.nib/keyedobjects.nib | Bin 4152 -> 4159 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/en.lproj/Afloat.nib/designable.nib b/en.lproj/Afloat.nib/designable.nib index 9c4d6b4..757f407 100644 --- a/en.lproj/Afloat.nib/designable.nib +++ b/en.lproj/Afloat.nib/designable.nib @@ -56,8 +56,8 @@ - - + + diff --git a/en.lproj/Afloat.nib/keyedobjects.nib b/en.lproj/Afloat.nib/keyedobjects.nib index 1955fd731fc22b67d2527ef58d70845c73b4a301..cec20b8d3117c8b736c4c1edce5c408040973da3 100644 GIT binary patch delta 1001 zcmY+;YfRQ<6aesZ_zUNG&N=vU5!@>_1VbReG-XCw4N|PVaZy|=yb!`0(M1zUV~l{x z(k_PniLtUGx>$3LHCnUPBD;NXHUmUbWQ1i#ty(!^L_~jKedzgce&>14WzVq%T??9G zo#XiF0sj+$UN{YX@GT6(k1zs%z&QK`6Yw_zhGG~p`Y-}xFc#x*J|o@LbNRW+etXB7C^Y4RQ|Vxo`7)-@10_g47;JgD5P* zfZNM!Ie4XQp7)Pc?$z=@*kjXIw^gnS!9(r|c_{Y-xT&onWoGCj474>A^gt3U!Y=$| zOMcO9IR#tq3zk){F0C$YM{j#cgfG7+5UdH7XIGWoTe&M()s3Iw=ba6D6zeSsg_DmW zDVkC#jW*C$+DK_crrX6f+pf18>>c(_TWs&KyKRlFwRN`Mw%Eh=9eczcwH@|L+i%a>0Xt}i>?nt^ zVP@sooWfbWl5gajIh!|eke}qe{4_ty`?-k^ax=GZE5FEx_!VyBc7B83;`$DLmpl15 zpWsvc4Uh8#Px6$YI1(x(Rz$+ZCy^2@F)~;Dk|=k{M%gSSQYvKZMU0mp$^7?2~8YIeA`M<&<h< z?J} nS7?^z=qcaF137HWiznDq>i~7R9mrneI delta 1016 zcmY+;dra146bJBg_`!Rg=bRJo8$%~Z#!W7UjiEU;b46+i3J6)vlshJjfxW#Wv=%R> zl{qi$w=QNDQM2YU*ZjwIk?gWI*SsJQq9$`ztTjhQjEJzG&_A6&&ga>4zGpj~iN_Q7 zO?SS;lWlR^S9igA=!PpW0KdQ>{0^h=7mUH*a1$dj3N1#XA7gPE#^X#(#3W3^bj-rJ zn1l0hAuhsvEWkosgH;&DgKdNNIG^Gd$C9xp%DqWGIs<3n$*^@TC1q^vhjs7-tcMur zfela!z3?!UK{+ggR;YptPz@Koe$g$a75J08pVH%c{+Fuq65f0=bAhs)KVif*X1OyC z|F}ga&U3;&XJ%3n#9{<{b_A@m{x% zb8(e>gcJNl9ncAxU2qq~U@_*oef$tt--^Y1$K47hxXY!;v`&8EHur$!xMyVZisP`f zJ)AMM_ZjB3hYP!4Hl*PR>?|!PS(#f{S?3+UtRhs=fhQodEZ{FF$*%nrREYMsLuY^cKBM?bJb^ zP%rgSKV72BbcF`!DqS;ChKx00ZZm#!yU8~5Os>f{m8RA-o1JEt*=_ckHgm`vHQ$-j z=CZkNhRh8!++s#-z$V!gJKLt)OuNLcwuN?$EwO8Dg$>$}ZL-aFt8KF#_I-QEerONd zleWut+g{se`|S`TI~>KtmQ#2>FW`l|n3wQlT+Xfh0`K6Lcqi}T-Mp9E*yUIGb>7bh z_#nT-@A6@8`G`N}&-q(E#pijLM|hOSc$_B$Btjy^Cq`IQq9q_P5-WGeBl4&`F6(5y zluEf&O0{g1O;RWI(jc29C?RQ*X4xvw$@3DHZL(cnl$YfdapjbJFQ?_KbV;}LN}u%0 zCHb*M2IQ(-lb>Z!ewE+kx(vw;8I}02)v)e?$%=@W62Afe)a$>l`~C&j C`31cI From f9e159f60ec01a43bcbd59d1446e94618dc2355f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Wed, 23 Oct 2013 01:13:02 +0900 Subject: [PATCH 7/9] Removed the ability to momentarily toggle focus follows mouse (it was just annoying) --- Afloat.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Afloat.m b/Afloat.m index e9aafc4..eb5e297 100644 --- a/Afloat.m +++ b/Afloat.m @@ -370,8 +370,8 @@ - (void) mouseEntered:(NSEvent*) e { [self animateFadeInForWindow:[e window]]; BOOL focusFollowsMouse = [[AfloatStorage globalValueForKey:@"FocusFollowsMouse"] boolValue]; - BOOL commandDown = [NSEvent modifierFlags] & NSCommandKeyMask ? YES : NO; - if(((focusFollowsMouse && !commandDown) || (!focusFollowsMouse && commandDown)) && ![[e window] isKeyWindow]) { + BOOL modsDown = ([NSEvent modifierFlags] & NSCommandKeyMask) ? YES : NO; + if(focusFollowsMouse && !modsDown && ![[e window] isKeyWindow]) { [[e window] makeKeyAndOrderFront:nil]; [NSApp activateIgnoringOtherApps:YES]; } From 4a280a4e3befee736cf5e0d94c28c9e2cd7e320a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Fri, 9 May 2014 13:53:41 +0900 Subject: [PATCH 8/9] Removed support for garbage collected apps (In order to build with latest clang) --- .gitignore | 5 ++++- Afloat.xcodeproj/project.pbxproj | 9 ++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index ce713f8..b422b1b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ Build build TemporaryItems -.DS_Store \ No newline at end of file +.DS_Store +Afloat.xcodeproj/project.xcworkspace/xcuserdata +Afloat.xcodeproj/xcuserdata +AfloatScripting/AfloatScripting.xcodeproj/xcuserdata diff --git a/Afloat.xcodeproj/project.pbxproj b/Afloat.xcodeproj/project.pbxproj index a0f940a..fb06d3b 100644 --- a/Afloat.xcodeproj/project.pbxproj +++ b/Afloat.xcodeproj/project.pbxproj @@ -333,7 +333,7 @@ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0510; }; buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Afloat" */; compatibilityVersion = "Xcode 3.2"; @@ -509,12 +509,10 @@ ); GCC_C_LANGUAGE_STANDARD = c99; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_GC = supported; - GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Afloat_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; + GCC_PREPROCESSOR_DEFINITIONS = ""; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Bundles"; LIBRARY_SEARCH_PATHS = ( @@ -525,7 +523,6 @@ PRODUCT_NAME = Afloat; SDKROOT = macosx; WRAPPER_EXTENSION = bundle; - ZERO_LINK = YES; }; name = Debug; }; @@ -540,8 +537,6 @@ "\"$(SRCROOT)\"", ); GCC_C_LANGUAGE_STANDARD = c99; - GCC_ENABLE_OBJC_GC = supported; - GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Afloat_Prefix.pch; INFOPLIST_FILE = Info.plist; From 767320b321aa6c4fb303f9d31808fc9368dfbb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fjo=CC=88lnir=20A=CC=81sgeirsson?= Date: Fri, 9 May 2014 14:34:57 +0900 Subject: [PATCH 9/9] Silenced a bunch of warnings --- AfloatBadgeController.h | 2 +- AfloatPanelController.h | 2 +- AfloatStorage.m | 2 +- AfloatWindowIdentifier.m | 2 +- Afloat_Prefix.pch | 5 +---- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/AfloatBadgeController.h b/AfloatBadgeController.h index f084185..ad3b378 100644 --- a/AfloatBadgeController.h +++ b/AfloatBadgeController.h @@ -22,7 +22,7 @@ typedef NSUInteger AfloatBadgeType; unsigned int enqueuedFades; } -@property(retain) NSWindow* parentWindow; +@property(retain, nonatomic) NSWindow* parentWindow; - (id) initAttachedToWindow:(NSWindow*) parentWindow; + (id) badgeControllerForWindow:(NSWindow*) w; diff --git a/AfloatPanelController.h b/AfloatPanelController.h index de943ee..065ae74 100644 --- a/AfloatPanelController.h +++ b/AfloatPanelController.h @@ -27,7 +27,7 @@ typedef enum { - (IBAction) disableAllOverlays:(id) sender; -@property(retain) NSWindow* parentWindow; +@property(retain, nonatomic) NSWindow* parentWindow; @property CGFloat alphaValue; // @property(getter=isKeptAfloat) BOOL keptAfloat; @property AfloatWindowState windowState; diff --git a/AfloatStorage.m b/AfloatStorage.m index add7076..4043cfa 100644 --- a/AfloatStorage.m +++ b/AfloatStorage.m @@ -159,7 +159,7 @@ + (void)_withGlobalStorage:(BOOL (^)(NSMutableDictionary *storage)) block { NSString *bundleIdentifier = [[NSBundle bundleForClass:self] bundleIdentifier]; NSString *storagePath = [[NSString stringWithFormat:@"~/Library/Preferences/%@.plist", bundleIdentifier] stringByExpandingTildeInPath]; - NSDistributedLock *lock = [NSDistributedLock lockWithPath:[storagePath stringByAppendingPathExtension:@"lock"]]; + NSDistributedLock *lock = [NSDistributedLock lockWithPath:[storagePath stringByAppendingPathExtension:@"lockfile"]]; while(![lock tryLock]) { usleep(100); diff --git a/AfloatWindowIdentifier.m b/AfloatWindowIdentifier.m index 4086e27..4b29e8c 100644 --- a/AfloatWindowIdentifier.m +++ b/AfloatWindowIdentifier.m @@ -154,7 +154,7 @@ - (void) dealloc { @synthesize category = _category, key = _key, canMatchMultipleWindows = _canMatchMultipleWindows; + (NSArray*) allIdentifiersForWindow:(NSWindow*) w { - NSMutableArray* results = [NSArray array]; + NSMutableArray* results = [NSMutableArray array]; for (Class c in [self identifierSubclasses]) { if ([c canInitWithWindow:w]) diff --git a/Afloat_Prefix.pch b/Afloat_Prefix.pch index 85b134d..50e8e32 100644 --- a/Afloat_Prefix.pch +++ b/Afloat_Prefix.pch @@ -21,10 +21,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #define L0LogS(x) NSLog(@": " x, __func__) #else - - // this removes any "unused variables" warnings for variables - // that are only used to log debug values. - #define L0Log(x, args...) do { {args;} } while(0) + #define L0Log(x, args...) do {} while(0) #define L0LogS(x) do {} while(0) #endif // DEBUG