From e3730418d21919938f73573a8554c155a2b11927 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 3 Aug 2020 11:58:22 -0700 Subject: [PATCH] fix: duplicate suspend/resume events --- .../api/electron_api_power_monitor_mac.mm | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/shell/browser/api/electron_api_power_monitor_mac.mm b/shell/browser/api/electron_api_power_monitor_mac.mm index f3830792d43bd..2c65bcd265923 100644 --- a/shell/browser/api/electron_api_power_monitor_mac.mm +++ b/shell/browser/api/electron_api_power_monitor_mac.mm @@ -24,29 +24,27 @@ - (id)init { if ((self = [super init])) { NSDistributedNotificationCenter* distCenter = [NSDistributedNotificationCenter defaultCenter]; + // A notification that the screen was locked. [distCenter addObserver:self selector:@selector(onScreenLocked:) name:@"com.apple.screenIsLocked" object:nil]; + // A notification that the screen was unlocked by the user. [distCenter addObserver:self selector:@selector(onScreenUnlocked:) name:@"com.apple.screenIsUnlocked" object:nil]; - // A notification that the workspace posts before the machine goes to sleep. - [[[NSWorkspace sharedWorkspace] notificationCenter] - addObserver:self - selector:@selector(isSuspending:) - name:NSWorkspaceWillSleepNotification - object:nil]; - + [distCenter addObserver:self + selector:@selector(isSuspending:) + name:NSWorkspaceWillSleepNotification + object:nil]; // A notification that the workspace posts when the machine wakes from // sleep. - [[[NSWorkspace sharedWorkspace] notificationCenter] - addObserver:self - selector:@selector(isResuming:) - name:NSWorkspaceDidWakeNotification - object:nil]; + [distCenter addObserver:self + selector:@selector(isResuming:) + name:NSWorkspaceDidWakeNotification + object:nil]; } return self; }