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
|
* `visible` Boolean
|
||||||
* `options` Object (optional)
|
* `options` Object (optional)
|
||||||
* `visibleOnFullScreen` Boolean (optional) _macOS_ - Sets whether
|
* `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.
|
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::Arguments* args) {
|
||||||
gin_helper::Dictionary options;
|
gin_helper::Dictionary options;
|
||||||
bool visibleOnFullScreen = false;
|
bool visibleOnFullScreen = false;
|
||||||
|
bool skipTransformProcessType = false;
|
||||||
args->GetNext(&options) &&
|
args->GetNext(&options) &&
|
||||||
options.Get("visibleOnFullScreen", &visibleOnFullScreen);
|
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() {
|
bool BaseWindow::IsVisibleOnAllWorkspaces() {
|
||||||
|
|
|
@ -187,8 +187,10 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
const std::string& description) = 0;
|
const std::string& description) = 0;
|
||||||
|
|
||||||
// Workspace APIs.
|
// Workspace APIs.
|
||||||
virtual void SetVisibleOnAllWorkspaces(bool visible,
|
virtual void SetVisibleOnAllWorkspaces(
|
||||||
bool visibleOnFullScreen = false) = 0;
|
bool visible,
|
||||||
|
bool visibleOnFullScreen = false,
|
||||||
|
bool skipTransformProcessType = false) = 0;
|
||||||
|
|
||||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,8 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
||||||
void SetOverlayIcon(const gfx::Image& overlay,
|
void SetOverlayIcon(const gfx::Image& overlay,
|
||||||
const std::string& description) override;
|
const std::string& description) override;
|
||||||
void SetVisibleOnAllWorkspaces(bool visible,
|
void SetVisibleOnAllWorkspaces(bool visible,
|
||||||
bool visibleOnFullScreen) override;
|
bool visibleOnFullScreen,
|
||||||
|
bool skipTransformProcessType) override;
|
||||||
bool IsVisibleOnAllWorkspaces() override;
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
void SetAutoHideCursor(bool auto_hide) override;
|
void SetAutoHideCursor(bool auto_hide) override;
|
||||||
void SetVibrancy(const std::string& type) override;
|
void SetVibrancy(const std::string& type) override;
|
||||||
|
|
|
@ -1161,11 +1161,13 @@ void NativeWindowMac::SetOverlayIcon(const gfx::Image& overlay,
|
||||||
const std::string& description) {}
|
const std::string& description) {}
|
||||||
|
|
||||||
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible,
|
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible,
|
||||||
bool visibleOnFullScreen) {
|
bool visibleOnFullScreen,
|
||||||
|
bool skipTransformProcessType) {
|
||||||
// In order for NSWindows to be visible on fullscreen we need to functionally
|
// In order for NSWindows to be visible on fullscreen we need to functionally
|
||||||
// mimic app.dock.hide() since Apple changed the underlying functionality of
|
// mimic app.dock.hide() since Apple changed the underlying functionality of
|
||||||
// NSWindows starting with 10.14 to disallow NSWindows from floating on top of
|
// NSWindows starting with 10.14 to disallow NSWindows from floating on top of
|
||||||
// fullscreen apps.
|
// fullscreen apps.
|
||||||
|
if (!skipTransformProcessType) {
|
||||||
ProcessSerialNumber psn = {0, kCurrentProcess};
|
ProcessSerialNumber psn = {0, kCurrentProcess};
|
||||||
if (visibleOnFullScreen) {
|
if (visibleOnFullScreen) {
|
||||||
[window_ setCanHide:NO];
|
[window_ setCanHide:NO];
|
||||||
|
@ -1174,6 +1176,7 @@ void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible,
|
||||||
[window_ setCanHide:YES];
|
[window_ setCanHide:YES];
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetCollectionBehavior(visible, NSWindowCollectionBehaviorCanJoinAllSpaces);
|
SetCollectionBehavior(visible, NSWindowCollectionBehaviorCanJoinAllSpaces);
|
||||||
SetCollectionBehavior(visibleOnFullScreen,
|
SetCollectionBehavior(visibleOnFullScreen,
|
||||||
|
|
|
@ -1231,8 +1231,10 @@ bool NativeWindowViews::IsMenuBarVisible() {
|
||||||
return root_view_->IsMenuBarVisible();
|
return root_view_->IsMenuBarVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible,
|
void NativeWindowViews::SetVisibleOnAllWorkspaces(
|
||||||
bool visibleOnFullScreen) {
|
bool visible,
|
||||||
|
bool visibleOnFullScreen,
|
||||||
|
bool skipTransformProcessType) {
|
||||||
widget()->SetVisibleOnAllWorkspaces(visible);
|
widget()->SetVisibleOnAllWorkspaces(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,8 @@ class NativeWindowViews : public NativeWindow,
|
||||||
bool IsMenuBarVisible() override;
|
bool IsMenuBarVisible() override;
|
||||||
|
|
||||||
void SetVisibleOnAllWorkspaces(bool visible,
|
void SetVisibleOnAllWorkspaces(bool visible,
|
||||||
bool visibleOnFullScreen) override;
|
bool visibleOnFullScreen,
|
||||||
|
bool skipTransformProcessType) override;
|
||||||
|
|
||||||
bool IsVisibleOnAllWorkspaces() override;
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue