Files
mandy/runtime/shims/lifecycle.h
andretuta b358d9062d lifecycle: suspend callbacks on window close and fit the title window (split from #401)
RegisterAppStateChangeNotification / UnregisterAppStateChangeNotification under
api-ms-win-core-psm-appnotify-l1-1-0/-l1-1-1 and kernelbase.dll, and CreateWindowExW/A under
user32.dll and ext-ms-win-rtcore-ntuser-window-l1-1-0/-l1-1-1, plus CreateWindowExA under
ext-ms-win-rtcore-ntuser-window-ansi-l1-1-0, the set the title's import table names. The title's
first top-level window is fitted to the work area and hooked: SC_CLOSE runs the suspend callbacks
(quiesced TRUE) and ends the run through the title's ExitProcess, with a 1 s deadline.

Split from #401 (a02134a9c), as the maintainer asked for one topic per pull request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:33:06 -03:00

22 lines
795 B
C++

// App lifecycle notifications (RegisterAppStateChangeNotification / UnregisterAppStateChangeNotification) and
// oversized top-level console window fitting + suspend-on-close hook (CreateWindowExA/W).
#pragma once
#include <windows.h>
#include <cstddef>
#include <utility>
namespace rt::lifecycle {
// Scales down (width, height) proportionally to fit inside `area`, leaving fitting sizes and CW_USEDEFAULT / <= 0
// unchanged.
std::pair<int, int> fit_window_to_area(const RECT& area, int width, int height);
// For tests: number of currently registered app-state change callbacks, and synchronous suspend invocation
// (quiesced = TRUE) without terminating the process.
std::size_t registered_notification_count();
void invoke_suspend_callbacks_for_test();
} // namespace rt::lifecycle