fix: duplicate suspend/resume events (#24818)
This commit is contained in:
parent
30cd9cdf2a
commit
06c47c650a
1 changed files with 10 additions and 12 deletions
|
@ -24,29 +24,27 @@
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
NSDistributedNotificationCenter* distCenter =
|
NSDistributedNotificationCenter* distCenter =
|
||||||
[NSDistributedNotificationCenter defaultCenter];
|
[NSDistributedNotificationCenter defaultCenter];
|
||||||
|
// A notification that the screen was locked.
|
||||||
[distCenter addObserver:self
|
[distCenter addObserver:self
|
||||||
selector:@selector(onScreenLocked:)
|
selector:@selector(onScreenLocked:)
|
||||||
name:@"com.apple.screenIsLocked"
|
name:@"com.apple.screenIsLocked"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
// A notification that the screen was unlocked by the user.
|
||||||
[distCenter addObserver:self
|
[distCenter addObserver:self
|
||||||
selector:@selector(onScreenUnlocked:)
|
selector:@selector(onScreenUnlocked:)
|
||||||
name:@"com.apple.screenIsUnlocked"
|
name:@"com.apple.screenIsUnlocked"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
// A notification that the workspace posts before the machine goes to sleep.
|
// A notification that the workspace posts before the machine goes to sleep.
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter]
|
[distCenter addObserver:self
|
||||||
addObserver:self
|
selector:@selector(isSuspending:)
|
||||||
selector:@selector(isSuspending:)
|
name:NSWorkspaceWillSleepNotification
|
||||||
name:NSWorkspaceWillSleepNotification
|
object:nil];
|
||||||
object:nil];
|
|
||||||
|
|
||||||
// A notification that the workspace posts when the machine wakes from
|
// A notification that the workspace posts when the machine wakes from
|
||||||
// sleep.
|
// sleep.
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter]
|
[distCenter addObserver:self
|
||||||
addObserver:self
|
selector:@selector(isResuming:)
|
||||||
selector:@selector(isResuming:)
|
name:NSWorkspaceDidWakeNotification
|
||||||
name:NSWorkspaceDidWakeNotification
|
object:nil];
|
||||||
object:nil];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue