Split Win32 main window session state
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "log.h"
|
||||
#include "platform_windows/windows_bootstrap_helpers.h"
|
||||
#include "platform_windows/windows_lifecycle_shell.h"
|
||||
#include "platform_windows/windows_main_window_session.h"
|
||||
#include "platform_windows/windows_platform_services.h"
|
||||
#include "platform_windows/windows_stylus_input.h"
|
||||
#include "platform_windows/windows_window_shell.h"
|
||||
@@ -16,23 +17,11 @@ namespace pp::platform::windows {
|
||||
|
||||
namespace {
|
||||
|
||||
struct RetainedMainWindowSessionState final {
|
||||
HWND handle{};
|
||||
wchar_t title[512]{};
|
||||
bool sandboxed = false;
|
||||
};
|
||||
|
||||
struct RetainedWindowsRuntimeState final {
|
||||
std::unique_ptr<App> owned_app;
|
||||
WacomTablet tablet;
|
||||
};
|
||||
|
||||
[[nodiscard]] RetainedMainWindowSessionState& retained_main_window_session_state()
|
||||
{
|
||||
static RetainedMainWindowSessionState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
[[nodiscard]] RetainedWindowsRuntimeState& retained_runtime_state()
|
||||
{
|
||||
static RetainedWindowsRuntimeState state;
|
||||
@@ -149,30 +138,9 @@ WacomTablet* bound_wacom_tablet() noexcept
|
||||
return &retained_runtime_state().tablet;
|
||||
}
|
||||
|
||||
HWND main_window_handle() noexcept
|
||||
{
|
||||
return retained_main_window_session_state().handle;
|
||||
}
|
||||
|
||||
const wchar_t* main_window_title() noexcept
|
||||
{
|
||||
return retained_main_window_session_state().title;
|
||||
}
|
||||
|
||||
bool main_window_sandboxed() noexcept
|
||||
{
|
||||
return retained_main_window_session_state().sandboxed;
|
||||
}
|
||||
|
||||
void set_main_window_sandboxed(bool sandboxed) noexcept
|
||||
{
|
||||
retained_main_window_session_state().sandboxed = sandboxed;
|
||||
}
|
||||
|
||||
int run_main_application(int argc, char** argv)
|
||||
{
|
||||
const auto instance = GetModuleHandle(NULL);
|
||||
auto& main_window_state = retained_main_window_session_state();
|
||||
|
||||
auto& runtime_state = retained_runtime_state();
|
||||
runtime_state.owned_app = std::make_unique<App>();
|
||||
@@ -203,9 +171,9 @@ int run_main_application(int argc, char** argv)
|
||||
auto context = pp::platform::windows::OpenGlWindowContext {};
|
||||
switch (pp::platform::windows::initialize_main_window_and_gl(
|
||||
startup,
|
||||
main_window_state.handle,
|
||||
retained_main_window_handle_ref(),
|
||||
instance,
|
||||
main_window_state.title,
|
||||
retained_main_window_title_buffer(),
|
||||
context))
|
||||
{
|
||||
case pp::platform::windows::MainStartupResult::Ok:
|
||||
@@ -245,25 +213,24 @@ int run_main_application(int argc, char** argv)
|
||||
|
||||
void run_main_window_runtime(const MainWindowStartupState& startup, bool start_in_vr, HINSTANCE instance, SplashScreen& splash)
|
||||
{
|
||||
auto& main_window_state = retained_main_window_session_state();
|
||||
auto* app = bound_app();
|
||||
register_touch_window(main_window_state.handle);
|
||||
register_touch_window(retained_main_window_handle_ref());
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
|
||||
initialize_runtime_threads();
|
||||
install_debug_gl_callbacks();
|
||||
initialize_wintab(main_window_state.handle, main_window_state.sandboxed);
|
||||
set_main_window_icon(main_window_state.handle);
|
||||
initialize_wintab(retained_main_window_handle_ref(), retained_main_window_sandboxed());
|
||||
set_main_window_icon(retained_main_window_handle_ref());
|
||||
|
||||
app->ui_sync();
|
||||
restore_window_placement(main_window_state.handle, startup.show_command);
|
||||
restore_window_placement(retained_main_window_handle_ref(), startup.show_command);
|
||||
|
||||
if (start_in_vr)
|
||||
app->vr_start();
|
||||
|
||||
LOG("show main window");
|
||||
SetForegroundWindow(main_window_state.handle);
|
||||
SetForegroundWindow(retained_main_window_handle_ref());
|
||||
|
||||
splash.dismiss();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user