diff --git a/MacPass/Base.lproj/AutotypeCandidateSelectionView.xib b/MacPass/Base.lproj/AutotypeCandidateSelectionView.xib index f623d7b9..665d1aec 100644 --- a/MacPass/Base.lproj/AutotypeCandidateSelectionView.xib +++ b/MacPass/Base.lproj/AutotypeCandidateSelectionView.xib @@ -17,17 +17,17 @@ - - + + - + - + - + @@ -103,7 +103,7 @@ - + diff --git a/MacPass/MPAutotypeCandidateSelectionViewController.m b/MacPass/MPAutotypeCandidateSelectionViewController.m index a680306c..a15ff41c 100644 --- a/MacPass/MPAutotypeCandidateSelectionViewController.m +++ b/MacPass/MPAutotypeCandidateSelectionViewController.m @@ -107,25 +107,38 @@ } - (NSImage *)_composeInfoImage { - static const uint32_t imageWidth = 512; - static const uint32_t iconSize = 128; + static const uint32_t iconSize = 64; + uint32_t imageWidth = 256; + uint32_t imageHeight = 256; NSRunningApplication *targetApplication = [NSRunningApplication runningApplicationWithProcessIdentifier:self.environment.pid]; CGImageRef windowGrab = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, self.environment.windowId, kCGWindowImageDefault | kCGWindowImageBestResolution); NSImage *windowImage = [[NSImage alloc] initWithCGImage:windowGrab size:NSZeroSize]; CFRelease(windowGrab); - CGFloat imageHeight = imageWidth * (windowImage.size.height / windowImage.size.width); + if(windowImage.size.width > windowImage.size.height) { + imageHeight = imageWidth * (windowImage.size.height / windowImage.size.width); + } + else { + imageWidth = imageWidth * (windowImage.size.width / windowImage.size.height); + } + if(!targetApplication.icon) { return windowImage; } - /* FIXME: respect tall windows correctly, we currently scale them up needlesly */ - - NSImage *composite = [[NSImage alloc] initWithSize:NSMakeSize(imageWidth, MAX(imageHeight, iconSize))]; + NSImage *composite = [[NSImage alloc] initWithSize:NSMakeSize(MAX(imageWidth, iconSize), MAX(imageHeight, iconSize))]; [composite lockFocus]; - [windowImage drawInRect:NSMakeRect(0, 0, imageWidth, imageHeight) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1]; - [targetApplication.icon drawInRect:NSMakeRect(0, 0, iconSize, iconSize) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1]; + /* draw the image at the top left */ + [windowImage drawInRect:NSMakeRect(composite.size.width - imageWidth, composite.size.height - imageHeight, imageWidth, imageHeight) + fromRect:NSZeroRect + operation:NSCompositingOperationSourceOver + fraction:1]; + /* draw the app icon at the bottom left */ + [targetApplication.icon drawInRect:NSMakeRect(0, 0, iconSize, iconSize) + fromRect:NSZeroRect + operation:NSCompositingOperationSourceOver + fraction:1]; [composite unlockFocus]; return composite; }