diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 589accfedb..57f8eae1af 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1060,6 +1060,7 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level, int rel std::string* error) { int windowLevel = NSNormalWindowLevel; CGWindowLevel maxWindowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey); + CGWindowLevel minWindowLevel = CGWindowLevelForKey(kCGMinimumWindowLevelKey); if (top) { if (level == "floating") { @@ -1083,12 +1084,12 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level, int rel } NSInteger newLevel = windowLevel + relativeLevel; - - if (newLevel >= 0 && newLevel <= maxWindowLevel) { + if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) { [window_ setLevel:newLevel]; } else { *error = std::string([[NSString stringWithFormat: - @"relativeLevel must be between 0 and %d", maxWindowLevel] UTF8String]); + @"relativeLevel must be between %d and %d", minWindowLevel, + maxWindowLevel] UTF8String]); } } diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 2d52ec27e5..6666a41545 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -518,7 +518,7 @@ describe('BrowserWindow module', function () { if (process.platform !== 'darwin') return assert.throws(function () { - w.setAlwaysOnTop(true, '', -1) + w.setAlwaysOnTop(true, '', -2147483644) }) assert.throws(function () {