72 lines
1.3 KiB
C++
72 lines
1.3 KiB
C++
#include "pch.h"
|
|
|
|
#include "platform_windows/windows_runtime_state.h"
|
|
|
|
#include "app.h"
|
|
#include "app_runtime.h"
|
|
#include "wacom.h"
|
|
|
|
namespace pp::platform::windows {
|
|
namespace {
|
|
|
|
struct RetainedWindowsRuntimeState final {
|
|
std::unique_ptr<App> owned_app;
|
|
App* app = nullptr;
|
|
AppRuntime* runtime = nullptr;
|
|
WacomTablet tablet;
|
|
};
|
|
|
|
[[nodiscard]] RetainedWindowsRuntimeState& retained_runtime_state() noexcept
|
|
{
|
|
static RetainedWindowsRuntimeState state;
|
|
return state;
|
|
}
|
|
|
|
}
|
|
|
|
void bind_app(App* app) noexcept
|
|
{
|
|
auto& state = retained_runtime_state();
|
|
state.app = app;
|
|
App::I = app;
|
|
}
|
|
|
|
App* bound_app() noexcept
|
|
{
|
|
return retained_runtime_state().app;
|
|
}
|
|
|
|
void release_bound_app() noexcept
|
|
{
|
|
bind_app(nullptr);
|
|
bind_runtime(nullptr);
|
|
retained_owned_app().reset();
|
|
}
|
|
|
|
WacomTablet* bound_wacom_tablet() noexcept
|
|
{
|
|
return &retained_wacom_tablet();
|
|
}
|
|
|
|
std::unique_ptr<App>& retained_owned_app() noexcept
|
|
{
|
|
return retained_runtime_state().owned_app;
|
|
}
|
|
|
|
WacomTablet& retained_wacom_tablet() noexcept
|
|
{
|
|
return retained_runtime_state().tablet;
|
|
}
|
|
|
|
AppRuntime* retained_bound_runtime() noexcept
|
|
{
|
|
return retained_runtime_state().runtime;
|
|
}
|
|
|
|
void bind_runtime(AppRuntime* runtime) noexcept
|
|
{
|
|
retained_runtime_state().runtime = runtime;
|
|
}
|
|
|
|
}
|