diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index fad4141775..5410345ab5 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -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) { + auto window = static_cast(window_.get()); + return window->taskbar_host().SetThumbnailToolTip( + window_->GetAcceleratedWidget(), tooltip); +} #endif #if defined(TOOLKIT_VIEWS) @@ -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) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index e027ceabc7..e9aeaac0cd 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -180,6 +180,7 @@ class Window : public mate::TrackableObject, void UnhookWindowMessage(UINT message); void UnhookAllWindowMessages(); bool SetThumbnailClip(const gfx::Rect& region); + bool SetThumbnailToolTip(const std::string& tooltip); #endif #if defined(TOOLKIT_VIEWS) diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index 8fef5e08a3..adc41cf1fb 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -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]; diff --git a/atom/browser/ui/win/taskbar_host.h b/atom/browser/ui/win/taskbar_host.h index c10e05f764..fb87ab4a69 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -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); diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 22ad3a8c4f..a4d149b2bc 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -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()`.