diff --git a/ThymeAppDelegate.h b/ThymeAppDelegate.h index c780a0d..6517af9 100644 --- a/ThymeAppDelegate.h +++ b/ThymeAppDelegate.h @@ -33,6 +33,9 @@ NSMenuItem *sessionsMenuExportItem; NSMenuItem *sessionsMenuClearItem; NSMutableArray *sessionsMenuItems; + + BOOL startOnWake; + BOOL startOnScreensaverEnd; } @property(nonatomic, retain) Stopwatch *stopwatch; diff --git a/ThymeAppDelegate.m b/ThymeAppDelegate.m index 145151a..b4638bc 100644 --- a/ThymeAppDelegate.m +++ b/ThymeAppDelegate.m @@ -386,13 +386,15 @@ - (void)resetHotKeys { - (void) onSleep: (NSNotification*) note { if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnSleep"]) { + startOnWake = [self.stopwatch isActive]; [self pauseWithNotification:NO]; } } - (void) onWake: (NSNotification*) note { - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnSleep"]) { + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnSleep"] && startOnWake) { + startOnWake = NO; [self startWithNotification:NO]; } } @@ -401,16 +403,16 @@ - (void) onWake: (NSNotification*) note - (void) onScreensaverStart: (NSNotification*) note { - NSLog(@"screensaver start"); if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnScreensaver"]) { + startOnScreensaverEnd = [self.stopwatch isActive]; [self pauseWithNotification:NO]; } } - (void) onScreensaverStop: (NSNotification*) note { - NSLog(@"screensaver stop"); - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnScreensaver"]) { + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnScreensaver"] && startOnScreensaverEnd) { + startOnScreensaverEnd = NO; [self startWithNotification:NO]; } } @@ -420,7 +422,9 @@ - (void) onScreensaverStop: (NSNotification*) note - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [window close]; - + startOnWake = NO; + startOnScreensaverEnd = NO; + // Setup the hotkey center DDHotKeyCenter *center = [[DDHotKeyCenter alloc] init]; self.hotKeyCenter = center;