зеркало из https://github.com/electron/electron.git
use kCGMinimumWindowLevelKey to get the minimum level
This commit is contained in:
Родитель
b67d515a76
Коммит
edbb786fb4
|
@ -1060,6 +1060,7 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level, int rel
|
||||||
std::string* error) {
|
std::string* error) {
|
||||||
int windowLevel = NSNormalWindowLevel;
|
int windowLevel = NSNormalWindowLevel;
|
||||||
CGWindowLevel maxWindowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
|
CGWindowLevel maxWindowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
|
||||||
|
CGWindowLevel minWindowLevel = CGWindowLevelForKey(kCGMinimumWindowLevelKey);
|
||||||
|
|
||||||
if (top) {
|
if (top) {
|
||||||
if (level == "floating") {
|
if (level == "floating") {
|
||||||
|
@ -1083,12 +1084,12 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level, int rel
|
||||||
}
|
}
|
||||||
|
|
||||||
NSInteger newLevel = windowLevel + relativeLevel;
|
NSInteger newLevel = windowLevel + relativeLevel;
|
||||||
|
if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) {
|
||||||
if (newLevel >= 0 && newLevel <= maxWindowLevel) {
|
|
||||||
[window_ setLevel:newLevel];
|
[window_ setLevel:newLevel];
|
||||||
} else {
|
} else {
|
||||||
*error = std::string([[NSString stringWithFormat:
|
*error = std::string([[NSString stringWithFormat:
|
||||||
@"relativeLevel must be between 0 and %d", maxWindowLevel] UTF8String]);
|
@"relativeLevel must be between %d and %d", minWindowLevel,
|
||||||
|
maxWindowLevel] UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -518,7 +518,7 @@ describe('BrowserWindow module', function () {
|
||||||
if (process.platform !== 'darwin') return
|
if (process.platform !== 'darwin') return
|
||||||
|
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
w.setAlwaysOnTop(true, '', -1)
|
w.setAlwaysOnTop(true, '', -2147483644)
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче