Ladybird: Send window size and position to WebContent process

This commit is contained in:
Aliaksandr Kalenik 2023-03-08 23:57:24 +03:00 committed by Andreas Kling
parent 24d5bf8173
commit b51090e83e
Notes: sideshowbarker 2024-07-17 06:39:26 +09:00
4 changed files with 32 additions and 1 deletions

View file

@ -507,6 +507,22 @@ void BrowserWindow::copy_selected_text()
}
}
void BrowserWindow::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);
for (auto& tab : m_tabs) {
tab->view().set_window_size({ frameSize().width(), frameSize().height() });
}
}
void BrowserWindow::moveEvent(QMoveEvent* event)
{
QWidget::moveEvent(event);
for (auto& tab : m_tabs) {
tab->view().set_window_position({ event->pos().x(), event->pos().y() });
}
}
bool BrowserWindow::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::MouseButtonRelease) {

View file

@ -54,9 +54,12 @@ public slots:
void copy_selected_text();
protected:
bool eventFilter(QObject* obj, QEvent* event);
bool eventFilter(QObject* obj, QEvent* event) override;
private:
virtual void resizeEvent(QResizeEvent*) override;
virtual void moveEvent(QMoveEvent*) override;
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = "");
QTabWidget* m_tabs_container { nullptr };

View file

@ -452,6 +452,16 @@ void WebContentView::set_viewport_rect(Gfx::IntRect rect)
client().async_set_viewport_rect(rect);
}
void WebContentView::set_window_size(Gfx::IntSize size)
{
client().async_set_window_size(size);
}
void WebContentView::set_window_position(Gfx::IntPoint position)
{
client().async_set_window_position(position);
}
void WebContentView::update_viewport_rect()
{
auto scaled_width = int(viewport()->width() / m_inverse_pixel_scaling_ratio);

View file

@ -98,6 +98,8 @@ public:
ErrorOr<String> dump_layout_tree();
void set_viewport_rect(Gfx::IntRect);
void set_window_size(Gfx::IntSize);
void set_window_position(Gfx::IntPoint);
Gfx::IntPoint to_content(Gfx::IntPoint) const;
Gfx::IntPoint to_widget(Gfx::IntPoint) const;