Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
Screen detection logging; include error codes when logging accessibil…
Browse files Browse the repository at this point in the history
…ity element errors.
  • Loading branch information
eczarny committed Oct 27, 2014
1 parent 2e05700 commit 42afd8c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
22 changes: 21 additions & 1 deletion Spectacle/SpectacleScreenDetection.m
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -92,7 +110,9 @@ + (NSScreen *)nextOrPreviousScreenToFrameOfScreen: (CGRect)frameOfScreen inDirec

break;
}


NSLog(@"Selected screen: %@", RectToString(NSRectToCGRect(result.frame)));

return result;
}

Expand Down
8 changes: 4 additions & 4 deletions Spectacle/ZKAccessibilityElement.m
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down

0 comments on commit 42afd8c

Please sign in to comment.