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
|
@ -39,6 +39,14 @@ Emitted when the system is about to lock the screen.
|
|||
|
||||
Emitted as soon as the systems screen is unlocked.
|
||||
|
||||
### Event: 'user-did-become-active' _macOS_
|
||||
|
||||
Emitted when a login session is activated. See [documentation](https://developer.apple.com/documentation/appkit/nsworkspacesessiondidbecomeactivenotification?language=objc) for more information.
|
||||
|
||||
### Event: 'user-did-resign-active' _macOS_
|
||||
|
||||
Emitted when a login session is deactivated. See [documentation](https://developer.apple.com/documentation/appkit/nsworkspacesessiondidresignactivenotification?language=objc) for more information.
|
||||
|
||||
## Methods
|
||||
|
||||
The `powerMonitor` module has the following methods:
|
||||
|
|
|
@ -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…
Reference in a new issue