55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
/**
|
|
* @file App.cpp
|
|
* @author apio (cloudapio.eu)
|
|
* @brief UI application event loop.
|
|
*
|
|
* @copyright Copyright (c) 2023, the Luna authors.
|
|
*
|
|
*/
|
|
|
|
#include <os/ArgumentParser.h>
|
|
#include <os/IPC.h>
|
|
#include <ui/App.h>
|
|
|
|
namespace ui
|
|
{
|
|
App* App::s_app { nullptr };
|
|
|
|
App::App()
|
|
{
|
|
s_app = this;
|
|
}
|
|
|
|
App::~App()
|
|
{
|
|
s_app = nullptr;
|
|
}
|
|
|
|
Result<void> App::init(int argc, char** argv)
|
|
{
|
|
StringView socket_path = "/tmp/wind.sock";
|
|
|
|
os::ArgumentParser parser;
|
|
parser.add_description("A UI application."_sv);
|
|
parser.add_system_program_info(argv[0]);
|
|
parser.add_value_argument(socket_path, 's', "socket"_sv, "the path for the local IPC socket"_sv);
|
|
parser.parse(argc, argv);
|
|
|
|
m_client = TRY(os::LocalClient::connect(socket_path, true));
|
|
|
|
return {};
|
|
}
|
|
|
|
Result<int> App::run()
|
|
{
|
|
while (!m_should_close) { TRY(os::IPC::check_for_messages(*m_client)); }
|
|
return 0;
|
|
}
|
|
|
|
App& App::the()
|
|
{
|
|
check(s_app);
|
|
return *s_app;
|
|
}
|
|
}
|