Skip to content

Commit

Permalink
fix: window button visibility fullscreen interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jun 13, 2022
1 parent 2a9b3cc commit 073ebe7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shell/browser/native_window_mac.mm
Expand Up @@ -1511,6 +1511,11 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {

void NativeWindowMac::SetWindowButtonVisibility(bool visible) {
window_button_visibility_ = visible;
if (buttons_proxy_ && visible) {
[buttons_proxy_ redraw];
[buttons_proxy_ setVisible:YES];
}

// The visibility of window buttons are managed by |buttons_proxy_| if the
// style is customButtonsOnHover.
if (title_bar_style_ == TitleBarStyle::kCustomButtonsOnHover)
Expand Down
36 changes: 36 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -1996,6 +1996,42 @@ describe('BrowserWindow module', () => {
w.setWindowButtonVisibility(false);
expect(w._getWindowButtonVisibility()).to.equal(false);
});

it('correctly updates when entering/exiting fullscreen for hidden style', async () => {
const w = new BrowserWindow({ show: false, frame: false, titleBarStyle: 'hidden' });
expect(w._getWindowButtonVisibility()).to.equal(true);
w.setWindowButtonVisibility(false);
expect(w._getWindowButtonVisibility()).to.equal(false);

const enterFS = emittedOnce(w, 'enter-full-screen');
w.setFullScreen(true);
await enterFS;

const leaveFS = emittedOnce(w, 'leave-full-screen');
w.setFullScreen(false);
await leaveFS;

w.setWindowButtonVisibility(true);
expect(w._getWindowButtonVisibility()).to.equal(true);
});

it('correctly updates when entering/exiting fullscreen for hiddenInset style', async () => {
const w = new BrowserWindow({ show: false, frame: false, titleBarStyle: 'hiddenInset' });
expect(w._getWindowButtonVisibility()).to.equal(true);
w.setWindowButtonVisibility(false);
expect(w._getWindowButtonVisibility()).to.equal(false);

const enterFS = emittedOnce(w, 'enter-full-screen');
w.setFullScreen(true);
await enterFS;

const leaveFS = emittedOnce(w, 'leave-full-screen');
w.setFullScreen(false);
await leaveFS;

w.setWindowButtonVisibility(true);
expect(w._getWindowButtonVisibility()).to.equal(true);
});
});

ifdescribe(process.platform === 'darwin')('BrowserWindow.setVibrancy(type)', () => {
Expand Down

0 comments on commit 073ebe7

Please sign in to comment.