feat: allow windows to be excluded from the windows menu (#17404)

* feat: allow windows to be excluded from the windows menu

* excludedfromWindowsMenu => excludedFromShownWindowsMenu

* implement no-op for win & linux
This commit is contained in:
Shelley Vohr 2019-03-27 08:10:23 -04:00 committed by GitHub
parent ec5e0ef06e
commit 4e57a732a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 0 deletions

View file

@ -567,6 +567,14 @@ void TopLevelWindow::SetSkipTaskbar(bool skip) {
window_->SetSkipTaskbar(skip);
}
void TopLevelWindow::SetExcludedFromShownWindowsMenu(bool excluded) {
window_->SetExcludedFromShownWindowsMenu(excluded);
}
bool TopLevelWindow::IsExcludedFromShownWindowsMenu() {
return window_->IsExcludedFromShownWindowsMenu();
}
void TopLevelWindow::SetSimpleFullScreen(bool simple_fullscreen) {
window_->SetSimpleFullScreen(simple_fullscreen);
}
@ -1133,6 +1141,9 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("addTabbedWindow", &TopLevelWindow::AddTabbedWindow)
.SetMethod("setWindowButtonVisibility",
&TopLevelWindow::SetWindowButtonVisibility)
.SetProperty("excludedFromShownWindowsMenu",
&TopLevelWindow::IsExcludedFromShownWindowsMenu,
&TopLevelWindow::SetExcludedFromShownWindowsMenu)
#endif
.SetMethod("setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar)
.SetMethod("isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide)

View file

@ -145,6 +145,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
std::string GetTitle();
void FlashFrame(bool flash);
void SetSkipTaskbar(bool skip);
void SetExcludedFromShownWindowsMenu(bool excluded);
bool IsExcludedFromShownWindowsMenu();
void SetSimpleFullScreen(bool simple_fullscreen);
bool IsSimpleFullScreen();
void SetKiosk(bool kiosk);

View file

@ -136,6 +136,8 @@ class NativeWindow : public base::SupportsUserData,
virtual std::string GetTitle() = 0;
virtual void FlashFrame(bool flash) = 0;
virtual void SetSkipTaskbar(bool skip) = 0;
virtual void SetExcludedFromShownWindowsMenu(bool excluded) = 0;
virtual bool IsExcludedFromShownWindowsMenu() = 0;
virtual void SetSimpleFullScreen(bool simple_fullscreen) = 0;
virtual bool IsSimpleFullScreen() = 0;
virtual void SetKiosk(bool kiosk) = 0;

View file

@ -87,6 +87,8 @@ class NativeWindowMac : public NativeWindow {
std::string GetTitle() override;
void FlashFrame(bool flash) override;
void SetSkipTaskbar(bool skip) override;
void SetExcludedFromShownWindowsMenu(bool excluded) override;
bool IsExcludedFromShownWindowsMenu() override;
void SetSimpleFullScreen(bool simple_fullscreen) override;
bool IsSimpleFullScreen() override;
void SetKiosk(bool kiosk) override;

View file

@ -886,6 +886,16 @@ void NativeWindowMac::FlashFrame(bool flash) {
void NativeWindowMac::SetSkipTaskbar(bool skip) {}
bool NativeWindowMac::IsExcludedFromShownWindowsMenu() {
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
return [window isExcludedFromWindowsMenu];
}
void NativeWindowMac::SetExcludedFromShownWindowsMenu(bool excluded) {
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
[window setExcludedFromWindowsMenu:excluded];
}
void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
NSWindow* window = GetNativeWindow().GetNativeNSWindow();

View file

@ -721,6 +721,13 @@ bool NativeWindowViews::IsMaximizable() {
#endif
}
void NativeWindowViews::SetExcludedFromShownWindowsMenu(bool excluded) {}
bool NativeWindowViews::IsExcludedFromShownWindowsMenu() {
// return false on unsupported platforms
return false;
}
void NativeWindowViews::SetFullScreenable(bool fullscreenable) {
fullscreenable_ = fullscreenable;
}

View file

@ -97,6 +97,8 @@ class NativeWindowViews : public NativeWindow,
std::string GetTitle() override;
void FlashFrame(bool flash) override;
void SetSkipTaskbar(bool skip) override;
void SetExcludedFromShownWindowsMenu(bool excluded) override;
bool IsExcludedFromShownWindowsMenu() override;
void SetSimpleFullScreen(bool simple_fullscreen) override;
bool IsSimpleFullScreen() override;
void SetKiosk(bool kiosk) override;

View file

@ -1648,3 +1648,24 @@ removed in future Electron releases.
[vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc
[window-levels]: https://developer.apple.com/documentation/appkit/nswindow/level
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
### Properties
#### `win.excludedFromShownWindowsMenu` _macOS_
A `Boolean` property that determines whether the window is excluded from the applications Windows menu. `false` by default.
```js
const win = new BrowserWindow({ height: 600, width: 600 })
const template = [
{
role: 'windowmenu'
}
]
win.excludedFromShownWindowsMenu = true
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
```