1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

SpiceAgent: Implement setting the user's clipboard contents for text

We also now use GUI::Clipboard for setting the clipboard contents,
instead of using a custom connection to the Clipboard server.
This commit is contained in:
Caoimhe 2023-05-13 14:20:41 +01:00 committed by Andreas Kling
parent 9c4538a9a8
commit 3b6d63f723
8 changed files with 96 additions and 124 deletions

View file

@ -7,26 +7,28 @@
#include "SpiceAgent.h"
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Clipboard.h>
#include <LibIPC/ConnectionToServer.h>
#include <LibMain/Main.h>
#include <fcntl.h>
static constexpr auto SPICE_DEVICE = "/dev/hvc0p1"sv;
ErrorOr<int> serenity_main(Main::Arguments)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
Core::EventLoop loop;
// We use the application to be able to easily write to the user's clipboard.
auto app = TRY(GUI::Application::create(arguments));
// FIXME: Make Core::File support reading and writing, but without creating:
// By default, Core::File opens the file descriptor with O_CREAT when using OpenMode::Write (and subsequently, OpenMode::ReadWrite).
// To minimise confusion for people that have already used Core::File, we can probably just do `OpenMode::ReadWrite | OpenMode::DontCreate`.
TRY(Core::System::pledge("unix rpath wpath stdio sendfd recvfd cpath"));
TRY(Core::System::unveil(SPICE_DEVICE, "rwc"sv));
TRY(Core::System::unveil("/tmp/session/%sid/portal/clipboard", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));
auto agent = TRY(SpiceAgent::SpiceAgent::create(SPICE_DEVICE));
TRY(agent->start());
return loop.exec();
return app->exec();
}