From af9b56aa591ceabe4edbce93b13ab93a629c6f4a Mon Sep 17 00:00:00 2001 From: LiJianying Date: Tue, 1 Dec 2026 07:23:01 +0800 Subject: [PATCH] Add Windows WindowTaskbar API --- CMakeLists.txt | 1 + .../window_taskbar_example/CMakeLists.txt | 24 + examples/window_taskbar_example/main.cpp | 230 ++++ include/nativeapi.h | 2 + src/capi/window_c.cpp | 15 + src/capi/window_c.h | 6 + src/capi/window_taskbar_c.cpp | 711 ++++++++++ src/capi/window_taskbar_c.h | 373 ++++++ src/foundation/id_allocator.h | 10 + .../android/window_taskbar_android.cpp | 58 + src/platform/ios/window_taskbar_ios.mm | 58 + src/platform/linux/window_taskbar_linux.cpp | 58 + src/platform/macos/window_taskbar_macos.mm | 58 + src/platform/ohos/window_taskbar_ohos.cpp | 58 + src/platform/wasm/window_taskbar_wasm.cpp | 58 + src/platform/windows/application_windows.cpp | 56 +- .../windows/window_taskbar_windows.cpp | 1140 +++++++++++++++++ src/platform/windows/window_taskbar_windows.h | 16 + src/window.h | 24 + src/window_taskbar.cpp | 297 +++++ src/window_taskbar.h | 531 ++++++++ src/window_taskbar_impl.h | 139 ++ tests/CMakeLists.txt | 5 + tests/window_taskbar_test.cpp | 297 +++++ 24 files changed, 4178 insertions(+), 47 deletions(-) create mode 100644 examples/window_taskbar_example/CMakeLists.txt create mode 100644 examples/window_taskbar_example/main.cpp create mode 100644 src/capi/window_taskbar_c.cpp create mode 100644 src/capi/window_taskbar_c.h create mode 100644 src/platform/android/window_taskbar_android.cpp create mode 100644 src/platform/ios/window_taskbar_ios.mm create mode 100644 src/platform/linux/window_taskbar_linux.cpp create mode 100644 src/platform/macos/window_taskbar_macos.mm create mode 100644 src/platform/ohos/window_taskbar_ohos.cpp create mode 100644 src/platform/wasm/window_taskbar_wasm.cpp create mode 100644 src/platform/windows/window_taskbar_windows.cpp create mode 100644 src/platform/windows/window_taskbar_windows.h create mode 100644 src/window_taskbar.cpp create mode 100644 src/window_taskbar.h create mode 100644 src/window_taskbar_impl.h create mode 100644 tests/window_taskbar_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d1ac5d58..0789b0d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ if(NATIVEAPI_BUILD_EXAMPLES) add_subdirectory(examples/window_lifecycle_example) add_subdirectory(examples/window_parent_example) add_subdirectory(examples/window_shadow_example) + add_subdirectory(examples/window_taskbar_example) add_subdirectory(examples/window_visual_effect_example) add_subdirectory(examples/drag_drop_example) add_subdirectory(examples/desktop_features_example) diff --git a/examples/window_taskbar_example/CMakeLists.txt b/examples/window_taskbar_example/CMakeLists.txt new file mode 100644 index 00000000..05257f34 --- /dev/null +++ b/examples/window_taskbar_example/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.16) +project(window_taskbar_example) + +set(CMAKE_CXX_STANDARD 17) + +include_directories(${CMAKE_SOURCE_DIR}/../../include) + +add_executable(window_taskbar_example main.cpp) +target_link_libraries(window_taskbar_example nativeapi) + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") +elseif(APPLE) + find_library(COCOA_LIBRARY Cocoa) + target_link_libraries(window_taskbar_example ${COCOA_LIBRARY}) +elseif(WIN32) + target_link_libraries(window_taskbar_example user32 kernel32) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_package(PkgConfig REQUIRED) + pkg_check_modules(GTK3 REQUIRED gtk+-3.0) + target_include_directories(window_taskbar_example PRIVATE ${GTK3_INCLUDE_DIRS}) + target_link_libraries(window_taskbar_example ${GTK3_LIBRARIES}) +elseif(ANDROID) + target_link_libraries(window_taskbar_example log android) +endif() diff --git a/examples/window_taskbar_example/main.cpp b/examples/window_taskbar_example/main.cpp new file mode 100644 index 00000000..1443d298 --- /dev/null +++ b/examples/window_taskbar_example/main.cpp @@ -0,0 +1,230 @@ +// WindowTaskbar example: interactive control panel exercising progress states, +// overlay icon, thumbnail toolbar buttons (with live updates, click events, and +// hide/restore recovery), and taskbar flashing. + +#include +#include +#include +#include +#include +#include + +#include "nativeapi.h" + +using namespace nativeapi; + +namespace { + +constexpr const char* kBadgePng = + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOUlEQVR42mNgoAV4amn6HxsmWyNRBhGrGachFBmATQE6wG" + "sIIc24DBnOBpAciAOfDqiSlKmSmcgBAELbsdgN1EiUAAAAAElFTkSuQmCC"; +constexpr const char* kPlayPng = + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAL0lEQVR42mNgGIZgWsd/MKbYALINQTaALIOwGUCSIbgMIN" + "ogmhkwMIE4MAlpyAEAncFlcf6T6RQAAAAASUVORK5CYII="; +constexpr const char* kPausePng = + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAHUlEQVR42mNgGF7g/wyG/8iYkPioAaMG0MaAoQkAa2zO4f" + "8w4zgAAAAASUVORK5CYII="; +constexpr const char* kPrevPng = + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAN0lEQVR42mNgGD5Acdrn/zBMjFqyDcCphpAByPIkG4CumW" + "gDsGmkrwEUe4FqgUiVaCSYkIYuAAA5K7Tl/slM+AAAAABJRU5ErkJggg=="; +constexpr const char* kNextPng = + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMklEQVR42mNgGD5Acdrn/8SogWGckhQbgM8gkgzApohkA9" + "AV09+AgQlEiqKRooQ0dAEADpu05f0DPosAAAAASUVORK5CYII="; + +std::shared_ptr MakeRow() { + auto row = std::make_shared(); + row->SetLayout(ViewLayout::Row); + row->SetSpacing(8); + row->SetPreferredSize(Size{0, 32}); + return row; +} + +std::shared_ptr