diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 4559f7a3ad..8eca540417 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -248,6 +248,22 @@ Tab::Tab(BrowserWindow& window) update_status({}, count_waiting); }; + view().on_restore_window = [this]() { + this->window().show(); + this->window().move_to_front(); + m_web_content_view->set_system_visibility_state(true); + }; + + view().on_reposition_window = [this](Gfx::IntPoint const& position) { + this->window().move_to(position); + return this->window().position(); + }; + + view().on_resize_window = [this](Gfx::IntSize const& size) { + this->window().resize(size); + return this->window().size(); + }; + m_link_context_menu = GUI::Menu::construct(); auto link_default_action = GUI::Action::create("&Open", g_icon_bag.go_to, [this](auto&) { view().on_link_click(m_link_context_menu_url, "", 0); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index a354601df4..f05acd7f7f 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -401,6 +401,26 @@ void OutOfProcessWebView::notify_server_did_update_resource_count(i32 count_wait on_resource_status_change(count_waiting); } +void OutOfProcessWebView::notify_server_did_request_restore_window() +{ + if (on_restore_window) + on_restore_window(); +} + +Gfx::IntPoint OutOfProcessWebView::notify_server_did_request_reposition_window(Gfx::IntPoint const& position) +{ + if (on_reposition_window) + return on_reposition_window(position); + return {}; +} + +Gfx::IntSize OutOfProcessWebView::notify_server_did_request_resize_window(Gfx::IntSize const& size) +{ + if (on_resize_window) + return on_resize_window(size); + return {}; +} + void OutOfProcessWebView::notify_server_did_request_file(Badge, String const& path, i32 request_id) { auto file = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window(), path); @@ -642,14 +662,19 @@ void OutOfProcessWebView::focusout_event(GUI::FocusEvent&) client().async_set_has_focus(false); } +void OutOfProcessWebView::set_system_visibility_state(bool visible) +{ + client().async_set_system_visibility_state(visible); +} + void OutOfProcessWebView::show_event(GUI::ShowEvent&) { - client().async_set_system_visibility_state(true); + set_system_visibility_state(true); } void OutOfProcessWebView::hide_event(GUI::HideEvent&) { - client().async_set_system_visibility_state(false); + set_system_visibility_state(false); } } diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index a2d24d455b..830c86c96d 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -84,6 +84,8 @@ public: void set_window_position(Gfx::IntPoint const&); void set_window_size(Gfx::IntSize const&); + void set_system_visibility_state(bool visible); + Gfx::ShareableBitmap take_screenshot() const; Gfx::ShareableBitmap take_element_screenshot(i32 element_id); Gfx::ShareableBitmap take_document_screenshot(); @@ -110,6 +112,9 @@ public: Function on_get_cookie; Function on_set_cookie; Function on_resource_status_change; + Function on_restore_window; + Function on_reposition_window; + Function on_resize_window; private: OutOfProcessWebView(); @@ -167,6 +172,9 @@ private: virtual String notify_server_did_request_cookie(Badge, const AK::URL& url, Web::Cookie::Source source) override; virtual void notify_server_did_set_cookie(Badge, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) override; virtual void notify_server_did_update_resource_count(i32 count_waiting) override; + virtual void notify_server_did_request_restore_window() override; + virtual Gfx::IntPoint notify_server_did_request_reposition_window(Gfx::IntPoint const&) override; + virtual Gfx::IntSize notify_server_did_request_resize_window(Gfx::IntSize const&) override; virtual void notify_server_did_request_file(Badge, String const& path, i32) override; void request_repaint(); diff --git a/Userland/Libraries/LibWebView/ViewImplementation.h b/Userland/Libraries/LibWebView/ViewImplementation.h index 2421907b70..306442428a 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.h +++ b/Userland/Libraries/LibWebView/ViewImplementation.h @@ -50,6 +50,9 @@ public: virtual String notify_server_did_request_cookie(Badge, const AK::URL& url, Web::Cookie::Source source) = 0; virtual void notify_server_did_set_cookie(Badge, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) = 0; virtual void notify_server_did_update_resource_count(i32 count_waiting) = 0; + virtual void notify_server_did_request_restore_window() = 0; + virtual Gfx::IntPoint notify_server_did_request_reposition_window(Gfx::IntPoint const&) = 0; + virtual Gfx::IntSize notify_server_did_request_resize_window(Gfx::IntSize const&) = 0; virtual void notify_server_did_request_file(Badge, String const& path, i32) = 0; }; diff --git a/Userland/Libraries/LibWebView/WebContentClient.cpp b/Userland/Libraries/LibWebView/WebContentClient.cpp index 2388e560e5..9edadcdab4 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -200,6 +200,21 @@ void WebContentClient::did_update_resource_count(i32 count_waiting) m_view.notify_server_did_update_resource_count(count_waiting); } +void WebContentClient::did_request_restore_window() +{ + m_view.notify_server_did_request_restore_window(); +} + +Messages::WebContentClient::DidRequestRepositionWindowResponse WebContentClient::did_request_reposition_window(Gfx::IntPoint const& position) +{ + return m_view.notify_server_did_request_reposition_window(position); +} + +Messages::WebContentClient::DidRequestResizeWindowResponse WebContentClient::did_request_resize_window(Gfx::IntSize const& size) +{ + return m_view.notify_server_did_request_resize_window(size); +} + void WebContentClient::did_request_file(String const& path, i32 request_id) { m_view.notify_server_did_request_file({}, path, request_id); diff --git a/Userland/Libraries/LibWebView/WebContentClient.h b/Userland/Libraries/LibWebView/WebContentClient.h index 11c08f011a..9c4c26926d 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.h +++ b/Userland/Libraries/LibWebView/WebContentClient.h @@ -61,6 +61,9 @@ private: virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(AK::URL const&, u8) override; virtual void did_set_cookie(AK::URL const&, Web::Cookie::ParsedCookie const&, u8) override; virtual void did_update_resource_count(i32 count_waiting) override; + virtual void did_request_restore_window() override; + virtual Messages::WebContentClient::DidRequestRepositionWindowResponse did_request_reposition_window(Gfx::IntPoint const&) override; + virtual Messages::WebContentClient::DidRequestResizeWindowResponse did_request_resize_window(Gfx::IntSize const&) override; virtual void did_request_file(String const& path, i32) override; ViewImplementation& m_view; diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc index a98f3b03b2..104c642089 100644 --- a/Userland/Services/WebContent/WebContentClient.ipc +++ b/Userland/Services/WebContent/WebContentClient.ipc @@ -38,6 +38,9 @@ endpoint WebContentClient did_request_cookie(URL url, u8 source) => (String cookie) did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) =| did_update_resource_count(i32 count_waiting) =| + did_request_restore_window() =| + did_request_reposition_window(Gfx::IntPoint position) => (Gfx::IntPoint window_position) + did_request_resize_window(Gfx::IntSize size) => (Gfx::IntSize window_size) did_request_file(String path, i32 request_id) =| did_output_js_console_message(i32 message_index) =|