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 1 commit
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
8 changes: 8 additions & 0 deletions atom/browser/api/atom_api_top_level_window.cc
Expand Up @@ -262,6 +262,14 @@ void TopLevelWindow::OnWindowLeaveHtmlFullScreen() {
Emit("leave-html-full-screen");
}

void TopLevelWindow::OnWindowEnterAlwaysOnTop() {
Emit("enter-always-on-top");
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if enter and leave are the right semantics here, maybe always-on-top-changed with a single param alwaysOnTop which is a boolean.

Enter and leave make sense for fullscreen because it's a mode you "enter" and you don't really "enter" always on top. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm...i see what you mean 🤔

is there an alt nomenclature you'd prefer to see?

Copy link
Member

Choose a reason for hiding this comment

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

  • always-on-top-changed
  • is-always-on-top / not-always-on-top 🤔

I prefer the first one

Copy link
Member

Choose a reason for hiding this comment

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

👍 for always-on-top-changed with an arg, similar to what we do for accessibility-support-changed

}

void TopLevelWindow::OnWindowLeaveAlwaysOnTop() {
Emit("leave-always-on-top");
}

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

void NativeWindow::NotifyWindowEnterAlwaysOnTop() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowEnterAlwaysOnTop();
}

void NativeWindow::NotifyWindowLeaveAlwaysOnTop() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowLeaveAlwaysOnTop();
}

void NativeWindow::NotifyWindowExecuteWindowsCommand(
const std::string& command) {
for (NativeWindowObserver& observer : observers_)
Expand Down
2 changes: 2 additions & 0 deletions atom/browser/native_window.h
Expand Up @@ -254,6 +254,8 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowLeaveFullScreen();
void NotifyWindowEnterHtmlFullScreen();
void NotifyWindowLeaveHtmlFullScreen();
void NotifyWindowEnterAlwaysOnTop();
void NotifyWindowLeaveAlwaysOnTop();
void NotifyWindowExecuteWindowsCommand(const std::string& command);
void NotifyTouchBarItemInteraction(const std::string& item_id,
const base::DictionaryValue& details);
Expand Down
2 changes: 2 additions & 0 deletions atom/browser/native_window_observer.h
Expand Up @@ -83,6 +83,8 @@ class NativeWindowObserver {
virtual void OnWindowLeaveFullScreen() {}
virtual void OnWindowEnterHtmlFullScreen() {}
virtual void OnWindowLeaveHtmlFullScreen() {}
virtual void OnWindowEnterAlwaysOnTop() {}
virtual void OnWindowLeaveAlwaysOnTop() {}
virtual void OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) {}
virtual void OnNewWindowForTab() {}
Expand Down
6 changes: 6 additions & 0 deletions atom/browser/native_window_views.cc
Expand Up @@ -706,6 +706,12 @@ void NativeWindowViews::SetAlwaysOnTop(bool top,
const std::string& level,
int relativeLevel,
std::string* error) {
if (top) {
NativeWindow::NotifyWindowEnterAlwaysOnTop();
} else {
NativeWindow::NotifyWindowLeaveAlwaysOnTop();
}

widget()->SetAlwaysOnTop(top);
}

Expand Down