mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
feat: add macOS fast user switching evt (#25321)
This commit is contained in:
@@ -45,6 +45,18 @@
|
||||
selector:@selector(isResuming:)
|
||||
name:NSWorkspaceDidWakeNotification
|
||||
object:nil];
|
||||
// A notification that the workspace posts when the user session becomes
|
||||
// active.
|
||||
[distCenter addObserver:self
|
||||
selector:@selector(onUserDidBecomeActive:)
|
||||
name:NSWorkspaceSessionDidBecomeActiveNotification
|
||||
object:nil];
|
||||
// A notification that the workspace posts when the user session becomes
|
||||
// inactive.
|
||||
[distCenter addObserver:self
|
||||
selector:@selector(onUserDidResignActive:)
|
||||
name:NSWorkspaceSessionDidResignActiveNotification
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -82,6 +94,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onUserDidBecomeActive:(NSNotification*)notification {
|
||||
for (auto* emitter : self->emitters) {
|
||||
emitter->Emit("user-did-become-active");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onUserDidResignActive:(NSNotification*)notification {
|
||||
for (auto* emitter : self->emitters) {
|
||||
emitter->Emit("user-did-resign-active");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace electron {
|
||||
|
||||
Reference in New Issue
Block a user