From b89848d683b4ed58adf69d5c4da3a074775fb8d5 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 31 Aug 2018 17:06:02 -0500 Subject: [PATCH] feat: allow window above full screen windows on mac (#14122) * allow window above full screen windows on mac * add visibility change params to higher level files * adress feedback, fix bool issue, remove compilation hooks * adjust readme * switch to options object * single argument for native window views --- atom/browser/api/atom_api_top_level_window.cc | 9 +++++++-- atom/browser/api/atom_api_top_level_window.h | 2 +- atom/browser/native_window.h | 4 +++- atom/browser/native_window_mac.h | 3 ++- atom/browser/native_window_mac.mm | 5 ++++- atom/browser/native_window_views.cc | 3 ++- atom/browser/native_window_views.h | 5 ++++- docs/api/browser-window.md | 5 ++++- 8 files changed, 27 insertions(+), 9 deletions(-) diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index 799ff5aca52e..c3110099aa6d 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -706,8 +706,13 @@ void TopLevelWindow::SetOverlayIcon(const gfx::Image& overlay, window_->SetOverlayIcon(overlay, description); } -void TopLevelWindow::SetVisibleOnAllWorkspaces(bool visible) { - return window_->SetVisibleOnAllWorkspaces(visible); +void TopLevelWindow::SetVisibleOnAllWorkspaces(bool visible, + mate::Arguments* args) { + mate::Dictionary options; + bool visibleOnFullScreen = false; + args->GetNext(&options) && + options.Get("visibleOnFullScreen", &visibleOnFullScreen); + return window_->SetVisibleOnAllWorkspaces(visible, visibleOnFullScreen); } bool TopLevelWindow::IsVisibleOnAllWorkspaces() { diff --git a/atom/browser/api/atom_api_top_level_window.h b/atom/browser/api/atom_api_top_level_window.h index ead430ae9ad5..4ad8ac65f3b8 100644 --- a/atom/browser/api/atom_api_top_level_window.h +++ b/atom/browser/api/atom_api_top_level_window.h @@ -167,7 +167,7 @@ class TopLevelWindow : public mate::TrackableObject, void SetProgressBar(double progress, mate::Arguments* args); void SetOverlayIcon(const gfx::Image& overlay, const std::string& description); - void SetVisibleOnAllWorkspaces(bool visible); + void SetVisibleOnAllWorkspaces(bool visible, mate::Arguments* args); bool IsVisibleOnAllWorkspaces(); void SetAutoHideCursor(bool auto_hide); virtual void SetVibrancy(v8::Isolate* isolate, v8::Local value); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 3069d607ca31..a41e94595ee9 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -167,7 +167,9 @@ 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; virtual void SetAutoHideCursor(bool auto_hide); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 3d8f6a932f1a..84898d986b38 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -109,7 +109,8 @@ class NativeWindowMac : public NativeWindow { 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; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 060f6fe4dcc3..f4d08a99fa62 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1132,8 +1132,11 @@ 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) { SetCollectionBehavior(visible, NSWindowCollectionBehaviorCanJoinAllSpaces); + SetCollectionBehavior(visibleOnFullScreen, + NSWindowCollectionBehaviorFullScreenAuxiliary); } bool NativeWindowMac::IsVisibleOnAllWorkspaces() { diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 0efb7aaf9f53..280410b7ba82 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -1006,7 +1006,8 @@ bool NativeWindowViews::IsMenuBarVisible() { return root_view_->IsMenuBarVisible(); } -void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible) { +void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible, + bool visibleOnFullScreen) { widget()->SetVisibleOnAllWorkspaces(visible); } diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index e73c5694b8b7..4b61754ed865 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -120,7 +120,10 @@ class NativeWindowViews : public NativeWindow, bool IsMenuBarAutoHide() override; void SetMenuBarVisibility(bool visible) override; bool IsMenuBarVisible() override; - void SetVisibleOnAllWorkspaces(bool visible) override; + + void SetVisibleOnAllWorkspaces(bool visible, + bool visibleOnFullScreen) override; + bool IsVisibleOnAllWorkspaces() override; gfx::AcceleratedWidget GetAcceleratedWidget() const override; diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 78d17cc16560..c20c7480d7c1 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1418,9 +1418,12 @@ can still bring up the menu bar by pressing the single `Alt` key. 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.