feat: add macOS fast user switching evt (#25321)
This commit is contained in:
parent
f6f05c34e6
commit
6acf34fa4c
2 changed files with 32 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue