feat: emit always-on-top-changed on macOS (#19462)
* feat: emit always-on-top-changed on macOS * update event emission test for macos
This commit is contained in:
parent
50c7eb58a1
commit
6c9d40ec33
3 changed files with 8 additions and 3 deletions
|
@ -553,7 +553,7 @@ Emitted when the window enters a full-screen state triggered by HTML API.
|
|||
|
||||
Emitted when the window leaves a full-screen state triggered by HTML API.
|
||||
|
||||
#### Event: 'always-on-top-changed' _macOS_
|
||||
#### Event: 'always-on-top-changed'
|
||||
|
||||
Returns:
|
||||
|
||||
|
@ -1182,7 +1182,6 @@ On Linux always returns `true`.
|
|||
placed below the Dock on macOS and below the taskbar on Windows. From
|
||||
`pop-up-menu` to a higher it is shown above the Dock on macOS and above the
|
||||
taskbar on Windows. See the [macOS docs][window-levels] for more details.
|
||||
|
||||
* `relativeLevel` Integer (optional) _macOS_ - The number of layers higher to set
|
||||
this window relative to the given `level`. The default is `0`. Note that Apple
|
||||
discourages setting levels higher than 1 above `screen-saver`.
|
||||
|
|
|
@ -810,6 +810,7 @@ void NativeWindowMac::SetAlwaysOnTop(ui::ZOrderLevel z_order,
|
|||
int relativeLevel,
|
||||
std::string* error) {
|
||||
int windowLevel = NSNormalWindowLevel;
|
||||
bool level_changed = z_order != widget()->GetZOrderLevel();
|
||||
CGWindowLevel maxWindowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
|
||||
CGWindowLevel minWindowLevel = CGWindowLevelForKey(kCGMinimumWindowLevelKey);
|
||||
|
||||
|
@ -847,6 +848,11 @@ void NativeWindowMac::SetAlwaysOnTop(ui::ZOrderLevel z_order,
|
|||
stringWithFormat:@"relativeLevel must be between %d and %d",
|
||||
minWindowLevel, maxWindowLevel] UTF8String]);
|
||||
}
|
||||
|
||||
// This must be notified at the very end or IsAlwaysOnTop
|
||||
// will not yet have been updated to reflect the new status
|
||||
if (level_changed)
|
||||
NativeWindow::NotifyWindowAlwaysOnTopChanged();
|
||||
}
|
||||
|
||||
ui::ZOrderLevel NativeWindowMac::GetZOrderLevel() {
|
||||
|
|
|
@ -1080,7 +1080,7 @@ describe('BrowserWindow module', () => {
|
|||
expect(w.isAlwaysOnTop()).to.be.true('is not alwaysOnTop')
|
||||
})
|
||||
|
||||
ifit(process.platform !== 'darwin')('causes the right value to be emitted on `always-on-top-changed`', (done) => {
|
||||
it('causes the right value to be emitted on `always-on-top-changed`', (done) => {
|
||||
w.on('always-on-top-changed', (e, alwaysOnTop) => {
|
||||
expect(alwaysOnTop).to.be.true('is not alwaysOnTop')
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue