feat: add option to not transform processes on win.SetVisibleOnAllWorkspaces (#27200)
* fix: optionally transform processes on win.SetVisibleOnAllWorkspaces on macOS, making it backwards-compatible with v9.2.1 (#27101) * fix: optionally transform processes on win.SetVisibleOnAllWorkspaces on macOS, making it backwards-compatible with v9.2.1 (#27101) Co-authored-by: Cyrus Roshan <cyrusroshan@users.noreply.github.com>
This commit is contained in:
parent
272611cc82
commit
444ad26f89
7 changed files with 36 additions and 16 deletions
|
@ -1624,7 +1624,14 @@ Returns `Boolean` - Whether the menu bar is visible.
|
|||
* `visible` Boolean
|
||||
* `options` Object (optional)
|
||||
* `visibleOnFullScreen` Boolean (optional) _macOS_ - Sets whether
|
||||
the window should be visible above fullscreen windows
|
||||
the window should be visible above fullscreen windows.
|
||||
* `skipTransformProcessType` Boolean (optional) _macOS_ - Calling
|
||||
setVisibleOnAllWorkspaces will by default transform the process
|
||||
type between UIElementApplication and ForegroundApplication to
|
||||
ensure the correct behavior. However, this will hide the window
|
||||
and dock for a short time every time it is called. If your window
|
||||
is already of type UIElementApplication, you can bypass this
|
||||
transformation by passing true to skipTransformProcessType.
|
||||
|
||||
Sets whether the window should be visible on all workspaces.
|
||||
|
||||
|
|
|
@ -825,9 +825,13 @@ void BaseWindow::SetVisibleOnAllWorkspaces(bool visible,
|
|||
gin_helper::Arguments* args) {
|
||||
gin_helper::Dictionary options;
|
||||
bool visibleOnFullScreen = false;
|
||||
bool skipTransformProcessType = false;
|
||||
args->GetNext(&options) &&
|
||||
options.Get("visibleOnFullScreen", &visibleOnFullScreen);
|
||||
return window_->SetVisibleOnAllWorkspaces(visible, visibleOnFullScreen);
|
||||
args->GetNext(&options) &&
|
||||
options.Get("skipTransformProcessType", &skipTransformProcessType);
|
||||
return window_->SetVisibleOnAllWorkspaces(visible, visibleOnFullScreen,
|
||||
skipTransformProcessType);
|
||||
}
|
||||
|
||||
bool BaseWindow::IsVisibleOnAllWorkspaces() {
|
||||
|
|
|
@ -187,8 +187,10 @@ class NativeWindow : public base::SupportsUserData,
|
|||
const std::string& description) = 0;
|
||||
|
||||
// Workspace APIs.
|
||||
virtual void SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen = false) = 0;
|
||||
virtual void SetVisibleOnAllWorkspaces(
|
||||
bool visible,
|
||||
bool visibleOnFullScreen = false,
|
||||
bool skipTransformProcessType = false) = 0;
|
||||
|
||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
|||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
void SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) override;
|
||||
bool visibleOnFullScreen,
|
||||
bool skipTransformProcessType) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
void SetAutoHideCursor(bool auto_hide) override;
|
||||
void SetVibrancy(const std::string& type) override;
|
||||
|
|
|
@ -1161,18 +1161,21 @@ void NativeWindowMac::SetOverlayIcon(const gfx::Image& overlay,
|
|||
const std::string& description) {}
|
||||
|
||||
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) {
|
||||
bool visibleOnFullScreen,
|
||||
bool skipTransformProcessType) {
|
||||
// In order for NSWindows to be visible on fullscreen we need to functionally
|
||||
// mimic app.dock.hide() since Apple changed the underlying functionality of
|
||||
// NSWindows starting with 10.14 to disallow NSWindows from floating on top of
|
||||
// fullscreen apps.
|
||||
ProcessSerialNumber psn = {0, kCurrentProcess};
|
||||
if (visibleOnFullScreen) {
|
||||
[window_ setCanHide:NO];
|
||||
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
||||
} else {
|
||||
[window_ setCanHide:YES];
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
if (!skipTransformProcessType) {
|
||||
ProcessSerialNumber psn = {0, kCurrentProcess};
|
||||
if (visibleOnFullScreen) {
|
||||
[window_ setCanHide:NO];
|
||||
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
||||
} else {
|
||||
[window_ setCanHide:YES];
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
}
|
||||
|
||||
SetCollectionBehavior(visible, NSWindowCollectionBehaviorCanJoinAllSpaces);
|
||||
|
|
|
@ -1231,8 +1231,10 @@ bool NativeWindowViews::IsMenuBarVisible() {
|
|||
return root_view_->IsMenuBarVisible();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) {
|
||||
void NativeWindowViews::SetVisibleOnAllWorkspaces(
|
||||
bool visible,
|
||||
bool visibleOnFullScreen,
|
||||
bool skipTransformProcessType) {
|
||||
widget()->SetVisibleOnAllWorkspaces(visible);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool IsMenuBarVisible() override;
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) override;
|
||||
bool visibleOnFullScreen,
|
||||
bool skipTransformProcessType) override;
|
||||
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue