Skip to content

Truly independent web browser

UI/Qt: Show the address field's suggestions over the page on Wayland

Andreas Klingb0e08fdc92b1
diff --git a/UI/Qt/Tab.cpp b/UI/Qt/Tab.cpp
index 60047a303aa..b45462f8bbb 100644
--- a/UI/Qt/Tab.cpp
+++ b/UI/Qt/Tab.cpp
@@ -224,6 +224,7 @@ void Tab::initialize(Optional<WebView::CanonicalTraversable&> traversable)
// The window's toolbar holds the address field while it shows this tab.
m_location_edit = new LocationEdit(this, m_window->is_private());
m_location_edit->hide();
+ m_location_edit->installEventFilter(this);
m_view->installEventFilter(this);
@@ -1396,6 +1397,8 @@ bool Tab::eventFilter(QObject* watched, QEvent* event)
if (m_restore_session_card)
m_restore_session_card->reposition();
}
+ if (watched == m_location_edit && event->type() == QEvent::DynamicPropertyChange && static_cast<QDynamicPropertyChangeEvent*>(event)->propertyName() == "autocompleteOpen")
+ m_view->set_suggestions_over_page(m_location_edit->property("autocompleteOpen").toBool());
return QWidget::eventFilter(watched, event);
}
diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp
index 6a692aa47dc..d0d1d1d19f6 100644
--- a/UI/Qt/WebContentView.cpp
+++ b/UI/Qt/WebContentView.cpp
@@ -1722,9 +1722,17 @@ void WebContentView::add_floating_surface(QWidget& surface)
new FloatingSurfaceWatcher(surface, [this] { schedule_repaint(); });
}
+void WebContentView::set_suggestions_over_page(bool suggestions_over_page)
+{
+ if (m_suggestions_over_page == suggestions_over_page)
+ return;
+ m_suggestions_over_page = suggestions_over_page;
+ schedule_repaint();
+}
+
bool WebContentView::has_floating_surface_over_page() const
{
- return any_of(m_floating_surfaces, [](auto const& surface) { return surface && surface->isVisible(); });
+ return m_suggestions_over_page || any_of(m_floating_surfaces, [](auto const& surface) { return surface && surface->isVisible(); });
}
// Overlays are painted by Qt, underneath whatever presents the page on some platforms, which has to step aside for them.
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.h
index 099eae9fcbb..5643c68e13a 100644
--- a/UI/Qt/WebContentView.h
+++ b/UI/Qt/WebContentView.h
@@ -177,6 +177,9 @@ public:
// A card that floats over the page, such as the find bar. Qt paints it above the page, so whatever presents the
// page above Qt's painting steps aside while it shows.
void add_floating_surface(QWidget&);
+ // The address field's suggestions float over the page as such a card does, but outlive the view, as they belong to
+ // the window.
+ void set_suggestions_over_page(bool);
void prepare_for_window_move();
void finish_window_move();
void close_select_dropdown_after_crash();
@@ -341,6 +344,7 @@ private:
QPointer<ScreenshotSelectionOverlay> m_screenshot_selection_overlay;
QPointer<ScreenshotViewer> m_screenshot_viewer;
Vector<QPointer<QWidget>> m_floating_surfaces;
+ bool m_suggestions_over_page { false };
PageOverlay* m_web_compat_report_overlay { nullptr };
bool handle_native_gesture_event(QNativeGestureEvent const&);
diff --git a/UI/Qt/WindowToolbar.cpp b/UI/Qt/WindowToolbar.cpp
index e3712e40653..f152cff2741 100644
--- a/UI/Qt/WindowToolbar.cpp
+++ b/UI/Qt/WindowToolbar.cpp
@@ -655,8 +655,9 @@ static constexpr int FIELD_PANEL_DIVIDER_INSET = 8;
static constexpr int FIELD_PANEL_LIST_PADDING = 6;
// The address field floats over its place in the toolbar, in a panel that is a native child of the window wherever the
-// page is native. So the panel stacks above the native views of the sidebar and the page, and can grow over the page,
-// while the field keeps the keyboard focus.
+// page stays native under it. So the panel stacks above the native views of the sidebar and the page, and can grow over
+// the page, while the field keeps the keyboard focus. Elsewhere, the page steps aside while the panel is grown, and Qt
+// paints them both.
class FieldPanel final : public QWidget {
public:
AK_ALLOC_WITH_KMALLOC;
@@ -665,8 +666,7 @@ public:
: QWidget(&window)
{
setObjectName("LadybirdFieldPanel");
-#if defined(AK_OS_MACOS) || defined(LADYBIRD_QT_USE_RHI_WIDGET) || defined(LADYBIRD_QT_USE_VULKAN_WINDOW)
- // The web view is native on these presentation paths, so the panel that grows over it must also be native.
+#if defined(AK_OS_MACOS) || defined(LADYBIRD_QT_USE_RHI_WIDGET)
setAttribute(Qt::WA_DontCreateNativeAncestors);
setAttribute(Qt::WA_NativeWindow);
#endif