fix: simpleFullscreen window should be on top of other OS X menu bars. (#14881)
If an app has no menu bar (because `app.dock.hide()` has been called), OS X will still render the menu bar of the previously-focused app. This commit ensures simpleFullscreen windows will be drawn on top of that menu bar by setting their level to NSPopUpMenuWindowLevel while simpleFullscreen mode is active. Ref: https://github.com/electron/electron/issues/11468
This commit is contained in:
parent
ed065f0106
commit
af4cf1e969
2 changed files with 14 additions and 2 deletions
|
@ -209,6 +209,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
bool was_maximizable_ = false;
|
bool was_maximizable_ = false;
|
||||||
bool was_movable_ = false;
|
bool was_movable_ = false;
|
||||||
NSRect original_frame_;
|
NSRect original_frame_;
|
||||||
|
NSInteger original_level_;
|
||||||
NSUInteger simple_fullscreen_mask_;
|
NSUInteger simple_fullscreen_mask_;
|
||||||
|
|
||||||
base::scoped_nsobject<NSColor> background_color_before_vibrancy_;
|
base::scoped_nsobject<NSColor> background_color_before_vibrancy_;
|
||||||
|
|
|
@ -473,6 +473,7 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
AddContentViewLayers();
|
AddContentViewLayers();
|
||||||
|
|
||||||
original_frame_ = [window_ frame];
|
original_frame_ = [window_ frame];
|
||||||
|
original_level_ = [window_ level];
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowMac::~NativeWindowMac() {
|
NativeWindowMac::~NativeWindowMac() {
|
||||||
|
@ -892,9 +893,11 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
||||||
if (simple_fullscreen && !is_simple_fullscreen_) {
|
if (simple_fullscreen && !is_simple_fullscreen_) {
|
||||||
is_simple_fullscreen_ = true;
|
is_simple_fullscreen_ = true;
|
||||||
|
|
||||||
// Take note of the current window size
|
// Take note of the current window size and level
|
||||||
if (IsNormal())
|
if (IsNormal()) {
|
||||||
original_frame_ = [window_ frame];
|
original_frame_ = [window_ frame];
|
||||||
|
original_level_ = [window_ level];
|
||||||
|
}
|
||||||
|
|
||||||
simple_fullscreen_options_ = [NSApp currentSystemPresentationOptions];
|
simple_fullscreen_options_ = [NSApp currentSystemPresentationOptions];
|
||||||
simple_fullscreen_mask_ = [window styleMask];
|
simple_fullscreen_mask_ = [window styleMask];
|
||||||
|
@ -911,6 +914,13 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
||||||
|
|
||||||
NSRect fullscreenFrame = [window.screen frame];
|
NSRect fullscreenFrame = [window.screen frame];
|
||||||
|
|
||||||
|
// If our app has dock hidden, set the window level higher so another app's
|
||||||
|
// menu bar doesn't appear on top of our fullscreen app.
|
||||||
|
if ([[NSRunningApplication currentApplication] activationPolicy] !=
|
||||||
|
NSApplicationActivationPolicyRegular) {
|
||||||
|
window.level = NSPopUpMenuWindowLevel;
|
||||||
|
}
|
||||||
|
|
||||||
if (!fullscreen_window_title()) {
|
if (!fullscreen_window_title()) {
|
||||||
// Hide the titlebar
|
// Hide the titlebar
|
||||||
SetStyleMask(false, NSWindowStyleMaskTitled);
|
SetStyleMask(false, NSWindowStyleMaskTitled);
|
||||||
|
@ -951,6 +961,7 @@ void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
||||||
setHidden:window_button_hidden];
|
setHidden:window_button_hidden];
|
||||||
|
|
||||||
[window setFrame:original_frame_ display:YES animate:YES];
|
[window setFrame:original_frame_ display:YES animate:YES];
|
||||||
|
window.level = original_level_;
|
||||||
|
|
||||||
[NSApp setPresentationOptions:simple_fullscreen_options_];
|
[NSApp setPresentationOptions:simple_fullscreen_options_];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue