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
23 changes: 19 additions & 4 deletions examples/window_taskbar_example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ int main() {

auto window = std::make_shared<Window>();
window->SetTitle("WindowTaskbar Example");
window->SetContentSize(Size{620, 370});
window->SetMinimumSize(Size{540, 340});
window->SetContentSize(Size{620, 440});
window->SetMinimumSize(Size{540, 410});
window->Center();

auto taskbar = window->GetTaskbar();
Expand Down Expand Up @@ -198,8 +198,23 @@ int main() {
});
root->AddSubview(toolbar_row);

// --- Section 4: Flashing ---
auto flash_label = std::make_shared<Label>("4. Attention / Flashing");
// --- Section 4: Custom Thumbnail ---
auto thumb_label =
std::make_shared<Label>("4. Custom Thumbnail (retains Aero Peek live preview)");
root->AddSubview(thumb_label);
auto thumb_row = MakeRow();
AddButton(thumb_row, "Set Custom Thumbnail", [=] {
bool ok = taskbar->SetThumbnail(badge_icon);
set_status(ok ? "Custom thumbnail set (hover taskbar icon)" : "SetThumbnail failed");
});
AddButton(thumb_row, "Reset Thumbnail", [=] {
bool ok = taskbar->ResetThumbnail();
set_status(ok ? "Thumbnail reset to system default" : "ResetThumbnail failed");
});
root->AddSubview(thumb_row);

// --- Section 5: Flashing ---
auto flash_label = std::make_shared<Label>("5. Attention / Flashing");
root->AddSubview(flash_label);
auto flash_row = MakeRow();
AddButton(flash_row, "Flash 5x", [=] {
Expand Down
40 changes: 40 additions & 0 deletions src/capi/window_taskbar_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,46 @@ char* native_window_taskbar_get_overlay_icon_description(native_window_taskbar_t
}
}

bool native_window_taskbar_set_thumbnail(native_window_taskbar_t window_taskbar, native_image_t thumbnail) {
auto self = nativeapi::HandleTable::GetInstance().Resolve<nativeapi::WindowTaskbar>(window_taskbar);
if (!self) {
return false;
}
try {
auto thumbnail_cpp = nativeapi::HandleTable::GetInstance().Resolve<nativeapi::Image>(thumbnail);
return self->SetThumbnail(thumbnail_cpp);
} catch (...) {
fprintf(stderr, "[nativeapi] %s: unexpected exception\n", "native_window_taskbar_set_thumbnail");
return false;
}
}

native_image_t native_window_taskbar_get_thumbnail(native_window_taskbar_t window_taskbar) {
auto self = nativeapi::HandleTable::GetInstance().Resolve<nativeapi::WindowTaskbar>(window_taskbar);
if (!self) {
return 0;
}
try {
return nativeapi::HandleTable::GetInstance().Insert(self->GetThumbnail());
} catch (...) {
fprintf(stderr, "[nativeapi] %s: unexpected exception\n", "native_window_taskbar_get_thumbnail");
return 0;
}
}

bool native_window_taskbar_reset_thumbnail(native_window_taskbar_t window_taskbar) {
auto self = nativeapi::HandleTable::GetInstance().Resolve<nativeapi::WindowTaskbar>(window_taskbar);
if (!self) {
return false;
}
try {
return self->ResetThumbnail();
} catch (...) {
fprintf(stderr, "[nativeapi] %s: unexpected exception\n", "native_window_taskbar_reset_thumbnail");
return false;
}
}

bool native_window_taskbar_add_thumbnail_button(native_window_taskbar_t window_taskbar, native_taskbar_thumbnail_button_t button) {
auto self = nativeapi::HandleTable::GetInstance().Resolve<nativeapi::WindowTaskbar>(window_taskbar);
if (!self) {
Expand Down
10 changes: 10 additions & 0 deletions src/capi/window_taskbar_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ native_image_t native_window_taskbar_get_overlay_icon(native_window_taskbar_t wi
FFI_PLUGIN_EXPORT
char* native_window_taskbar_get_overlay_icon_description(native_window_taskbar_t window_taskbar);

FFI_PLUGIN_EXPORT
bool native_window_taskbar_set_thumbnail(native_window_taskbar_t window_taskbar, native_image_t thumbnail);

/// Caller owns the returned handle; release it with native_image_free().
FFI_PLUGIN_EXPORT
native_image_t native_window_taskbar_get_thumbnail(native_window_taskbar_t window_taskbar);

FFI_PLUGIN_EXPORT
bool native_window_taskbar_reset_thumbnail(native_window_taskbar_t window_taskbar);

FFI_PLUGIN_EXPORT
bool native_window_taskbar_add_thumbnail_button(native_window_taskbar_t window_taskbar, native_taskbar_thumbnail_button_t button);

Expand Down
4 changes: 4 additions & 0 deletions src/platform/android/window_taskbar_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ bool WindowTaskbar::Impl::SetOverlayIcon(std::shared_ptr<Image>, const std::stri
std::shared_ptr<Image> WindowTaskbar::Impl::GetOverlayIcon() const { return nullptr; }
std::string WindowTaskbar::Impl::GetOverlayIconDescription() const { return {}; }

bool WindowTaskbar::Impl::SetThumbnail(std::shared_ptr<Image>) { return false; }
std::shared_ptr<Image> WindowTaskbar::Impl::GetThumbnail() const { return nullptr; }
bool WindowTaskbar::Impl::ResetThumbnail() { return false; }

bool WindowTaskbar::Impl::AddThumbnailButton(std::shared_ptr<TaskbarThumbnailButton>) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/platform/ios/window_taskbar_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
std::shared_ptr<Image> WindowTaskbar::Impl::GetOverlayIcon() const { return nullptr; }
std::string WindowTaskbar::Impl::GetOverlayIconDescription() const { return {}; }

bool WindowTaskbar::Impl::SetThumbnail(std::shared_ptr<Image>) { return false; }
std::shared_ptr<Image> WindowTaskbar::Impl::GetThumbnail() const { return nullptr; }
bool WindowTaskbar::Impl::ResetThumbnail() { return false; }

bool WindowTaskbar::Impl::AddThumbnailButton(std::shared_ptr<TaskbarThumbnailButton>) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/platform/linux/window_taskbar_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ bool WindowTaskbar::Impl::SetOverlayIcon(std::shared_ptr<Image>, const std::stri
std::shared_ptr<Image> WindowTaskbar::Impl::GetOverlayIcon() const { return nullptr; }
std::string WindowTaskbar::Impl::GetOverlayIconDescription() const { return {}; }

bool WindowTaskbar::Impl::SetThumbnail(std::shared_ptr<Image>) { return false; }
std::shared_ptr<Image> WindowTaskbar::Impl::GetThumbnail() const { return nullptr; }
bool WindowTaskbar::Impl::ResetThumbnail() { return false; }

bool WindowTaskbar::Impl::AddThumbnailButton(std::shared_ptr<TaskbarThumbnailButton>) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/platform/macos/window_taskbar_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
std::shared_ptr<Image> WindowTaskbar::Impl::GetOverlayIcon() const { return nullptr; }
std::string WindowTaskbar::Impl::GetOverlayIconDescription() const { return {}; }

bool WindowTaskbar::Impl::SetThumbnail(std::shared_ptr<Image>) { return false; }
std::shared_ptr<Image> WindowTaskbar::Impl::GetThumbnail() const { return nullptr; }
bool WindowTaskbar::Impl::ResetThumbnail() { return false; }

bool WindowTaskbar::Impl::AddThumbnailButton(std::shared_ptr<TaskbarThumbnailButton>) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/platform/ohos/window_taskbar_ohos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ bool WindowTaskbar::Impl::SetOverlayIcon(std::shared_ptr<Image>, const std::stri
std::shared_ptr<Image> WindowTaskbar::Impl::GetOverlayIcon() const { return nullptr; }
std::string WindowTaskbar::Impl::GetOverlayIconDescription() const { return {}; }

bool WindowTaskbar::Impl::SetThumbnail(std::shared_ptr<Image>) { return false; }
std::shared_ptr<Image> WindowTaskbar::Impl::GetThumbnail() const { return nullptr; }
bool WindowTaskbar::Impl::ResetThumbnail() { return false; }

bool WindowTaskbar::Impl::AddThumbnailButton(std::shared_ptr<TaskbarThumbnailButton>) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/platform/wasm/window_taskbar_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ bool WindowTaskbar::Impl::SetOverlayIcon(std::shared_ptr<Image>, const std::stri
std::shared_ptr<Image> WindowTaskbar::Impl::GetOverlayIcon() const { return nullptr; }
std::string WindowTaskbar::Impl::GetOverlayIconDescription() const { return {}; }

bool WindowTaskbar::Impl::SetThumbnail(std::shared_ptr<Image>) { return false; }
std::shared_ptr<Image> WindowTaskbar::Impl::GetThumbnail() const { return nullptr; }
bool WindowTaskbar::Impl::ResetThumbnail() { return false; }

bool WindowTaskbar::Impl::AddThumbnailButton(std::shared_ptr<TaskbarThumbnailButton>) {
return false;
}
Expand Down
Loading
Loading