feat: reinvigorate visibleOnFullscreen option (#24956)
This commit is contained in:
parent
52d7afa4ef
commit
53668445ba
8 changed files with 37 additions and 9 deletions
|
@ -1669,9 +1669,12 @@ Sets whether the menu bar should be visible. If the menu bar is auto-hide, users
|
|||
|
||||
Returns `Boolean` - Whether the menu bar is visible.
|
||||
|
||||
#### `win.setVisibleOnAllWorkspaces(visible)`
|
||||
#### `win.setVisibleOnAllWorkspaces(visible[, options])`
|
||||
|
||||
* `visible` Boolean
|
||||
* `options` Object (optional)
|
||||
* `visibleOnFullScreen` Boolean (optional) _macOS_ - Sets whether
|
||||
the window should be visible above fullscreen windows
|
||||
|
||||
Sets whether the window should be visible on all workspaces.
|
||||
|
||||
|
|
|
@ -801,8 +801,13 @@ void BaseWindow::SetOverlayIcon(const gfx::Image& overlay,
|
|||
window_->SetOverlayIcon(overlay, description);
|
||||
}
|
||||
|
||||
void BaseWindow::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
return window_->SetVisibleOnAllWorkspaces(visible);
|
||||
void BaseWindow::SetVisibleOnAllWorkspaces(bool visible,
|
||||
gin_helper::Arguments* args) {
|
||||
gin_helper::Dictionary options;
|
||||
bool visibleOnFullScreen = false;
|
||||
args->GetNext(&options) &&
|
||||
options.Get("visibleOnFullScreen", &visibleOnFullScreen);
|
||||
return window_->SetVisibleOnAllWorkspaces(visible, visibleOnFullScreen);
|
||||
}
|
||||
|
||||
bool BaseWindow::IsVisibleOnAllWorkspaces() {
|
||||
|
|
|
@ -179,7 +179,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
|||
void SetProgressBar(double progress, gin_helper::Arguments* args);
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description);
|
||||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
void SetVisibleOnAllWorkspaces(bool visible, gin_helper::Arguments* args);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
void SetAutoHideCursor(bool auto_hide);
|
||||
virtual void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value);
|
||||
|
|
|
@ -185,7 +185,8 @@ class NativeWindow : public base::SupportsUserData,
|
|||
const std::string& description) = 0;
|
||||
|
||||
// Workspace APIs.
|
||||
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
|
||||
virtual void SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen = false) = 0;
|
||||
|
||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||
|
||||
|
|
|
@ -118,7 +118,8 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
|||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
void SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
void SetAutoHideCursor(bool auto_hide) override;
|
||||
|
|
|
@ -1351,8 +1351,24 @@ void NativeWindowMac::SetProgressBar(double progress,
|
|||
void NativeWindowMac::SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) {}
|
||||
|
||||
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
SetCollectionBehavior(visible, NSWindowCollectionBehaviorCanJoinAllSpaces);
|
||||
SetCollectionBehavior(visibleOnFullScreen,
|
||||
NSWindowCollectionBehaviorFullScreenAuxiliary);
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||
|
|
|
@ -1154,7 +1154,8 @@ bool NativeWindowViews::IsMenuBarVisible() {
|
|||
return root_view_->IsMenuBarVisible();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) {
|
||||
widget()->SetVisibleOnAllWorkspaces(visible);
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetMenuBarVisibility(bool visible) override;
|
||||
bool IsMenuBarVisible() override;
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
void SetVisibleOnAllWorkspaces(bool visible,
|
||||
bool visibleOnFullScreen) override;
|
||||
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue