Luna/apps/gclient.cpp

47 lines
1.4 KiB
C++
Raw Normal View History

2023-08-07 20:45:00 +00:00
#include <os/ArgumentParser.h>
2023-08-14 16:15:38 +00:00
#include <os/File.h>
2023-08-07 20:45:00 +00:00
#include <os/LocalClient.h>
2023-08-14 16:15:38 +00:00
#include <ui/ipc/Server.h>
#include <unistd.h>
Result<void> handle_ipc_client_event(os::LocalClient&, u8)
{
todo();
}
Result<int> create_window(os::LocalClient& client, ui::Rect rect, StringView name, ui::Color color)
{
ui::CreateWindowRequest request;
request.rect = rect;
SET_IPC_STRING(request.name, name.chars());
request.color = color;
auto response = TRY(os::IPC::send_sync<ui::CreateWindowResponse>(client, request));
return response.window;
}
2023-08-07 20:45:00 +00:00
Result<int> luna_main(int argc, char** argv)
{
StringView socket_path = "/tmp/wind.sock";
os::ArgumentParser parser;
parser.add_description("A graphical user interface client."_sv);
parser.add_system_program_info("gclient"_sv);
parser.add_value_argument(socket_path, 's', "socket"_sv, "the path for the local IPC socket"_sv);
parser.parse(argc, argv);
auto client = TRY(os::LocalClient::connect(socket_path, false));
2023-08-14 16:15:38 +00:00
int id = TRY(create_window(*client, ui::Rect { 200, 200, 400, 300 }, "My Window", ui::CYAN));
os::println("Created new window with id %d!", id);
sleep(3);
id =
TRY(create_window(*client, ui::Rect { 100, 100, 200, 150 }, "Super Long Name that is Way Too Long ", ui::BLUE));
os::println("Created new window with id %d!", id);
sleep(6);
2023-08-07 20:45:00 +00:00
return 0;
}