mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-29 12:49:05 +00:00
LibFileSystemAccessClient: Use WindowServer window stealing interface
This commit is contained in:
parent
9e04ab936f
commit
215f383b12
Notes:
sideshowbarker
2024-07-18 08:49:33 +09:00
Author: https://github.com/timmot
Commit: 215f383b12
Pull-request: https://github.com/SerenityOS/serenity/pull/8636
Issue: https://github.com/SerenityOS/serenity/issues/8628
Issue: https://github.com/SerenityOS/serenity/issues/8630
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
1 changed files with 27 additions and 6 deletions
|
@ -26,9 +26,16 @@ Client& Client::the()
|
||||||
Result Client::request_file(i32 parent_window_id, String const& path, Core::OpenMode mode)
|
Result Client::request_file(i32 parent_window_id, String const& path, Core::OpenMode mode)
|
||||||
{
|
{
|
||||||
m_promise = Core::Promise<Result>::construct();
|
m_promise = Core::Promise<Result>::construct();
|
||||||
auto window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
auto parent_window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
||||||
|
auto child_window_server_client_id = expose_window_server_client_id();
|
||||||
|
|
||||||
async_request_file(window_server_client_id, parent_window_id, path, mode);
|
GUI::WindowServerConnection::the().async_add_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
|
|
||||||
|
ScopeGuard guard([parent_window_id, child_window_server_client_id] {
|
||||||
|
GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
async_request_file(parent_window_server_client_id, parent_window_id, path, mode);
|
||||||
|
|
||||||
return m_promise->await();
|
return m_promise->await();
|
||||||
}
|
}
|
||||||
|
@ -36,9 +43,16 @@ Result Client::request_file(i32 parent_window_id, String const& path, Core::Open
|
||||||
Result Client::open_file(i32 parent_window_id)
|
Result Client::open_file(i32 parent_window_id)
|
||||||
{
|
{
|
||||||
m_promise = Core::Promise<Result>::construct();
|
m_promise = Core::Promise<Result>::construct();
|
||||||
auto window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
auto parent_window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
||||||
|
auto child_window_server_client_id = expose_window_server_client_id();
|
||||||
|
|
||||||
async_prompt_open_file(window_server_client_id, parent_window_id, Core::StandardPaths::home_directory(), Core::OpenMode::ReadOnly);
|
GUI::WindowServerConnection::the().async_add_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
|
|
||||||
|
ScopeGuard guard([parent_window_id, child_window_server_client_id] {
|
||||||
|
GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
async_prompt_open_file(parent_window_server_client_id, parent_window_id, Core::StandardPaths::home_directory(), Core::OpenMode::ReadOnly);
|
||||||
|
|
||||||
return m_promise->await();
|
return m_promise->await();
|
||||||
}
|
}
|
||||||
|
@ -46,9 +60,16 @@ Result Client::open_file(i32 parent_window_id)
|
||||||
Result Client::save_file(i32 parent_window_id, String const& name, String const ext)
|
Result Client::save_file(i32 parent_window_id, String const& name, String const ext)
|
||||||
{
|
{
|
||||||
m_promise = Core::Promise<Result>::construct();
|
m_promise = Core::Promise<Result>::construct();
|
||||||
auto window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
auto parent_window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
||||||
|
auto child_window_server_client_id = expose_window_server_client_id();
|
||||||
|
|
||||||
async_prompt_save_file(window_server_client_id, parent_window_id, name.is_null() ? "Untitled" : name, ext.is_null() ? "txt" : ext, Core::StandardPaths::home_directory(), Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
GUI::WindowServerConnection::the().async_add_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
|
|
||||||
|
ScopeGuard guard([parent_window_id, child_window_server_client_id] {
|
||||||
|
GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
async_prompt_save_file(parent_window_server_client_id, parent_window_id, name.is_null() ? "Untitled" : name, ext.is_null() ? "txt" : ext, Core::StandardPaths::home_directory(), Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||||
|
|
||||||
return m_promise->await();
|
return m_promise->await();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue