Extract Win32 runtime state storage
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "platform_windows/windows_lifecycle_state.h"
|
||||
#include "platform_windows/windows_main_window_session.h"
|
||||
#include "platform_windows/windows_platform_services.h"
|
||||
#include "platform_windows/windows_runtime_state.h"
|
||||
#include "platform_windows/windows_stylus_input.h"
|
||||
#include "platform_windows/windows_window_shell.h"
|
||||
#include "wacom.h"
|
||||
@@ -17,17 +18,6 @@ namespace pp::platform::windows {
|
||||
|
||||
namespace {
|
||||
|
||||
struct RetainedWindowsRuntimeState final {
|
||||
std::unique_ptr<App> owned_app;
|
||||
WacomTablet tablet;
|
||||
};
|
||||
|
||||
[[nodiscard]] RetainedWindowsRuntimeState& retained_runtime_state()
|
||||
{
|
||||
static RetainedWindowsRuntimeState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
void register_touch_window(HWND hWnd)
|
||||
{
|
||||
// link: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registertouchwindow
|
||||
@@ -110,7 +100,7 @@ void run_main_message_loop()
|
||||
|
||||
void shutdown_main_window_runtime(const MainWindowStartupState& startup, HINSTANCE hInst)
|
||||
{
|
||||
retained_runtime_state().tablet.terminate();
|
||||
retained_wacom_tablet().terminate();
|
||||
UnregisterClass(startup.window_class.lpszClassName, hInst);
|
||||
LogRemote::I.stop();
|
||||
}
|
||||
@@ -130,21 +120,21 @@ App* bound_app() noexcept
|
||||
void release_bound_app() noexcept
|
||||
{
|
||||
bind_app(nullptr);
|
||||
retained_runtime_state().owned_app.reset();
|
||||
retained_owned_app().reset();
|
||||
}
|
||||
|
||||
WacomTablet* bound_wacom_tablet() noexcept
|
||||
{
|
||||
return &retained_runtime_state().tablet;
|
||||
return &retained_wacom_tablet();
|
||||
}
|
||||
|
||||
int run_main_application(int argc, char** argv)
|
||||
{
|
||||
const auto instance = GetModuleHandle(NULL);
|
||||
|
||||
auto& runtime_state = retained_runtime_state();
|
||||
runtime_state.owned_app = std::make_unique<App>();
|
||||
auto* app = runtime_state.owned_app.get();
|
||||
auto& owned_app = retained_owned_app();
|
||||
owned_app = std::make_unique<App>();
|
||||
auto* app = owned_app.get();
|
||||
bind_app(app);
|
||||
app->set_platform_services(&pp::platform::windows::platform_services());
|
||||
app->initLog();
|
||||
|
||||
Reference in New Issue
Block a user