Own Linux platform services and narrow legacy fallback

This commit is contained in:
2026-06-17 15:32:29 +02:00
parent 3edb6617d0
commit 9750c418bc
9 changed files with 432 additions and 82 deletions

View File

@@ -9,12 +9,7 @@
#include "platform_api/platform_policy.h"
#include "renderer_gl/opengl_capabilities.h"
#ifdef __LINUX__
#include <tinyfiledialogs.h>
#include "platform_linux/linux_platform_services.h"
std::string linux_home_path();
int mkpath(const std::string& dir, mode_t mode = DEFFILEMODE);
#elif __WEB__
#ifdef __WEB__
void webgl_pick_file(std::function<void(std::string)> callback);
void webgl_pick_file_save(
const std::string& path,
@@ -37,21 +32,7 @@ public:
[[nodiscard]] pp::platform::PlatformStoragePaths prepare_storage_paths() override
{
#if __LINUX__
const std::string data_path = linux_home_path() + "/PanoPainter";
mkpath(data_path + "/brushes");
mkpath(data_path + "/brushes/thumbs");
mkpath(data_path + "/patterns");
mkpath(data_path + "/patterns/thumbs");
mkpath(data_path + "/settings");
mkpath(data_path + "/frames");
return {
data_path,
data_path,
data_path + "/frames",
{},
};
#elif __WEB__
#if __WEB__
const std::string data_path = "/PanoPainter";
mkdir(data_path.c_str(), 0777);
mkdir((data_path + "/brushes").c_str(), 0777);
@@ -111,7 +92,7 @@ public:
void acquire_render_context() override
{
#if __LINUX__ || __WEB__
#if __WEB__
invoke_legacy_glfw_shell_callback(glfw_shell_.acquire_render_context);
#endif
}
@@ -122,7 +103,7 @@ public:
void present_render_context() override
{
#if __LINUX__ || __WEB__
#if __WEB__
invoke_legacy_glfw_shell_callback(glfw_shell_.present_render_context);
#endif
}
@@ -223,19 +204,12 @@ public:
void report_rendered_frames(int frames) override
{
#ifdef __LINUX__
pp::platform::linux_desktop::report_rendered_frames(frames);
#else
(void)frames;
#endif
}
void pick_image(pp::platform::PickedPathCallback callback) override
{
#ifdef __LINUX__
if (auto p = tinyfd_openFileDialog("Open File", "", 0, nullptr, nullptr, false))
invoke_picked_path_if_selected(p, callback);
#elif __WEB__
#ifdef __WEB__
webgl_pick_file(callback);
#else
(void)callback;
@@ -244,10 +218,7 @@ public:
void pick_file(std::vector<std::string> file_types, pp::platform::PickedPathCallback callback) override
{
#ifdef __LINUX__
if (auto p = tinyfd_openFileDialog("Open File", "", 0, nullptr, nullptr, false))
invoke_picked_path_if_selected(p, callback);
#elif __WEB__
#ifdef __WEB__
webgl_pick_file(callback);
#else
(void)file_types;
@@ -364,7 +335,7 @@ public:
void request_app_close() override
{
#ifdef __LINUX__
#if __WEB__
invoke_legacy_glfw_shell_callback(glfw_shell_.request_app_close);
#endif
}