diff --git a/MasterPassword/ObjC/Mac/MPMacAppDelegate.h b/MasterPassword/ObjC/Mac/MPMacAppDelegate.h index 3425b997..204bd53f 100644 --- a/MasterPassword/ObjC/Mac/MPMacAppDelegate.h +++ b/MasterPassword/ObjC/Mac/MPMacAppDelegate.h @@ -22,6 +22,7 @@ @property(nonatomic, weak) IBOutlet NSMenuItem *hidePasswordsItem; @property(nonatomic, weak) IBOutlet NSMenuItem *rememberPasswordItem; @property(nonatomic, weak) IBOutlet NSMenuItem *openAtLoginItem; +@property(nonatomic, weak) IBOutlet NSMenuItem *showFullScreenItem; @property(nonatomic, weak) IBOutlet NSMenuItem *savePasswordItem; @property(nonatomic, weak) IBOutlet NSMenuItem *createUserItem; @property(nonatomic, weak) IBOutlet NSMenuItem *deleteUserItem; diff --git a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m index 1d507aeb..9271c0af 100644 --- a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m +++ b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m @@ -335,11 +335,15 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (IBAction)togglePreference:(id)sender { if (sender == self.hidePasswordsItem) - [MPConfig get].hidePasswords = @(![[MPConfig get].hidePasswords boolValue]); + [MPConfig get].hidePasswords = @(self.hidePasswordsItem.state != NSOnState); if (sender == self.rememberPasswordItem) - [MPConfig get].rememberLogin = @(![[MPConfig get].rememberLogin boolValue]); + [MPConfig get].rememberLogin = @(self.rememberPasswordItem.state != NSOnState); if (sender == self.openAtLoginItem) [self setLoginItemEnabled:self.openAtLoginItem.state != NSOnState]; + if (sender == self.showFullScreenItem) { + [MPMacConfig get].fullScreen = @(self.showFullScreenItem.state != NSOnState); + [NSApp updateWindows]; + } if (sender == self.savePasswordItem) { [MPMacAppDelegate managedObjectContextPerformBlockAndWait:^(NSManagedObjectContext *context) { MPUserEntity *activeUser = [[MPMacAppDelegate get] activeUserInContext:context]; @@ -610,6 +614,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven BOOL loginItemEnabled = [self loginItemEnabled]; self.openAtLoginItem.state = loginItemEnabled? NSOnState: NSOffState; + self.showFullScreenItem.state = [[MPMacConfig get].fullScreen boolValue]? NSOnState: NSOffState; self.initialWindowController.openAtLoginButton.state = loginItemEnabled? NSOnState: NSOffState; self.rememberPasswordItem.state = [[MPConfig get].rememberLogin boolValue]? NSOnState: NSOffState; diff --git a/MasterPassword/ObjC/Mac/MPMacConfig.h b/MasterPassword/ObjC/Mac/MPMacConfig.h index c3a208fa..3caf3db3 100644 --- a/MasterPassword/ObjC/Mac/MPMacConfig.h +++ b/MasterPassword/ObjC/Mac/MPMacConfig.h @@ -11,5 +11,6 @@ @interface MPMacConfig : MPConfig @property(nonatomic, retain) NSString *usedUserName; +@property(nonatomic, retain) NSNumber *fullScreen; @end diff --git a/MasterPassword/ObjC/Mac/MPMacConfig.m b/MasterPassword/ObjC/Mac/MPMacConfig.m index 7cac08be..0f494bc9 100644 --- a/MasterPassword/ObjC/Mac/MPMacConfig.m +++ b/MasterPassword/ObjC/Mac/MPMacConfig.m @@ -9,6 +9,7 @@ @implementation MPMacConfig @dynamic usedUserName; +@dynamic fullScreen; - (id)init { @@ -16,7 +17,8 @@ return self; [self.defaults registerDefaults:@{ - NSStringFromSelector( @selector(appleID) ) : @"510296984", + NSStringFromSelector( @selector( appleID ) ) : @"510296984", + NSStringFromSelector( @selector( fullScreen ) ) : @YES, }]; return self; diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindow.h b/MasterPassword/ObjC/Mac/MPPasswordWindow.h index b3beab8c..9d5dc1d7 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindow.h +++ b/MasterPassword/ObjC/Mac/MPPasswordWindow.h @@ -20,4 +20,5 @@ @interface MPPasswordWindow : NSWindow + @end diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindow.m b/MasterPassword/ObjC/Mac/MPPasswordWindow.m index 89217459..9130baf9 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindow.m +++ b/MasterPassword/ObjC/Mac/MPPasswordWindow.m @@ -18,21 +18,10 @@ #import "MPPasswordWindow.h" - @implementation MPPasswordWindow #pragma mark - Life -- (void)awakeFromNib { - - [super awakeFromNib]; - - self.opaque = NO; - self.backgroundColor = [NSColor clearColor]; - self.level = NSScreenSaverWindowLevel; - self.alphaValue = 0; -} - - (BOOL)canBecomeKeyWindow { return YES; @@ -40,6 +29,21 @@ #pragma mark - State +- (void)update { + + if ([[MPMacConfig get].fullScreen boolValue]) { + [self setLevel:NSScreenSaverWindowLevel]; + [self setFrame:self.screen.frame display:YES]; + } + else { + [self setLevel:NSNormalWindowLevel]; + [self setFrame:NSMakeRect( 0, 0, 640, 600) display:NO]; + [self center]; + } + + [super update]; +} + #pragma mark - Private @end diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.h b/MasterPassword/ObjC/Mac/MPPasswordWindowController.h index 29613088..7bee11e6 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.h +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.h @@ -19,6 +19,7 @@ #import #import "MPSiteModel.h" #import "MPSitesTableView.h" +#import "MPPasswordWindow.h" @class MPMacAppDelegate; @@ -33,7 +34,6 @@ @property(nonatomic) BOOL newUser; @property(nonatomic, weak) IBOutlet NSArrayController *sitesController; -@property(nonatomic, weak) IBOutlet NSImageView *blurView; @property(nonatomic, weak) IBOutlet NSTextField *inputLabel; @property(nonatomic, weak) IBOutlet NSTextField *securePasswordField; @property(nonatomic, weak) IBOutlet NSTextField *revealPasswordField; diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.m b/MasterPassword/ObjC/Mac/MPPasswordWindowController.m index e6d9410d..4d0f8551 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.m +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.m @@ -61,7 +61,7 @@ [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidBecomeKeyNotification object:self.window queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { prof_new( @"didBecomeKey" ); - [self fadeIn]; + [self.window makeKeyAndOrderFront:nil]; prof_rewind( @"fadeIn" ); [self updateUser]; prof_finish( @"updateUser" ); @@ -75,7 +75,7 @@ [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { #ifndef DEBUG - [self fadeOut]; + [self.window fadeOut]; #endif }]; [[NSNotificationCenter defaultCenter] addObserverForName:MPSignedInNotification object:nil @@ -362,7 +362,7 @@ - (IBAction)settings:(id)sender { - [self fadeOut:NO]; + [self.window close]; [[MPMacAppDelegate get] showPopup:sender]; } @@ -471,7 +471,7 @@ return YES; } if (commandSelector == @selector( cancel: ) || commandSelector == @selector( cancelOperation: )) { - [self fadeOut]; + [self.window close]; return YES; } @@ -492,7 +492,7 @@ // Performing action while content is available. Copy it. [self copyContent:self.shiftPressed? selectedSite.answer: selectedSite.content]; - [self fadeOut]; + [self.window close]; NSUserNotification *notification = [NSUserNotification new]; notification.title = @"Password Copied"; @@ -602,6 +602,7 @@ CGFloat gradientOpacity = selectedOffset / siteScrollView.bounds.size.height; self.siteGradient.colors = @[ (__bridge id)[NSColor whiteColor].CGColor, + (__bridge id)[NSColor colorWithDeviceWhite:1 alpha:1 - (1 - gradientOpacity) * 4 / 5].CGColor, (__bridge id)[NSColor colorWithDeviceWhite:1 alpha:gradientOpacity].CGColor ]; @@ -636,70 +637,4 @@ }]; } -- (void)fadeIn { - - prof_new( @"fadeIn" ); - if ([self.window isOnActiveSpace] && self.window.alphaValue > FLT_EPSILON) { - prof_finish( @"showing" ); - return; - } - - CGDirectDisplayID displayID = [self.window.screen.deviceDescription[@"NSScreenNumber"] unsignedIntValue]; - CGImageRef capturedImage = CGDisplayCreateImage( displayID ); - if (!capturedImage || CGImageGetWidth( capturedImage ) <= 1) { - if (capturedImage) - CFRelease( capturedImage ); - wrn( @"Failed to capture screen image for display: %d", displayID ); - prof_finish( @"capture failed" ); - return; - } - prof_rewind( @"capture" ); - - NSImage *screenImage = [[NSImage alloc] initWithCGImage:capturedImage size:NSMakeSize( - CGImageGetWidth( capturedImage ) / self.window.backingScaleFactor, - CGImageGetHeight( capturedImage ) / self.window.backingScaleFactor )]; - prof_rewind( @"screenImage" ); - - NSImage *smallImage = [[NSImage alloc] initWithSize:NSMakeSize( - CGImageGetWidth( capturedImage ) / 20, - CGImageGetHeight( capturedImage ) / 20 )]; - prof_rewind( @"smallImage" ); - CFRelease( capturedImage ); - [smallImage lockFocus]; - [screenImage drawInRect:(NSRect){ .origin = CGPointZero, .size = smallImage.size, } - fromRect:NSZeroRect - operation:NSCompositeSourceOver - fraction:1.0]; - [smallImage unlockFocus]; - prof_rewind( @"scale" ); - - self.blurView.image = smallImage; - prof_rewind( @"blurView" ); - - [self.window setFrame:self.window.screen.frame display:YES]; - [NSAnimationContext currentContext].timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; - self.window.animator.alphaValue = 1.0; - prof_finish( @"window setup" ); -} - -- (void)fadeOut { - - [self fadeOut:YES]; -} - -- (void)fadeOut:(BOOL)hide { - - if (![NSApp isActive] && self.window.alphaValue <= FLT_EPSILON) - return; - - [[NSAnimationContext currentContext] setCompletionHandler:^{ - [self close]; - - if (hide) - [NSApp hide:self]; - }]; - [NSAnimationContext currentContext].timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; - [self.window animator].alphaValue = 0.0; -} - @end diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib b/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib index 03fadc62..1d88311c 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib @@ -9,7 +9,6 @@ - @@ -25,192 +24,33 @@ - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - -