[PR #769] [MERGED] lifecycle: suspend callbacks on window close and fit the title window (RT-GDK-SPEECH-DISPLAY-LIFECYCLE, split from #401) #805

Closed
opened 2026-11-26 20:19:06 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/769
Author: @Andretuta
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: feat/gdk-lifecycle-window-hook


📝 Commits (3)

  • b358d90 lifecycle: suspend callbacks on window close and fit the title window (split from #401)
  • f9792cc Merge remote-tracking branch 'ubiq/main' into feat/gdk-lifecycle-window-hook
  • 8b77190 Merge main into feat/gdk-lifecycle-window-hook (#769)

📊 Changes

6 files changed (+484 additions, -2 deletions)

View changed files

📝 docs/runtime_imports.md (+10 -0)
📝 runtime/CMakeLists.txt (+16 -0)
➕ runtime/shims/lifecycle.cpp (+254 -0)
➕ runtime/shims/lifecycle.h (+21 -0)
➕ runtime/test/lifecycle_test.cpp (+181 -0)
📝 scripts/build_runtime.ps1 (+2 -2)

📄 Description

Claimed in the coordination issue as: RT-GDK-SPEECH-DISPLAY-LIFECYCLE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121796272). Split from #401 at the maintainer's request (one topic per pull request).

What and why

Console titles never get a desktop WM_CLOSE: quitting suspends the title (its RegisterAppStateChangeNotification callbacks run with quiesced TRUE so it can flush saves) and then ends the process. They also size their window for a 4K render target, which overflows smaller desktops.

  • runtime/shims/lifecycle.{h,cpp}: RegisterAppStateChangeNotification / UnregisterAppStateChangeNotification under api-ms-win-core-psm-appnotify-l1-1-0.dll, api-ms-win-core-psm-appnotify-l1-1-1.dll and kernelbase.dll.
  • CreateWindowExW / CreateWindowExA under user32.dll and ext-ms-win-rtcore-ntuser-window-l1-1-0/-l1-1-1.dll, and CreateWindowExA under ext-ms-win-rtcore-ntuser-window-ansi-l1-1-0.dll. The title's import table names CreateWindowExA from that ANSI set and RegisterAppStateChangeNotification from api-ms-win-core-psm-appnotify-l1-1-0 (tools/pe_inspect.py). The version in #401 missed the ANSI set, so the game's window would never have been hooked. Only the title's first top-level window (no parent, not WS_CHILD, not WS_EX_TOOLWINDOW) is fitted to the primary monitor's work area and hooked.
  • Its SC_CLOSE runs the registered suspend callbacks under the registration lock, off the window thread, then ends the run through the title's own ExitProcess shim (process.cpp), so the host finishes its cleanup. The deadline is 1 s: if the callbacks have not returned by then, the run ends the same way.
  • A callback may unregister itself; a registration removed by UnregisterAppStateChangeNotification is never called after it returned.
  • lifecycle_test in runtime/CMakeLists.txt; scripts/build_runtime.ps1 adds shims\lifecycle.cpp and user32.lib to the cl fallback; one paragraph in docs/runtime_imports.md.

The code is #401's lifecycle part (as of a02134a9c) on current main, plus the ANSI window set.

Tested

  • MSVC 14.44 / Windows SDK 10.0.26100: lifecycle_test 30 checks, 0 failures, under CTest (new: CreateWindowExA binds through the ANSI set to the same shim).
  • Build-script, docs and test_gdk_runtime_calls pytest: 82 passed.
  • Merges cleanly with #401 and #537 (git merge-tree).
  • Not run with the title itself.

GPUs tested: n/a (CPU-only Win32 tests)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — runtime shims only)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/769 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `feat/gdk-lifecycle-window-hook` --- ### 📝 Commits (3) - [`b358d90`](https://github.com/ubiquitarianism/leonida/commit/b358d9062d10e63fbd90bfbb08c4bac8b9ef0b30) lifecycle: suspend callbacks on window close and fit the title window (split from #401) - [`f9792cc`](https://github.com/ubiquitarianism/leonida/commit/f9792cc56de10067f1bbdb233eaac23cd5b2074f) Merge remote-tracking branch 'ubiq/main' into feat/gdk-lifecycle-window-hook - [`8b77190`](https://github.com/ubiquitarianism/leonida/commit/8b771908c3c8d7d233e66f39d535a5a7c63047aa) Merge main into feat/gdk-lifecycle-window-hook (#769) ### 📊 Changes **6 files changed** (+484 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/runtime_imports.md` (+10 -0) 📝 `runtime/CMakeLists.txt` (+16 -0) ➕ `runtime/shims/lifecycle.cpp` (+254 -0) ➕ `runtime/shims/lifecycle.h` (+21 -0) ➕ `runtime/test/lifecycle_test.cpp` (+181 -0) 📝 `scripts/build_runtime.ps1` (+2 -2) </details> ### 📄 Description Claimed in the coordination issue as: `RT-GDK-SPEECH-DISPLAY-LIFECYCLE` (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121796272). Split from #401 at the maintainer's request (one topic per pull request). ### What and why Console titles never get a desktop `WM_CLOSE`: quitting suspends the title (its `RegisterAppStateChangeNotification` callbacks run with `quiesced` TRUE so it can flush saves) and then ends the process. They also size their window for a 4K render target, which overflows smaller desktops. - **`runtime/shims/lifecycle.{h,cpp}`:** `RegisterAppStateChangeNotification` / `UnregisterAppStateChangeNotification` under `api-ms-win-core-psm-appnotify-l1-1-0.dll`, `api-ms-win-core-psm-appnotify-l1-1-1.dll` and `kernelbase.dll`. - `CreateWindowExW` / `CreateWindowExA` under `user32.dll` and `ext-ms-win-rtcore-ntuser-window-l1-1-0/-l1-1-1.dll`, and `CreateWindowExA` under `ext-ms-win-rtcore-ntuser-window-ansi-l1-1-0.dll`. The title's import table names `CreateWindowExA` from that ANSI set and `RegisterAppStateChangeNotification` from `api-ms-win-core-psm-appnotify-l1-1-0` (`tools/pe_inspect.py`). The version in #401 missed the ANSI set, so the game's window would never have been hooked. Only the title's first top-level window (no parent, not `WS_CHILD`, not `WS_EX_TOOLWINDOW`) is fitted to the primary monitor's work area and hooked. - Its `SC_CLOSE` runs the registered suspend callbacks under the registration lock, off the window thread, then ends the run through the title's own `ExitProcess` shim (`process.cpp`), so the host finishes its cleanup. **The deadline is 1 s:** if the callbacks have not returned by then, the run ends the same way. - A callback may unregister itself; a registration removed by `UnregisterAppStateChangeNotification` is never called after it returned. - `lifecycle_test` in `runtime/CMakeLists.txt`; `scripts/build_runtime.ps1` adds `shims\lifecycle.cpp` and `user32.lib` to the `cl` fallback; one paragraph in `docs/runtime_imports.md`. The code is #401's lifecycle part (as of a02134a9c) on current `main`, plus the ANSI window set. ### Tested - MSVC 14.44 / Windows SDK 10.0.26100: `lifecycle_test` 30 checks, 0 failures, under CTest (new: `CreateWindowExA` binds through the ANSI set to the same shim). - Build-script, docs and `test_gdk_runtime_calls` pytest: 82 passed. - Merges cleanly with #401 and #537 (`git merge-tree`). - Not run with the title itself. GPUs tested: n/a (CPU-only Win32 tests) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — runtime shims only) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:06 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#805
No description provided.