From 1c398b32ce022161dc96da7c036e28bb3691d5c7 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 9 Nov 2022 10:04:09 -0500 Subject: Browser+LibWebView+WebContent: Add IPC to minimize and maximize window Requests to maximize and minimize Browser windows will be coming from the WebContent process rather than the WebDriver process. Add hooks to propagate these requests back up to the Browser. --- Userland/Libraries/LibWebView/OutOfProcessWebView.cpp | 14 ++++++++++++++ Userland/Libraries/LibWebView/OutOfProcessWebView.h | 4 ++++ Userland/Libraries/LibWebView/ViewImplementation.h | 2 ++ Userland/Libraries/LibWebView/WebContentClient.cpp | 10 ++++++++++ Userland/Libraries/LibWebView/WebContentClient.h | 2 ++ 5 files changed, 32 insertions(+) (limited to 'Userland/Libraries/LibWebView') diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index f05acd7f7f..7e6422e869 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -421,6 +421,20 @@ Gfx::IntSize OutOfProcessWebView::notify_server_did_request_resize_window(Gfx::I return {}; } +Gfx::IntRect OutOfProcessWebView::notify_server_did_request_maximize_window() +{ + if (on_maximize_window) + return on_maximize_window(); + return {}; +} + +Gfx::IntRect OutOfProcessWebView::notify_server_did_request_minimize_window() +{ + if (on_minimize_window) + return on_minimize_window(); + 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); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index 830c86c96d..269c5d3313 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -115,6 +115,8 @@ public: Function on_restore_window; Function on_reposition_window; Function on_resize_window; + Function on_maximize_window; + Function on_minimize_window; private: OutOfProcessWebView(); @@ -175,6 +177,8 @@ private: 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 Gfx::IntRect notify_server_did_request_maximize_window() override; + virtual Gfx::IntRect notify_server_did_request_minimize_window() 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 306442428a..6294114da7 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.h +++ b/Userland/Libraries/LibWebView/ViewImplementation.h @@ -53,6 +53,8 @@ public: 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 Gfx::IntRect notify_server_did_request_maximize_window() = 0; + virtual Gfx::IntRect notify_server_did_request_minimize_window() = 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 9edadcdab4..c5bb0a8afd 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -215,6 +215,16 @@ Messages::WebContentClient::DidRequestResizeWindowResponse WebContentClient::did return m_view.notify_server_did_request_resize_window(size); } +Messages::WebContentClient::DidRequestMaximizeWindowResponse WebContentClient::did_request_maximize_window() +{ + return m_view.notify_server_did_request_maximize_window(); +} + +Messages::WebContentClient::DidRequestMinimizeWindowResponse WebContentClient::did_request_minimize_window() +{ + return m_view.notify_server_did_request_minimize_window(); +} + 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 9c4c26926d..b8ee9f4ab5 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.h +++ b/Userland/Libraries/LibWebView/WebContentClient.h @@ -64,6 +64,8 @@ private: 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 Messages::WebContentClient::DidRequestMaximizeWindowResponse did_request_maximize_window() override; + virtual Messages::WebContentClient::DidRequestMinimizeWindowResponse did_request_minimize_window() override; virtual void did_request_file(String const& path, i32) override; ViewImplementation& m_view; -- cgit v1.2.3