Move Win32 bindings into runtime state
This commit is contained in:
@@ -10,32 +10,9 @@
|
|||||||
#include "platform_windows/windows_runtime_state.h"
|
#include "platform_windows/windows_runtime_state.h"
|
||||||
#include "platform_windows/windows_stylus_input.h"
|
#include "platform_windows/windows_stylus_input.h"
|
||||||
#include "platform_windows/windows_window_shell.h"
|
#include "platform_windows/windows_window_shell.h"
|
||||||
#include "wacom.h"
|
|
||||||
|
|
||||||
namespace pp::platform::windows {
|
namespace pp::platform::windows {
|
||||||
|
|
||||||
void bind_app(App* app) noexcept
|
|
||||||
{
|
|
||||||
App::I = app;
|
|
||||||
}
|
|
||||||
|
|
||||||
App* bound_app() noexcept
|
|
||||||
{
|
|
||||||
return App::I;
|
|
||||||
}
|
|
||||||
|
|
||||||
void release_bound_app() noexcept
|
|
||||||
{
|
|
||||||
bind_app(nullptr);
|
|
||||||
bind_runtime(nullptr);
|
|
||||||
retained_owned_app().reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
WacomTablet* bound_wacom_tablet() noexcept
|
|
||||||
{
|
|
||||||
return &retained_wacom_tablet();
|
|
||||||
}
|
|
||||||
|
|
||||||
int run_main_application(int argc, char** argv)
|
int run_main_application(int argc, char** argv)
|
||||||
{
|
{
|
||||||
const auto instance = GetModuleHandle(NULL);
|
const auto instance = GetModuleHandle(NULL);
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class App;
|
#include "platform_windows/windows_runtime_state.h"
|
||||||
class WacomTablet;
|
|
||||||
|
|
||||||
namespace pp::platform::windows {
|
namespace pp::platform::windows {
|
||||||
|
|
||||||
int run_main_application(int argc, char** argv);
|
int run_main_application(int argc, char** argv);
|
||||||
void bind_app(App* app) noexcept;
|
|
||||||
[[nodiscard]] App* bound_app() noexcept;
|
|
||||||
void release_bound_app() noexcept;
|
|
||||||
[[nodiscard]] WacomTablet* bound_wacom_tablet() noexcept;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace {
|
|||||||
|
|
||||||
struct RetainedWindowsRuntimeState final {
|
struct RetainedWindowsRuntimeState final {
|
||||||
std::unique_ptr<App> owned_app;
|
std::unique_ptr<App> owned_app;
|
||||||
|
App* app = nullptr;
|
||||||
AppRuntime* runtime = nullptr;
|
AppRuntime* runtime = nullptr;
|
||||||
WacomTablet tablet;
|
WacomTablet tablet;
|
||||||
};
|
};
|
||||||
@@ -23,6 +24,30 @@ struct RetainedWindowsRuntimeState final {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
std::unique_ptr<App>& retained_owned_app() noexcept
|
||||||
{
|
{
|
||||||
return retained_runtime_state().owned_app;
|
return retained_runtime_state().owned_app;
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ class WacomTablet;
|
|||||||
|
|
||||||
namespace pp::platform::windows {
|
namespace pp::platform::windows {
|
||||||
|
|
||||||
|
void bind_app(App* app) noexcept;
|
||||||
|
[[nodiscard]] App* bound_app() noexcept;
|
||||||
|
void release_bound_app() noexcept;
|
||||||
|
[[nodiscard]] WacomTablet* bound_wacom_tablet() noexcept;
|
||||||
[[nodiscard]] std::unique_ptr<App>& retained_owned_app() noexcept;
|
[[nodiscard]] std::unique_ptr<App>& retained_owned_app() noexcept;
|
||||||
[[nodiscard]] WacomTablet& retained_wacom_tablet() noexcept;
|
[[nodiscard]] WacomTablet& retained_wacom_tablet() noexcept;
|
||||||
[[nodiscard]] AppRuntime* retained_bound_runtime() noexcept;
|
[[nodiscard]] AppRuntime* retained_bound_runtime() noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user