Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add evt listeners for SetAlwaysOnTop #14951

Merged
merged 5 commits into from Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions atom/browser/api/atom_api_top_level_window.cc
Expand Up @@ -262,6 +262,10 @@ void TopLevelWindow::OnWindowLeaveHtmlFullScreen() {
Emit("leave-html-full-screen");
}

void TopLevelWindow::OnWindowAlwaysOnTopChange() {
Emit("always-on-top-change", IsAlwaysOnTop());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/change/changed for consistency with accessibility-support-changed, accent-color-changed, cursor-changed, etc.

}

void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) {
Emit("app-command", command_name);
}
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_top_level_window.h
Expand Up @@ -77,6 +77,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
void OnWindowLeaveFullScreen() override;
void OnWindowEnterHtmlFullScreen() override;
void OnWindowLeaveHtmlFullScreen() override;
void OnWindowAlwaysOnTopChange() override;
void OnExecuteWindowsCommand(const std::string& command_name) override;
void OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) override;
Expand Down
5 changes: 5 additions & 0 deletions atom/browser/native_window.cc
Expand Up @@ -537,6 +537,11 @@ void NativeWindow::NotifyWindowLeaveHtmlFullScreen() {
observer.OnWindowLeaveHtmlFullScreen();
}

void NativeWindow::NotifyWindowAlwaysOnTopChange() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowAlwaysOnTopChange();
}

void NativeWindow::NotifyWindowExecuteWindowsCommand(
const std::string& command) {
for (NativeWindowObserver& observer : observers_)
Expand Down
1 change: 1 addition & 0 deletions atom/browser/native_window.h
Expand Up @@ -254,6 +254,7 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowLeaveFullScreen();
void NotifyWindowEnterHtmlFullScreen();
void NotifyWindowLeaveHtmlFullScreen();
void NotifyWindowAlwaysOnTopChange();
void NotifyWindowExecuteWindowsCommand(const std::string& command);
void NotifyTouchBarItemInteraction(const std::string& item_id,
const base::DictionaryValue& details);
Expand Down
1 change: 1 addition & 0 deletions atom/browser/native_window_observer.h
Expand Up @@ -83,6 +83,7 @@ class NativeWindowObserver {
virtual void OnWindowLeaveFullScreen() {}
virtual void OnWindowEnterHtmlFullScreen() {}
virtual void OnWindowLeaveHtmlFullScreen() {}
virtual void OnWindowAlwaysOnTopChange() {}
virtual void OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) {}
virtual void OnNewWindowForTab() {}
Expand Down
3 changes: 3 additions & 0 deletions atom/browser/native_window_views.cc
Expand Up @@ -706,6 +706,9 @@ void NativeWindowViews::SetAlwaysOnTop(bool top,
const std::string& level,
int relativeLevel,
std::string* error) {
if (top != widget()->IsAlwaysOnTop())
NativeWindow::NotifyWindowAlwaysOnTopChange();

widget()->SetAlwaysOnTop(top);
}

Expand Down
4 changes: 4 additions & 0 deletions docs/api/browser-window.md
Expand Up @@ -542,6 +542,10 @@ 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-change' _macOS_

Emitted when the window is set or unset to show always on top of other windows.
codebytere marked this conversation as resolved.
Show resolved Hide resolved

#### Event: 'app-command' _Windows_

Returns:
Expand Down