Skip to content
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
11 changes: 11 additions & 0 deletions bindings/csharp/src/CNativeAPI/generated/WindowTaskbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public static partial class Interop
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool native_window_taskbar_remove_thumbnail_button_by_id(ulong self, uint buttonId);

[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool native_window_taskbar_reset_thumbnail(ulong self);

[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool native_window_taskbar_set_overlay_icon(ulong self, ulong icon, [MarshalAs(UnmanagedType.LPUTF8Str)] string? description);
Expand All @@ -112,6 +116,10 @@ public static partial class Interop
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool native_window_taskbar_set_progress_value(ulong self, double progress);

[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool native_window_taskbar_set_thumbnail(ulong self, ulong thumbnail);

[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool native_window_taskbar_start_flashing(ulong self, native_taskbar_flash_options_t options);
Expand Down Expand Up @@ -159,6 +167,9 @@ public static partial class Interop
[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong native_window_taskbar_get_overlay_icon(ulong self);

[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong native_window_taskbar_get_thumbnail(ulong self);

[DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong native_window_taskbar_get_thumbnail_button_at(ulong self, CULong index);

Expand Down
21 changes: 21 additions & 0 deletions bindings/csharp/src/NativeAPI/WindowTaskbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ public string? OverlayIconDescription
}
}

public bool SetThumbnail(Image? thumbnail)
{
var rawResult = Interop.native_window_taskbar_set_thumbnail(NativeHandle, thumbnail?.NativeHandle ?? 0);
return rawResult;
}

public Image? Thumbnail
{
get
{
var rawResult = Interop.native_window_taskbar_get_thumbnail(NativeHandle);
return rawResult == 0 ? null : new Image(rawResult);
}
}

public bool ResetThumbnail()
{
var rawResult = Interop.native_window_taskbar_reset_thumbnail(NativeHandle);
return rawResult;
}

public bool AddThumbnailButton(TaskbarThumbnailButton? button)
{
var rawResult = Interop.native_window_taskbar_add_thumbnail_button(NativeHandle, button?.NativeHandle ?? 0);
Expand Down
13 changes: 13 additions & 0 deletions bindings/dart/cnativeapi/lib/src/bindings_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4066,6 +4066,10 @@ native_taskbar_progress_state_t native_window_taskbar_get_progress_state(
@ffi.Native<ffi.Double Function(native_window_taskbar_t)>()
external double native_window_taskbar_get_progress_value(int window_taskbar);

/// Caller owns the returned handle; release it with native_image_free().
@ffi.Native<native_image_t$2 Function(native_window_taskbar_t)>()
external int native_window_taskbar_get_thumbnail(int window_taskbar);

/// Caller owns the returned handle; release it with native_taskbar_thumbnail_button_free().
@ffi.Native<
native_taskbar_thumbnail_button_t Function(
Expand Down Expand Up @@ -4143,6 +4147,9 @@ external bool native_window_taskbar_remove_thumbnail_button_by_id(
int button_id,
);

@ffi.Native<ffi.Bool Function(native_window_taskbar_t)>()
external bool native_window_taskbar_reset_thumbnail(int window_taskbar);

@ffi.Native<
ffi.Bool Function(
native_window_taskbar_t,
Expand Down Expand Up @@ -4177,6 +4184,12 @@ external bool native_window_taskbar_set_progress_value(
double progress,
);

@ffi.Native<ffi.Bool Function(native_window_taskbar_t, native_image_t$2)>()
external bool native_window_taskbar_set_thumbnail(
int window_taskbar,
int thumbnail,
);

@ffi.Native<
ffi.Bool Function(native_window_taskbar_t, native_taskbar_flash_options_t)
>()
Expand Down
6 changes: 6 additions & 0 deletions bindings/dart/nativeapi/lib/src/web/window_taskbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class WindowTaskbar {

String? get overlayIconDescription => unsupported();

bool setThumbnail(Image? thumbnail) => unsupported();

Image? get thumbnail => unsupported();

bool resetThumbnail() => unsupported();

bool addThumbnailButton(TaskbarThumbnailButton? button) => unsupported();

bool insertThumbnailButton(int index, TaskbarThumbnailButton? button) =>
Expand Down
17 changes: 17 additions & 0 deletions bindings/dart/nativeapi/lib/src/window_taskbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,23 @@ class WindowTaskbar implements ffi.Finalizable {
return result;
}

bool setThumbnail(Image? thumbnail) {
return c.native_window_taskbar_set_thumbnail(
nativeHandle,
thumbnail?.nativeHandle ?? 0,
);
}

Image? get thumbnail {
final handle = c.native_window_taskbar_get_thumbnail(nativeHandle);
if (handle == 0) return null;
return Image.fromHandle(handle);
}

bool resetThumbnail() {
return c.native_window_taskbar_reset_thumbnail(nativeHandle);
}

bool addThumbnailButton(TaskbarThumbnailButton? button) {
return c.native_window_taskbar_add_thumbnail_button(
nativeHandle,
Expand Down
27 changes: 27 additions & 0 deletions bindings/go/nativeapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions bindings/js/lib/window_taskbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ export class WindowTaskbar extends NativeObject {
return native.native_window_taskbar_get_overlay_icon_description(this.nativeHandle);
}

setThumbnail(thumbnail: Image | null): boolean {
return native.native_window_taskbar_set_thumbnail(this.nativeHandle, thumbnail?.nativeHandle ?? 0n);
}

get thumbnail(): Image | null {
return wrapHandle(Image, native.native_window_taskbar_get_thumbnail(this.nativeHandle));
}

resetThumbnail(): boolean {
return native.native_window_taskbar_reset_thumbnail(this.nativeHandle);
}

addThumbnailButton(button: TaskbarThumbnailButton | null): boolean {
return native.native_window_taskbar_add_thumbnail_button(this.nativeHandle, button?.nativeHandle ?? 0n);
}
Expand Down
52 changes: 52 additions & 0 deletions bindings/js/src/generated/window_taskbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,55 @@ napi_value Js_native_window_taskbar_get_overlay_icon_description(napi_env env, n
return value.ToJs(env);
}

napi_value Js_native_window_taskbar_set_thumbnail(napi_env env, napi_callback_info info) {
Args args(env, info);
if (!args.ok()) {
return nullptr;
}
Arena arena;
(void)arena;
uint64_t self = 0;
if (!GetHandle(env, args[0], &self)) {
return nullptr;
}
native_image_t p0 = {};
if (!GetHandle(env, args[1], &p0)) {
return nullptr;
}
auto result = OnMainThread([&] { return native_window_taskbar_set_thumbnail(self, p0); });
return Value::Bool(result).ToJs(env);
}

napi_value Js_native_window_taskbar_get_thumbnail(napi_env env, napi_callback_info info) {
Args args(env, info);
if (!args.ok()) {
return nullptr;
}
Arena arena;
(void)arena;
uint64_t self = 0;
if (!GetHandle(env, args[0], &self)) {
return nullptr;
}
auto result = OnMainThread([&] { return native_window_taskbar_get_thumbnail(self); });
return Value::BigInt(result).ToJs(env);
}

napi_value Js_native_window_taskbar_reset_thumbnail(napi_env env, napi_callback_info info) {
Args args(env, info);
if (!args.ok()) {
return nullptr;
}
Arena arena;
(void)arena;
uint64_t self = 0;
if (!GetHandle(env, args[0], &self)) {
return nullptr;
}
auto result = OnMainThread([&] { return native_window_taskbar_reset_thumbnail(self); });
return Value::Bool(result).ToJs(env);
}

napi_value Js_native_window_taskbar_add_thumbnail_button(napi_env env, napi_callback_info info) {
Args args(env, info);
if (!args.ok()) {
Expand Down Expand Up @@ -787,6 +836,9 @@ void RegisterWindowTaskbar(napi_env env, napi_value exports) {
Export(env, exports, "native_window_taskbar_set_overlay_icon", Js_native_window_taskbar_set_overlay_icon);
Export(env, exports, "native_window_taskbar_get_overlay_icon", Js_native_window_taskbar_get_overlay_icon);
Export(env, exports, "native_window_taskbar_get_overlay_icon_description", Js_native_window_taskbar_get_overlay_icon_description);
Export(env, exports, "native_window_taskbar_set_thumbnail", Js_native_window_taskbar_set_thumbnail);
Export(env, exports, "native_window_taskbar_get_thumbnail", Js_native_window_taskbar_get_thumbnail);
Export(env, exports, "native_window_taskbar_reset_thumbnail", Js_native_window_taskbar_reset_thumbnail);
Export(env, exports, "native_window_taskbar_add_thumbnail_button", Js_native_window_taskbar_add_thumbnail_button);
Export(env, exports, "native_window_taskbar_insert_thumbnail_button", Js_native_window_taskbar_insert_thumbnail_button);
Export(env, exports, "native_window_taskbar_remove_thumbnail_button", Js_native_window_taskbar_remove_thumbnail_button);
Expand Down
22 changes: 22 additions & 0 deletions bindings/python/nativeapi/_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,28 @@ class native_window_list_t(Structure):
c_uint64,
],
)
native_window_taskbar_set_thumbnail = function(
"native_window_taskbar_set_thumbnail",
c_bool,
[
c_uint64,
c_uint64,
],
)
native_window_taskbar_get_thumbnail = function(
"native_window_taskbar_get_thumbnail",
c_uint64,
[
c_uint64,
],
)
native_window_taskbar_reset_thumbnail = function(
"native_window_taskbar_reset_thumbnail",
c_bool,
[
c_uint64,
],
)
native_window_taskbar_add_thumbnail_button = function(
"native_window_taskbar_add_thumbnail_button",
c_bool,
Expand Down
16 changes: 16 additions & 0 deletions bindings/python/nativeapi/window_taskbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ def overlay_icon_description(self) -> str:
raw = _C.native_window_taskbar_get_overlay_icon_description(self._handle)
return _rt.take_str(raw)

def set_thumbnail(self, thumbnail: _image.Image | None) -> bool:
raw = _C.native_window_taskbar_set_thumbnail(
self._handle,
_rt.handle_of(thumbnail),
)
return raw

@property
def thumbnail(self) -> _image.Image | None:
raw = _C.native_window_taskbar_get_thumbnail(self._handle)
return _image.Image._owned(raw)

def reset_thumbnail(self) -> bool:
raw = _C.native_window_taskbar_reset_thumbnail(self._handle)
return raw

def add_thumbnail_button(self, button: TaskbarThumbnailButton | None) -> bool:
raw = _C.native_window_taskbar_add_thumbnail_button(
self._handle,
Expand Down
15 changes: 15 additions & 0 deletions bindings/rust/cnativeapi/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,21 @@ unsafe extern "C" {
window_taskbar: native_window_taskbar_t,
) -> *mut ::std::os::raw::c_char;
}
unsafe extern "C" {
pub fn native_window_taskbar_set_thumbnail(
window_taskbar: native_window_taskbar_t,
thumbnail: native_image_t,
) -> bool;
}
unsafe extern "C" {
#[doc = " Caller owns the returned handle; release it with native_image_free()."]
pub fn native_window_taskbar_get_thumbnail(
window_taskbar: native_window_taskbar_t,
) -> native_image_t;
}
unsafe extern "C" {
pub fn native_window_taskbar_reset_thumbnail(window_taskbar: native_window_taskbar_t) -> bool;
}
unsafe extern "C" {
pub fn native_window_taskbar_add_thumbnail_button(
window_taskbar: native_window_taskbar_t,
Expand Down
18 changes: 18 additions & 0 deletions bindings/rust/nativeapi/src/window_taskbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@ impl WindowTaskbar {
}
}

pub fn set_thumbnail(&self, thumbnail: Option<&Image>) -> bool {
unsafe {
cnativeapi::native_window_taskbar_set_thumbnail(self.handle, thumbnail.map_or(0, |value| value.as_raw()))
}
}

pub fn thumbnail(&self) -> Option<Image> {
unsafe {
Image::from_raw(cnativeapi::native_window_taskbar_get_thumbnail(self.handle))
}
}

pub fn reset_thumbnail(&self) -> bool {
unsafe {
cnativeapi::native_window_taskbar_reset_thumbnail(self.handle)
}
}

pub fn add_thumbnail_button(&self, button: Option<&TaskbarThumbnailButton>) -> bool {
unsafe {
cnativeapi::native_window_taskbar_add_thumbnail_button(self.handle, button.map_or(0, |value| value.as_raw()))
Expand Down
14 changes: 14 additions & 0 deletions bindings/swift/Sources/NativeAPI/WindowTaskbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,20 @@ public class WindowTaskbar {
return String(cString: value)
}

public func setThumbnail(_ thumbnail: Image?) -> Bool {
return native_window_taskbar_set_thumbnail(nativeHandle, thumbnail?.nativeHandle ?? 0)
}

public var thumbnail: Image? {
let handle = native_window_taskbar_get_thumbnail(nativeHandle)
guard handle != NATIVE_INVALID_IMAGE else { return nil }
return Image(nativeHandle: handle)
}

public func resetThumbnail() -> Bool {
return native_window_taskbar_reset_thumbnail(nativeHandle)
}

public func addThumbnailButton(_ button: TaskbarThumbnailButton?) -> Bool {
return native_window_taskbar_add_thumbnail_button(nativeHandle, button?.nativeHandle ?? 0)
}
Expand Down
9 changes: 8 additions & 1 deletion specs/window-taskbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> 核实基准:2026-12-01

`WindowTaskbar` 控制单个顶层窗口在操作系统任务栏上的表现:5 态进度条、自定义叠加图标、
缩略图工具栏(最多 7 个可交互按钮)以及闪烁提醒。
自定义缩略图(保留 Aero Peek 实时预览)、缩略图工具栏(最多 7 个可交互按钮)以及闪烁提醒。

窗口是否出现在任务栏上由既有 `Window::SetVisibleInTaskbar()` / `IsVisibleInTaskbar()`
管理;窗口标题由 `Window::SetTitle()` / `GetTitle()` 管理;跨平台应用级 Dock/Launcher
Expand Down Expand Up @@ -38,6 +38,13 @@
- **叠加图标**:`SetOverlayIcon(image, description)` 接收 `std::shared_ptr<Image>`(`nullptr`
清除)和无障碍描述。Windows 上与 `Application::SetBadgeLabel()` 共享同一 `HWND` 的叠加
槽位,遵循后写入生效语义。
- **自定义缩略图**:`SetThumbnail(image)` 接收 `std::shared_ptr<Image>`(`nullptr` 还原为系统
默认),`GetThumbnail()` 返回当前自定义缩略图,`ResetThumbnail()` 等价于 `SetThumbnail(nullptr)`。
Windows 上通过 DWM `DWMWA_FORCE_ICONIC_REPRESENTATION` / `DWMWA_HAS_ICONIC_BITMAP` 响应
`WM_DWMSENDICONICTHUMBNAIL`(按比例缩放并铺不透明底色后调用 `DwmSetIconicThumbnail`),同时
响应 `WM_DWMSENDICONICLIVEPREVIEWBITMAP`(窗口可见时用 `PrintWindow(..., PW_RENDERFULLCONTENT)`
并按 `DWMWA_EXTENDED_FRAME_BOUNDS` 裁剪抓取真实画面,最小化或抓取失败时以深色底居中合成封面
兜底,再调用 `DwmSetIconicLivePreviewBitmap`),从而在自定义缩略图时保留 Aero Peek 实时预览。
- **缩略图工具栏**:集合方法遵循 `Menu` 约定(`AddThumbnailButton` / `InsertThumbnailButton` /
`RemoveThumbnailButton*` / `ClearThumbnailButtons` / `GetAllThumbnailButtons`),上限 7 个
按钮(`WindowTaskbar::GetMaxThumbnailButtonCount()`)。不采用 `vector<shared_ptr>` 入参以
Expand Down
Loading
Loading