From 42afd8c33348946790550208e12aee80f75bb7ff Mon Sep 17 00:00:00 2001 From: Eric Czarny Date: Mon, 27 Oct 2014 13:14:57 -0400 Subject: [PATCH] Screen detection logging; include error codes when logging accessibility element errors. --- Spectacle/SpectacleScreenDetection.m | 22 +++++++++++++++++++++- Spectacle/ZKAccessibilityElement.m | 8 ++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Spectacle/SpectacleScreenDetection.m b/Spectacle/SpectacleScreenDetection.m index f3bb317..eb32b28 100644 --- a/Spectacle/SpectacleScreenDetection.m +++ b/Spectacle/SpectacleScreenDetection.m @@ -67,6 +67,22 @@ + (NSScreen *)nextOrPreviousScreenToFrameOfScreen: (CGRect)frameOfScreen inDirec return result; } + NSLog(@"Discovered %lu screen(s).", (unsigned long)screens.count); + + NSLog(@"Current screen: %@", RectToString(frameOfScreen)); + + for (NSInteger i = 0; i < screens.count; i++) { + NSScreen *currentScreen = screens[i]; + + NSLog(@" Screen %ld: %@", (long)i, RectToString(NSRectToCGRect(currentScreen.frame))); + } + + if (action == SpectacleWindowActionNextDisplay) { + NSLog(@"Selecting the screen of the NEXT display."); + } else if (action == SpectacleWindowActionPreviousDisplay) { + NSLog(@"Selecting the screen of the PREVIOUS display."); + } + for (NSInteger i = 0; i < screens.count; i++) { NSScreen *currentScreen = screens[i]; CGRect currentFrameOfScreen = NSRectToCGRect(currentScreen.frame); @@ -76,6 +92,8 @@ + (NSScreen *)nextOrPreviousScreenToFrameOfScreen: (CGRect)frameOfScreen inDirec continue; } + NSLog(@"Index of the current screen: %ld", (long)i); + if (action == SpectacleWindowActionNextDisplay) { nextOrPreviousIndex++; } else if (action == SpectacleWindowActionPreviousDisplay) { @@ -92,7 +110,9 @@ + (NSScreen *)nextOrPreviousScreenToFrameOfScreen: (CGRect)frameOfScreen inDirec break; } - + + NSLog(@"Selected screen: %@", RectToString(NSRectToCGRect(result.frame))); + return result; } diff --git a/Spectacle/ZKAccessibilityElement.m b/Spectacle/ZKAccessibilityElement.m index 9b3119f..2d0bc54 100644 --- a/Spectacle/ZKAccessibilityElement.m +++ b/Spectacle/ZKAccessibilityElement.m @@ -74,7 +74,7 @@ - (ZKAccessibilityElement *)elementWithAttribute: (CFStringRef)attribute { CFRelease(childElement); } else { - NSLog(@"Unable to obtain the accessibility element with the specified attribute: %@", attribute); + NSLog(@"Unable to obtain the accessibility element with the specified attribute: %@ (error code %d)", attribute, result); } return newElement; @@ -92,7 +92,7 @@ - (NSString *)stringValueOfAttribute: (CFStringRef)attribute { if (result == kAXErrorSuccess) { return CFBridgingRelease(value); } else { - NSLog(@"There was a problem getting the string value of the specified attribute: %@", attribute); + NSLog(@"There was a problem getting the string value of the specified attribute: %@ (error code %d)", attribute, result); } } @@ -109,7 +109,7 @@ - (AXValueRef)valueOfAttribute: (CFStringRef)attribute type: (AXValueType)type { if ((result == kAXErrorSuccess) && (AXValueGetType(value) == type)) { return value; } else { - NSLog(@"There was a problem getting the value of the specified attribute: %@", attribute); + NSLog(@"There was a problem getting the value of the specified attribute: %@ (error code %d)", attribute, result); } } @@ -122,7 +122,7 @@ - (void)setValue: (AXValueRef)value forAttribute: (CFStringRef)attribute { AXError result = AXUIElementSetAttributeValue(_element, attribute, (CFTypeRef *)value); if (result != kAXErrorSuccess) { - NSLog(@"There was a problem setting the value of the specified attribute: %@", attribute); + NSLog(@"There was a problem setting the value of the specified attribute: %@ (error code %d)", attribute, result); } }