diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 9d2e9dd..0df10db 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -446,8 +446,8 @@ Known local toolchain state: platform clipboard bridges. - `pp_platform_api` exposes the SDK-free `PlatformServices` interface for clipboard text, cursor visibility, virtual-keyboard visibility, external - file display, file sharing, picker callbacks, and prepared-file - save/download handoff; Windows live app execution now uses injected + file display, file sharing, native app/window close, picker callbacks, and + prepared-file save/download handoff; Windows live app execution now uses injected `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*` in `pp_platform_windows`, while non-Windows platforms still reach retained platform bridges through diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index cba1de7..7d73ef7 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -35,7 +35,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0014 | Open | Modernization | `windows-clangcl-asan` now configures as a headless Ninja/clang-cl preset and uses the release MSVC runtime required by ASan, but local builds still fail because installed clang-cl 18.1.8 is paired with VS 2026-preview STL headers that require Clang 20 or newer | Sanitizer validation should be local and repeatable, but this machine's compiler/header pairing is incompatible | `cmake --fresh --preset windows-clangcl-asan`; `cmake --build --preset windows-clangcl-asan --target pp_foundation` | Install/use Clang 20+ with the VS 2026 STL, or point the preset at a compatible VS 2022 toolchain, then make `platform-build.ps1 -Presets windows-clangcl-asan` pass for the headless matrix | | DEBT-0015 | Open | Modernization | Cursor visibility requests now consume pure `pp_app_core` planning through `pano_cli plan-cursor-visibility`, `App::show_cursor`/`App::hide_cursor` dispatch through `PlatformServices` without platform guards, and Windows live execution uses injected `WindowsPlatformServices`, but macOS cursor execution still reaches the retained fallback adapter | Keep canvas cursor behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-cursor-visibility --visible`; `ctest --preset desktop-fast --build-config Debug` | Cursor visibility execution is owned by injected `pp_platform_*` services for every supported platform | | DEBT-0016 | Open | Modernization | Clipboard get/set requests now consume pure `pp_app_core` planning through `pano_cli plan-clipboard-read` and `pano_cli plan-clipboard-write`, and Windows live execution uses injected `WindowsPlatformServices`, but Apple/Android clipboard execution still reaches retained fallback adapter branches from `App::clipboard_get_text` and `App::clipboard_set_text` | Keep picker/color text clipboard behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-clipboard-write --text #ff00aa`; `ctest --preset desktop-fast --build-config Debug` | Clipboard execution is owned by injected `pp_platform_*` services for every supported platform | -| DEBT-0017 | Open | Modernization | `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell | +| DEBT-0017 | Open | Modernization | `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, native app/window close, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell | ## Closed Debt diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 9d0770a..748e15d 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -482,6 +482,10 @@ writes the temporary/exported payload. `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, and `App::hideKeyboard` now dispatch through the active service without local platform guards; unsupported platforms rely on their service no-op behavior. +The unsaved-document close prompt now requests native app/window close through +`PlatformServices`, with Windows implemented by `WindowsPlatformServices` and +macOS/Linux still handled by the legacy adapter until those platform shells +are injected. `pano_cli plan-cloud-upload` exposes the app-core cloud upload decision used by the live cloud upload command for missing-canvas, new-document warning, publish prompt, and dirty-document save-before-upload states before legacy UI, canvas, @@ -995,11 +999,12 @@ Results: - `pp_platform_api_tests` passed, covering the SDK-free `PlatformServices` interface for clipboard read/write, empty clipboard writes, cursor visibility dispatch, virtual-keyboard visibility dispatch, external file - display dispatch, file sharing dispatch, picker callback dispatch, and - prepared-file save/download callback dispatch. The live Windows app now - consumes this interface through an injected `WindowsPlatformServices` - instance isolated in `src/platform_windows/windows_platform_services.*`; - other platforms still use the legacy fallback adapter, now isolated in + display dispatch, file sharing dispatch, native app/window close dispatch, + picker callback dispatch, and prepared-file save/download callback dispatch. + The live Windows app now consumes this interface through an injected + `WindowsPlatformServices` instance isolated in + `src/platform_windows/windows_platform_services.*`; other platforms still + use the legacy fallback adapter, now isolated in `src/platform_legacy/legacy_platform_services.*` instead of being owned by `app_events.cpp`. - `panopainter_validate_shaders` passed, validating 25 shader programs and 7 diff --git a/src/app.cpp b/src/app.cpp index bbcf890..ba3cb00 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -27,7 +27,6 @@ bool async_lock_try(); void async_lock(); void win32_async_swap(); void async_unlock(); -void destroy_window(); void win32_renderdoc_frame_start(); void win32_renderdoc_frame_end(); #elif __LINUX__ @@ -273,16 +272,7 @@ bool App::request_close() m->m_message->set_text("Do you want to close without saving?"); m->btn_ok->m_text->set_text("Yes"); m->btn_ok->on_click = [this](Node*) { -#ifdef _WIN32 - destroy_window(); - //PostQuitMessage(0); -#elif __OSX__ - dispatch_async(dispatch_get_main_queue(), ^{ - [osx_view close]; - }); -#elif __LINUX__ - glfwSetWindowShouldClose(glfw_window, GLFW_TRUE); -#endif + request_app_close(); Canvas::I->m_unsaved = false; }; m->btn_cancel->m_text->set_text("No"); diff --git a/src/app.h b/src/app.h index 3b54367..8e13d9e 100644 --- a/src/app.h +++ b/src/app.h @@ -189,6 +189,7 @@ public: void pick_dir(std::function callback); void display_file(std::string path); void share_file(std::string path); + void request_app_close(); void save_prepared_file( std::string path, std::string suggested_name, diff --git a/src/app_events.cpp b/src/app_events.cpp index 9747740..41b5630 100644 --- a/src/app_events.cpp +++ b/src/app_events.cpp @@ -214,6 +214,11 @@ void App::share_file(std::string path) active_platform_services().share_file(path); } +void App::request_app_close() +{ + active_platform_services().request_app_close(); +} + void App::save_prepared_file( std::string path, std::string suggested_name, diff --git a/src/platform_api/platform_services.h b/src/platform_api/platform_services.h index fc1c9d5..6d6e134 100644 --- a/src/platform_api/platform_services.h +++ b/src/platform_api/platform_services.h @@ -20,6 +20,7 @@ public: virtual void set_virtual_keyboard_visible(bool visible) = 0; virtual void display_file(std::string_view path) = 0; virtual void share_file(std::string_view path) = 0; + virtual void request_app_close() = 0; virtual void pick_image(PickedPathCallback callback) = 0; virtual void pick_file(std::vector file_types, PickedPathCallback callback) = 0; virtual void pick_save_file(std::vector file_types, PickedPathCallback callback) = 0; diff --git a/src/platform_legacy/legacy_platform_services.cpp b/src/platform_legacy/legacy_platform_services.cpp index 8fa4990..b473bbd 100644 --- a/src/platform_legacy/legacy_platform_services.cpp +++ b/src/platform_legacy/legacy_platform_services.cpp @@ -205,6 +205,17 @@ public: #endif } + void request_app_close() override + { +#ifdef __OSX__ + dispatch_async(dispatch_get_main_queue(), ^{ + [App::I->osx_view close]; + }); +#elif __LINUX__ + glfwSetWindowShouldClose(App::I->glfw_window, GLFW_TRUE); +#endif + } + void save_prepared_file( std::string_view path, std::string_view suggested_name, diff --git a/src/platform_windows/windows_platform_services.cpp b/src/platform_windows/windows_platform_services.cpp index 9b8a219..38f7632 100644 --- a/src/platform_windows/windows_platform_services.cpp +++ b/src/platform_windows/windows_platform_services.cpp @@ -7,6 +7,8 @@ extern HWND hWnd; extern std::deque> main_tasklist; extern std::mutex main_task_mutex; +void destroy_window(); + namespace { void show_cursor(bool visible) @@ -176,6 +178,11 @@ public: (void)path; } + void request_app_close() override + { + destroy_window(); + } + void pick_image(pp::platform::PickedPathCallback callback) override { const std::string path = open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png"); diff --git a/tests/platform_api/platform_services_tests.cpp b/tests/platform_api/platform_services_tests.cpp index 2aa69df..b9c2ce9 100644 --- a/tests/platform_api/platform_services_tests.cpp +++ b/tests/platform_api/platform_services_tests.cpp @@ -52,6 +52,11 @@ public: shared_path.assign(path); } + void request_app_close() override + { + ++app_close_requests; + } + void pick_image(pp::platform::PickedPathCallback callback) override { ++pick_image_requests; @@ -95,6 +100,7 @@ public: int keyboard_updates = 0; int display_file_requests = 0; int share_file_requests = 0; + int app_close_requests = 0; int pick_image_requests = 0; int pick_file_requests = 0; int pick_save_file_requests = 0; @@ -162,9 +168,11 @@ void platform_services_dispatch_file_actions(pp::tests::Harness& harness) services.display_file("D:/Paint/export.png"); services.share_file("D:/Paint/demo.ppi"); + services.request_app_close(); PP_EXPECT(harness, fake.display_file_requests == 1); PP_EXPECT(harness, fake.share_file_requests == 1); + PP_EXPECT(harness, fake.app_close_requests == 1); PP_EXPECT(harness, fake.displayed_path == "D:/Paint/export.png"); PP_EXPECT(harness, fake.shared_path == "D:/Paint/demo.ppi"); }