Add BrowserWindow.prototype.setThumbnailToolTip
authorMilan Burda <milan.burda@gmail.com>
Sun, 7 Aug 2016 17:23:42 +0000 (19:23 +0200)
committerMilan Burda <milan.burda@gmail.com>
Mon, 8 Aug 2016 10:05:47 +0000 (12:05 +0200)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/ui/win/taskbar_host.cc
atom/browser/ui/win/taskbar_host.h
docs/api/browser-window.md

index fad4141..5410345 100644 (file)
@@ -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<NativeWindowViews*>(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)
index e027cea..e9aeaac 100644 (file)
@@ -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)
index 8fef5e0..adc41cf 100644 (file)
@@ -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];
index c10e05f..fb87ab4 100644 (file)
@@ -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);
index 22ad3a8..a4d149b 100644 (file)
@@ -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()`.