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

Add BrowserWindow.prototype.setThumbnailToolTip #6762

Merged
merged 1 commit into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions atom/browser/api/atom_api_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,12 @@ bool Window::SetThumbnailClip(const gfx::Rect& region) {
return window->taskbar_host().SetThumbnailClip(
window_->GetAcceleratedWidget(), region);
}

bool Window::SetThumbnailToolTip(const std::string& tooltip) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can pass const base::string16& directly here, which is more efficient than converting std::string to UTF16 later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other methods also take std::string, I can create another PR to refactor all of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

auto window = static_cast<NativeWindowViews*>(window_.get());
return window->taskbar_host().SetThumbnailToolTip(
window_->GetAcceleratedWidget(), tooltip);
}
#endif

#if defined(TOOLKIT_VIEWS)
Expand Down Expand Up @@ -858,6 +864,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("unhookWindowMessage", &Window::UnhookWindowMessage)
.SetMethod("unhookAllWindowMessages", &Window::UnhookAllWindowMessages)
.SetMethod("setThumbnailClip", &Window::SetThumbnailClip)
.SetMethod("setThumbnailToolTip", &Window::SetThumbnailToolTip)
#endif
#if defined(TOOLKIT_VIEWS)
.SetMethod("setIcon", &Window::SetIcon)
Expand Down
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class Window : public mate::TrackableObject<Window>,
void UnhookWindowMessage(UINT message);
void UnhookAllWindowMessages();
bool SetThumbnailClip(const gfx::Rect& region);
bool SetThumbnailToolTip(const std::string& tooltip);
#endif

#if defined(TOOLKIT_VIEWS)
Expand Down
9 changes: 9 additions & 0 deletions atom/browser/ui/win/taskbar_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) {
}
}

bool TaskbarHost::SetThumbnailToolTip(
HWND window, const std::string& tooltip) {
if (!InitializeTaskbar())
return false;

return SUCCEEDED(taskbar_->SetThumbnailTooltip(
window, base::UTF8ToUTF16(tooltip).c_str()));
}

bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {
if (ContainsKey(callback_map_, button_id)) {
auto callback = callback_map_[button_id];
Expand Down
5 changes: 4 additions & 1 deletion atom/browser/ui/win/taskbar_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class TaskbarHost {
HWND window, const gfx::Image& overlay, const std::string& text);

// Set the region of the window to show as a thumbnail in taskbar.
bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region);
bool SetThumbnailClip(HWND window, const gfx::Rect& region);

// Set the tooltip for the thumbnail in taskbar.
bool SetThumbnailToolTip(HWND window, const std::string& tooltip);

// Called by the window that there is a button in thumbar clicked.
bool HandleThumbarButtonEvent(int button_id);
Expand Down
7 changes: 7 additions & 0 deletions docs/api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,13 @@ hovering over the window in the taskbar. You can reset the thumbnail to be
the entire window by specifying an empty region:
`{x: 0, y: 0, width: 0, height: 0}`.

#### `win.setThumbnailToolTip(toolTip)` _Windows_

* `toolTip` String

Sets the toolTip that is displayed when hovering over the window thumbnail
in the taskbar.

#### `win.showDefinitionForSelection()` _macOS_

Same as `webContents.showDefinitionForSelection()`.
Expand Down