diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index b2a15f9855a..02a0d8a2401 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -262,6 +262,10 @@ void TopLevelWindow::OnWindowLeaveHtmlFullScreen() { Emit("leave-html-full-screen"); } +void TopLevelWindow::OnWindowAlwaysOnTopChanged() { + Emit("always-on-top-changed", IsAlwaysOnTop()); +} + void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) { Emit("app-command", command_name); } diff --git a/atom/browser/api/atom_api_top_level_window.h b/atom/browser/api/atom_api_top_level_window.h index 7950d4c6a33..809efaa5979 100644 --- a/atom/browser/api/atom_api_top_level_window.h +++ b/atom/browser/api/atom_api_top_level_window.h @@ -77,6 +77,7 @@ class TopLevelWindow : public mate::TrackableObject, void OnWindowLeaveFullScreen() override; void OnWindowEnterHtmlFullScreen() override; void OnWindowLeaveHtmlFullScreen() override; + void OnWindowAlwaysOnTopChanged() override; void OnExecuteWindowsCommand(const std::string& command_name) override; void OnTouchBarItemResult(const std::string& item_id, const base::DictionaryValue& details) override; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 464bdae7fa3..ab575e4f58e 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -537,6 +537,11 @@ void NativeWindow::NotifyWindowLeaveHtmlFullScreen() { observer.OnWindowLeaveHtmlFullScreen(); } +void NativeWindow::NotifyWindowAlwaysOnTopChanged() { + for (NativeWindowObserver& observer : observers_) + observer.OnWindowAlwaysOnTopChanged(); +} + void NativeWindow::NotifyWindowExecuteWindowsCommand( const std::string& command) { for (NativeWindowObserver& observer : observers_) diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index a41e94595ee..d0de62249f1 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -254,6 +254,7 @@ class NativeWindow : public base::SupportsUserData, void NotifyWindowLeaveFullScreen(); void NotifyWindowEnterHtmlFullScreen(); void NotifyWindowLeaveHtmlFullScreen(); + void NotifyWindowAlwaysOnTopChanged(); void NotifyWindowExecuteWindowsCommand(const std::string& command); void NotifyTouchBarItemInteraction(const std::string& item_id, const base::DictionaryValue& details); diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index e14332b9f0b..dde449637d5 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -83,6 +83,7 @@ class NativeWindowObserver { virtual void OnWindowLeaveFullScreen() {} virtual void OnWindowEnterHtmlFullScreen() {} virtual void OnWindowLeaveHtmlFullScreen() {} + virtual void OnWindowAlwaysOnTopChanged() {} virtual void OnTouchBarItemResult(const std::string& item_id, const base::DictionaryValue& details) {} virtual void OnNewWindowForTab() {} diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 9664d175440..8f3d9a2dc70 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -706,6 +706,9 @@ void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level, int relativeLevel, std::string* error) { + if (top != widget()->IsAlwaysOnTop()) + NativeWindow::NotifyWindowAlwaysOnTopChanged(); + widget()->SetAlwaysOnTop(top); } diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 49b18522feb..10d3a40aaff 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -542,6 +542,15 @@ 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_ + +Returns: + +* `event` Event +* `isAlwaysOnTop` Boolean + +Emitted when the window is set or unset to show always on top of other windows. + #### Event: 'app-command' _Windows_ Returns: