Add Waylight namespace

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-17 00:20:39 +03:00
parent 42a9de3ba3
commit 237208d972
14 changed files with 91 additions and 37 deletions

View File

@@ -17,43 +17,12 @@
#include "App.hpp"
namespace Waylight {
bool signal_running();
std::optional<App> g_app {};
auto main() -> int
{
if (signal_running()) {
return 0;
}
std::signal(SIGINT, [](int) {
if (g_app)
g_app->stop();
});
CPPTRACE_TRY
{
g_app.emplace();
g_app->run();
}
CPPTRACE_CATCH(std::exception const &e)
{
std::string what { e.what() };
std::ranges::replace(what, '"', '.');
std::ranges::replace(what, '\'', '.');
std::ranges::replace(what, '`', '.');
if (what.empty()) {
std::println(std::cerr, "Unexpected exception!");
} else {
std::println(std::cerr, "Unexpected exception! Error: {}", what);
}
cpptrace::from_current_exception().print();
tinyfd_messageBox(
"Unexpected exception", what.c_str(), "ok", "error", 1);
}
}
bool signal_running()
{
char const *lock_path = "/tmp/waylight.lock";
@@ -82,3 +51,38 @@ bool signal_running()
dprintf(fd, "%d\n", getpid());
return false;
}
} // namespace Waylight
auto main() -> int
{
if (Waylight::signal_running()) {
return 0;
}
std::signal(SIGINT, [](int) {
if (Waylight::g_app)
Waylight::g_app->stop();
});
CPPTRACE_TRY
{
Waylight::g_app.emplace();
Waylight::g_app->run();
}
CPPTRACE_CATCH(std::exception const &e)
{
std::string what { e.what() };
std::ranges::replace(what, '"', '.');
std::ranges::replace(what, '\'', '.');
std::ranges::replace(what, '`', '.');
if (what.empty()) {
std::println(std::cerr, "Unexpected exception!");
} else {
std::println(std::cerr, "Unexpected exception! Error: {}", what);
}
cpptrace::from_current_exception().print();
tinyfd_messageBox(
"Unexpected exception", what.c_str(), "ok", "error", 1);
}
}