feat: Add BrowserWindow option to hide window in Mission Control (macOS) (#36092)
* feat: Add BrowserWindow option to ignore Mission Control (macOS) * There are many circumstances when app developers may want to hide their windows from mission control. E.g., full screen overlays, small helper windows, dialogs, etc. * This PR adds the functionality, docs, and tests. * chore:Rename variables * Update shell/browser/native_window_mac.h Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
8b430c9d26
commit
15540975ff
9 changed files with 77 additions and 1 deletions
|
@ -209,6 +209,9 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
|||
std::string windowType;
|
||||
options.Get(options::kType, &windowType);
|
||||
|
||||
bool hiddenInMissionControl = false;
|
||||
options.Get(options::kHiddenInMissionControl, &hiddenInMissionControl);
|
||||
|
||||
bool useStandardWindow = true;
|
||||
// eventually deprecate separate "standardWindow" option in favor of
|
||||
// standard / textured window types
|
||||
|
@ -347,6 +350,8 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
|||
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
|
||||
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
|
||||
|
||||
SetHiddenInMissionControl(hiddenInMissionControl);
|
||||
|
||||
// Set maximizable state last to ensure zoom button does not get reset
|
||||
// by calls to other APIs.
|
||||
SetMaximizable(maximizable);
|
||||
|
@ -1085,9 +1090,17 @@ bool NativeWindowMac::IsDocumentEdited() {
|
|||
return [window_ isDocumentEdited];
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsHiddenInMissionControl() {
|
||||
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
||||
return collectionBehavior & NSWindowCollectionBehaviorTransient;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetHiddenInMissionControl(bool hidden) {
|
||||
SetCollectionBehavior(hidden, NSWindowCollectionBehaviorTransient);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
||||
[window_ setIgnoresMouseEvents:ignore];
|
||||
|
||||
if (!ignore) {
|
||||
SetForwardMouseMessages(NO);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue