Skip to content

Commit

Permalink
fix #28
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed May 23, 2015
1 parent ee45866 commit bb76c35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ThymeAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
NSMenuItem *sessionsMenuExportItem;
NSMenuItem *sessionsMenuClearItem;
NSMutableArray *sessionsMenuItems;

BOOL startOnWake;
BOOL startOnScreensaverEnd;
}

@property(nonatomic, retain) Stopwatch *stopwatch;
Expand Down
14 changes: 9 additions & 5 deletions ThymeAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand All @@ -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];
}
}
Expand All @@ -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;
Expand Down

0 comments on commit bb76c35

Please sign in to comment.