From dcc0afaaa0b4be48e692827891259e08993c0f20 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 10 Jun 2014 04:40:33 -0700 Subject: [PATCH] MGR: eliminate almost all overhead from my commit a8cc13f unless assistive software is in use --- clientgui/mac/MacAccessiblity.mm | 45 ++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/clientgui/mac/MacAccessiblity.mm b/clientgui/mac/MacAccessiblity.mm index 0b1cd797cb..93e2311cac 100644 --- a/clientgui/mac/MacAccessiblity.mm +++ b/clientgui/mac/MacAccessiblity.mm @@ -1047,6 +1047,8 @@ static void wxRectToNSRect(wxRect &wxr, NSRect &nsr) { // is somewhere in the caller chain. // I wish I could find a more efficient way to do this. // +static BOOL AccessibilityEnabled = false; + - (NSView *)hitTest:(NSPoint)aPoint { // [NSThread callStackSymbols] is not available in OS 10.5, so // BOINC does not fully implement accessibility under OS 10.5. @@ -1073,33 +1075,36 @@ static void wxRectToNSRect(wxRect &wxr, NSRect &nsr) { return [super hitTest:aPoint]; // Point is not within our rect } -// NSArray *theStack = [NSThread callStackSymbols]; - NSArray *theStack = [ NSThread performSelector:@selector(callStackSymbols) ]; - - int limit = [ theStack count ]; - int i = 0; - do { - if (limit < (i+1)) break; - NSString *sourceString = [theStack objectAtIndex:i]; - NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; - NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; - [array removeObject:@""]; + if (AccessibilityEnabled) { + // NSArray *theStack = [NSThread callStackSymbols]; + NSArray *theStack = [ NSThread performSelector:@selector(callStackSymbols) ]; + + int limit = [ theStack count ]; + int i = 0; + do { + if (limit < (i+1)) break; + NSString *sourceString = [theStack objectAtIndex:i]; + NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; + NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; + [array removeObject:@""]; + + if ([array count] >= 5) { + NSString *FunctionCaller = [array objectAtIndex:4]; + if ([ FunctionCaller hasPrefix: @"accessibility"]) { + return self; + } - if ([array count] >= 5) { - NSString *FunctionCaller = [array objectAtIndex:4]; - if ([ FunctionCaller hasPrefix: @"accessibility"]) { - return self; } - - } - ++i; - } while (i < 15); - + ++i; + } while (i < 15); + } + return [super hitTest:aPoint]; // Not an accessibility call } - (BOOL)accessibilityIsIgnored { + AccessibilityEnabled = true; return NO; }