Move Windows bootstrap off App::I
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
namespace pp::platform::windows {
|
||||
void set_async_render_context(HDC hdc, HGLRC hrc);
|
||||
App* bound_app() noexcept;
|
||||
}
|
||||
|
||||
namespace pp::platform::windows {
|
||||
@@ -130,7 +131,7 @@ int run_winmain_entry(int (*entry_point)(int, char**))
|
||||
return entry_point(argc, argv);
|
||||
}
|
||||
|
||||
void setup_exception_handler()
|
||||
void setup_exception_handler(const App& app)
|
||||
{
|
||||
// Setup exception handler
|
||||
BT_SetAppName(_T("PanoPainter"));
|
||||
@@ -155,11 +156,12 @@ void setup_exception_handler()
|
||||
// Add custom log file using default name
|
||||
TCHAR wpath[MAX_PATH];
|
||||
//GetFullPathNameW(L"panopainter-log.txt", 1024, wpath, nullptr);
|
||||
auto log_file = App::I->data_path + "/panopainter-log.txt";
|
||||
auto log_file = app.data_path + "/panopainter-log.txt";
|
||||
std::mbstowcs(wpath, log_file.c_str(), log_file.size());
|
||||
BT_AddLogFile(wpath);
|
||||
|
||||
BT_SetPreErrHandler([](INT_PTR){
|
||||
BT_SetPreErrHandler([](INT_PTR nErrHandlerParam){
|
||||
const auto* app = reinterpret_cast<const App*>(nErrHandlerParam);
|
||||
if (Canvas::I && Canvas::I->m_unsaved)
|
||||
{
|
||||
auto t = std::time(nullptr);
|
||||
@@ -167,7 +169,7 @@ void setup_exception_handler()
|
||||
std::ostringstream oss;
|
||||
oss << std::put_time(&tm, "%d-%m-%Y %H-%M-%S");
|
||||
|
||||
auto path = App::I->data_path + "/" + App::I->doc_name + "-recovery (" + oss.str() + ").ppi";
|
||||
auto path = app->data_path + "/" + app->doc_name + "-recovery (" + oss.str() + ").ppi";
|
||||
Canvas::I->project_save_thread(path, false);
|
||||
static char abspath[MAX_PATH];
|
||||
GetFullPathNameA(path.c_str(), MAX_PATH, abspath, NULL);
|
||||
@@ -176,7 +178,7 @@ void setup_exception_handler()
|
||||
MessageBoxA(retained_state().hWnd, message, "File Recovery", MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
LogRemote::I.file_close();
|
||||
}, 0);
|
||||
}, reinterpret_cast<INT_PTR>(&app));
|
||||
|
||||
BT_SetTerminate();
|
||||
}
|
||||
@@ -373,7 +375,7 @@ int read_WMI_info()
|
||||
return 0;
|
||||
}
|
||||
|
||||
MainWindowStartupState initialize_main_window_startup_state()
|
||||
MainWindowStartupState initialize_main_window_startup_state(App& app)
|
||||
{
|
||||
auto startup = MainWindowStartupState {};
|
||||
const auto hInst = GetModuleHandle(NULL);
|
||||
@@ -392,26 +394,26 @@ MainWindowStartupState initialize_main_window_startup_state()
|
||||
auto y = unsigned{ 96 };
|
||||
if (GetDpiForMonitor_fn)
|
||||
GetDpiForMonitor_fn(monitor, MDT_EFFECTIVE_DPI, &x, &y);
|
||||
App::I->display_density = (float)x / 96.f;
|
||||
app.display_density = (float)x / 96.f;
|
||||
|
||||
const auto window_preferences = pp::panopainter::read_legacy_window_preferences(SW_NORMAL);
|
||||
if (window_preferences.has_ui_scale)
|
||||
App::I->zoom = window_preferences.ui_scale;
|
||||
app.zoom = window_preferences.ui_scale;
|
||||
else
|
||||
App::I->zoom = (float)x / 96.f;
|
||||
app.zoom = (float)x / 96.f;
|
||||
|
||||
startup.show_command = window_preferences.show_command;
|
||||
startup.client_rect = {
|
||||
0,
|
||||
0,
|
||||
static_cast<LONG>(App::I->width * App::I->zoom),
|
||||
static_cast<LONG>(App::I->height * App::I->zoom),
|
||||
static_cast<LONG>(app.width * app.zoom),
|
||||
static_cast<LONG>(app.height * app.zoom),
|
||||
};
|
||||
if (window_preferences.has_window_rect)
|
||||
{
|
||||
auto wnd_rect = window_preferences.window_rect;
|
||||
App::I->width = wnd_rect.z - wnd_rect.x;
|
||||
App::I->height = wnd_rect.w - wnd_rect.y;
|
||||
app.width = wnd_rect.z - wnd_rect.x;
|
||||
app.height = wnd_rect.w - wnd_rect.y;
|
||||
startup.client_rect = { wnd_rect.x, wnd_rect.y, wnd_rect.z, wnd_rect.w };
|
||||
startup.client_pos = { wnd_rect.x, wnd_rect.y };
|
||||
}
|
||||
@@ -577,7 +579,7 @@ BOOL UnadjustWindowRectEx(LPRECT prc, DWORD dwStyle, BOOL fMenu, DWORD dwExStyle
|
||||
|
||||
void _pre_call_callback(const char* name, void* funcptr, int len_args, ...)
|
||||
{
|
||||
assert(App::I->is_render_thread());
|
||||
assert(bound_app()->is_render_thread());
|
||||
}
|
||||
|
||||
void _post_call_callback(const char* name, void* funcptr, int len_args, ...)
|
||||
|
||||
Reference in New Issue
Block a user