Merge pull request #9695 from shubham2892/alwaysOnTop-window-disappears-when-restored-fix

Fix an issue where alwaysOnTop window disappears when restore…
This commit is contained in:
Kevin Sawicki 2017-07-14 10:09:13 -07:00 committed by GitHub
commit 0a71a9b992
2 changed files with 26 additions and 0 deletions

View file

@ -172,6 +172,7 @@ bool ScopedDisableResize::disable_resize_ = false;
@private
atom::NativeWindowMac* shell_;
bool is_zooming_;
int level_;
}
- (id)initWithShell:(atom::NativeWindowMac*)shell;
@end
@ -182,6 +183,7 @@ bool ScopedDisableResize::disable_resize_ = false;
if ((self = [super init])) {
shell_ = shell;
is_zooming_ = false;
level_ = [shell_->GetNativeWindow() level];
}
return self;
}
@ -301,11 +303,19 @@ bool ScopedDisableResize::disable_resize_ = false;
shell_->NotifyWindowMoved();
}
- (void)windowWillMiniaturize:(NSNotification*)notification {
NSWindow* window = shell_->GetNativeWindow();
// store the current status window level to be restored in windowDidDeminiaturize
level_ = [window level];
[window setLevel:NSNormalWindowLevel];
}
- (void)windowDidMiniaturize:(NSNotification*)notification {
shell_->NotifyWindowMinimize();
}
- (void)windowDidDeminiaturize:(NSNotification*)notification {
[shell_->GetNativeWindow() setLevel:level_];
shell_->NotifyWindowRestore();
}

View file

@ -615,6 +615,22 @@ describe('BrowserWindow module', function () {
})
})
describe('BrowserWindow.alwaysOnTop() resets level on minimize', function () {
if (process.platform !== 'darwin') {
return
}
it('resets the windows level on minimize', function () {
assert.equal(w.isAlwaysOnTop(), false)
w.setAlwaysOnTop(true, 'screen-saver')
assert.equal(w.isAlwaysOnTop(), true)
w.minimize()
assert.equal(w.isAlwaysOnTop(), false)
w.restore()
assert.equal(w.isAlwaysOnTop(), true)
})
})
describe('BrowserWindow.setAutoHideCursor(autoHide)', () => {
if (process.platform !== 'darwin') {
it('is not available on non-macOS platforms', () => {