Merge pull request #6497 from electron/windows-thumbnail
Add setThumbnailClip API on Windows
This commit is contained in:
commit
d186a01815
5 changed files with 39 additions and 0 deletions
|
@ -649,6 +649,12 @@ bool Window::IsWindowMessageHooked(UINT message) {
|
|||
void Window::UnhookAllWindowMessages() {
|
||||
messages_callback_map_.clear();
|
||||
}
|
||||
|
||||
bool Window::SetThumbnailClip(const gfx::Rect& region) {
|
||||
auto window = static_cast<NativeWindowViews*>(window_.get());
|
||||
return window->taskbar_host().SetThumbnailClip(
|
||||
window_->GetAcceleratedWidget(), region);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
|
@ -836,6 +842,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("isWindowMessageHooked", &Window::IsWindowMessageHooked)
|
||||
.SetMethod("unhookWindowMessage", &Window::UnhookWindowMessage)
|
||||
.SetMethod("unhookAllWindowMessages", &Window::UnhookAllWindowMessages)
|
||||
.SetMethod("setThumbnailClip", &Window::SetThumbnailClip)
|
||||
#endif
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
.SetMethod("setIcon", &Window::SetIcon)
|
||||
|
|
|
@ -179,6 +179,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||
bool IsWindowMessageHooked(UINT message);
|
||||
void UnhookWindowMessage(UINT message);
|
||||
void UnhookAllWindowMessages();
|
||||
bool SetThumbnailClip(const gfx::Rect& region);
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
|
|
|
@ -142,6 +142,22 @@ bool TaskbarHost::SetOverlayIcon(
|
|||
window, icon.get(), base::UTF8ToUTF16(text).c_str()));
|
||||
}
|
||||
|
||||
bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) {
|
||||
if (!InitializeTaskbar())
|
||||
return false;
|
||||
|
||||
if (region.IsEmpty()) {
|
||||
return SUCCEEDED(taskbar_->SetThumbnailClip(window, NULL));
|
||||
} else {
|
||||
RECT rect;
|
||||
rect.left = region.x();
|
||||
rect.right = region.right();
|
||||
rect.top = region.y();
|
||||
rect.bottom = region.bottom();
|
||||
return SUCCEEDED(taskbar_->SetThumbnailClip(window, &rect));
|
||||
}
|
||||
}
|
||||
|
||||
bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {
|
||||
if (ContainsKey(callback_map_, button_id)) {
|
||||
auto callback = callback_map_[button_id];
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "base/callback.h"
|
||||
#include "base/win/scoped_comptr.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -40,6 +41,9 @@ class TaskbarHost {
|
|||
bool SetOverlayIcon(
|
||||
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);
|
||||
|
||||
// Called by the window that there is a button in thumbar clicked.
|
||||
bool HandleThumbarButtonEvent(int button_id);
|
||||
|
||||
|
|
|
@ -985,6 +985,17 @@ The `flags` is an array that can include following `String`s:
|
|||
button state is drawn. This value is intended for instances where the button
|
||||
is used in a notification.
|
||||
|
||||
#### `win.setThumbnailClip(region)` _Windows_
|
||||
|
||||
* `region` - Object
|
||||
* `x` Integer - x-position of region
|
||||
* `y` Integer - y-position of region
|
||||
* `width` Integer - width of region
|
||||
* `height` Integer - height of region
|
||||
|
||||
Sets the region of the window to show as the thumbnail image displayed when
|
||||
hovering over the window in the taskbar.
|
||||
|
||||
#### `win.showDefinitionForSelection()` _macOS_
|
||||
|
||||
Same as `webContents.showDefinitionForSelection()`.
|
||||
|
|
Loading…
Reference in a new issue