mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Browser: Inform WebView processes of the browser window's position/size
This commit is contained in:
parent
6aea60e6ee
commit
325e3c7bc6
5 changed files with 53 additions and 0 deletions
|
@ -682,4 +682,36 @@ void BrowserWindow::config_bool_did_change(String const& domain, String const& g
|
||||||
// NOTE: CloseDownloadWidgetOnFinish is read each time in DownloadWindow
|
// NOTE: CloseDownloadWidgetOnFinish is read each time in DownloadWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BrowserWindow::broadcast_window_position(Gfx::IntPoint const& position)
|
||||||
|
{
|
||||||
|
tab_widget().for_each_child_of_type<Browser::Tab>([&](auto& tab) {
|
||||||
|
tab.window_position_changed(position);
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWindow::broadcast_window_size(Gfx::IntSize const& size)
|
||||||
|
{
|
||||||
|
tab_widget().for_each_child_of_type<Browser::Tab>([&](auto& tab) {
|
||||||
|
tab.window_size_changed(size);
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWindow::event(Core::Event& event)
|
||||||
|
{
|
||||||
|
switch (event.type()) {
|
||||||
|
case GUI::Event::Move:
|
||||||
|
broadcast_window_position(static_cast<GUI::MoveEvent&>(event).position());
|
||||||
|
break;
|
||||||
|
case GUI::Event::Resize:
|
||||||
|
broadcast_window_size(static_cast<GUI::ResizeEvent&>(event).size());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Window::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@ public:
|
||||||
void content_filters_changed();
|
void content_filters_changed();
|
||||||
void proxy_mappings_changed();
|
void proxy_mappings_changed();
|
||||||
|
|
||||||
|
void broadcast_window_position(Gfx::IntPoint const&);
|
||||||
|
void broadcast_window_size(Gfx::IntSize const&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit BrowserWindow(CookieJar&, URL);
|
explicit BrowserWindow(CookieJar&, URL);
|
||||||
|
|
||||||
|
@ -53,6 +56,8 @@ private:
|
||||||
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override;
|
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override;
|
||||||
virtual void config_bool_did_change(String const& domain, String const& group, String const& key, bool value) override;
|
virtual void config_bool_did_change(String const& domain, String const& group, String const& key, bool value) override;
|
||||||
|
|
||||||
|
virtual void event(Core::Event&) override;
|
||||||
|
|
||||||
RefPtr<GUI::Action> m_go_back_action;
|
RefPtr<GUI::Action> m_go_back_action;
|
||||||
RefPtr<GUI::Action> m_go_forward_action;
|
RefPtr<GUI::Action> m_go_forward_action;
|
||||||
RefPtr<GUI::Action> m_go_home_action;
|
RefPtr<GUI::Action> m_go_home_action;
|
||||||
|
|
|
@ -545,6 +545,16 @@ void Tab::action_left(GUI::Action&)
|
||||||
m_statusbar->set_override_text({});
|
m_statusbar->set_override_text({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tab::window_position_changed(Gfx::IntPoint const& position)
|
||||||
|
{
|
||||||
|
m_web_content_view->set_window_position(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tab::window_size_changed(Gfx::IntSize const& size)
|
||||||
|
{
|
||||||
|
m_web_content_view->set_window_size(size);
|
||||||
|
}
|
||||||
|
|
||||||
BrowserWindow const& Tab::window() const
|
BrowserWindow const& Tab::window() const
|
||||||
{
|
{
|
||||||
return static_cast<BrowserWindow const&>(*Widget::window());
|
return static_cast<BrowserWindow const&>(*Widget::window());
|
||||||
|
|
|
@ -57,6 +57,9 @@ public:
|
||||||
void action_entered(GUI::Action&);
|
void action_entered(GUI::Action&);
|
||||||
void action_left(GUI::Action&);
|
void action_left(GUI::Action&);
|
||||||
|
|
||||||
|
void window_position_changed(Gfx::IntPoint const&);
|
||||||
|
void window_size_changed(Gfx::IntSize const&);
|
||||||
|
|
||||||
Function<void(String const&)> on_title_change;
|
Function<void(String const&)> on_title_change;
|
||||||
Function<void(const URL&)> on_tab_open_request;
|
Function<void(const URL&)> on_tab_open_request;
|
||||||
Function<void(Tab&)> on_tab_close_request;
|
Function<void(Tab&)> on_tab_close_request;
|
||||||
|
|
|
@ -190,5 +190,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
window->broadcast_window_position(window->position());
|
||||||
|
window->broadcast_window_size(window->size());
|
||||||
|
|
||||||
return app->exec();
|
return app->exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue