1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

FileSystemAccessServer+TextEditor: Implement cross-process modal prompts

This transitions from synchronous IPC calls to asynchronous IPC calls
provided through a synchronous interface in LibFileSystemAccessClient
which allows the parent Application to stay responsive.

It achieves this with Promise which is pumping the Application event
loop while waiting for the Dialog to respond with the user's action.

LibFileSystemAccessClient provides a lazy singleton which also ensures
that FileSystemAccessServer is running in the event of a crash.

This also transitions TextEditor into using LibFileSystemAccessClient.
This commit is contained in:
Timothy 2021-07-12 01:16:26 +10:00 committed by Andreas Kling
parent ab353fd4e1
commit 38594dde79
12 changed files with 224 additions and 88 deletions

View file

@ -8,37 +8,17 @@
#include <AK/Function.h>
#include <AK/LexicalPath.h>
#include <FileSystemAccessServer/ClientConnection.h>
#include <FileSystemAccessServer/FileSystemAccessClientEndpoint.h>
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
#include <LibFileSystemAccessClient/Client.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/TextEditor.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibIPC/ServerConnection.h>
#include <LibWeb/Forward.h>
namespace TextEditor {
class FileSystemAccessClient final
: public IPC::ServerConnection<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>
, public FileSystemAccessClientEndpoint {
C_OBJECT(FileSystemAccessClient)
public:
virtual void die() override
{
}
private:
explicit FileSystemAccessClient()
: IPC::ServerConnection<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>(*this, "/tmp/portal/filesystemaccess")
{
}
};
class MainWidget final : public GUI::Widget {
C_OBJECT(MainWidget);
@ -74,8 +54,6 @@ private:
virtual void drop_event(GUI::DropEvent&) override;
NonnullRefPtr<FileSystemAccessClient> m_file_system_access_client;
RefPtr<GUI::TextEditor> m_editor;
String m_path;
String m_name;