fix: remove extra 'suspend'/'resume' handling from powerMonitor (#47162)

fix: remove extra 'suspend'/'resume' handling from powerMonitor
This commit is contained in:
Shelley Vohr 2025-05-21 17:00:38 +02:00 committed by GitHub
commit 7b77a24211
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 0 additions and 35 deletions

View file

@ -34,17 +34,6 @@
selector:@selector(onScreenUnlocked:)
name:@"com.apple.screenIsUnlocked"
object:nil];
// A notification that the workspace posts before the machine goes to sleep.
[distributed_center addObserver:self
selector:@selector(isSuspending:)
name:NSWorkspaceWillSleepNotification
object:nil];
// A notification that the workspace posts when the machine wakes from
// sleep.
[distributed_center addObserver:self
selector:@selector(isResuming:)
name:NSWorkspaceDidWakeNotification
object:nil];
NSNotificationCenter* shared_center =
[[NSWorkspace sharedWorkspace] notificationCenter];
@ -73,18 +62,6 @@
self->emitters.push_back(monitor_);
}
- (void)isSuspending:(NSNotification*)notify {
for (auto* emitter : self->emitters) {
emitter->Emit("suspend");
}
}
- (void)isResuming:(NSNotification*)notify {
for (auto* emitter : self->emitters) {
emitter->Emit("resume");
}
}
- (void)onScreenLocked:(NSNotification*)notification {
for (auto* emitter : self->emitters) {
emitter->Emit("lock-screen");

View file

@ -88,18 +88,6 @@ LRESULT CALLBACK PowerMonitor::WndProc(HWND hwnd,
base::Unretained(this)));
}
}
} else if (message == WM_POWERBROADCAST) {
if (wparam == PBT_APMRESUMEAUTOMATIC) {
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce([](PowerMonitor* pm) { pm->Emit("resume"); },
base::Unretained(this)));
} else if (wparam == PBT_APMSUSPEND) {
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce([](PowerMonitor* pm) { pm->Emit("suspend"); },
base::Unretained(this)));
}
}
return ::DefWindowProc(hwnd, message, wparam, lparam);
}