diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp index e00d46fb45..961103c7cd 100644 --- a/UI/Qt/WebContentView.cpp +++ b/UI/Qt/WebContentView.cpp @@ -53,10 +53,25 @@ namespace Ladybird { bool is_using_dark_system_theme(QWidget&); -WebContentView::WebContentView(QWidget* window, RefPtr parent_client, size_t page_index, WebContentViewInitialState initial_state) - : WebContentViewBase(window) +static QWidget* initial_web_content_view_parent([[maybe_unused]] QWidget* window) { #ifdef AK_OS_MACOS + return nullptr; +#else + return window; +#endif +} + +WebContentView::WebContentView(QWidget* window, RefPtr parent_client, size_t page_index, WebContentViewInitialState initial_state) + : WebContentViewBase(initial_web_content_view_parent(window)) +{ +#ifdef AK_OS_MACOS + // Keep the QRhiWidget out of the top-level QWidget backing store. If it is + // parented before becoming native, Qt propagates its RHI config to the whole + // browser window and uploads the full backing store texture on chrome repaints. + setAttribute(Qt::WA_DontCreateNativeAncestors); + setAttribute(Qt::WA_NativeWindow); + setParent(window); setApi(QRhiWidget::Api::Metal); #endif diff --git a/UI/Qt/main.cpp b/UI/Qt/main.cpp index 9c3e01d0b4..316009ce9c 100644 --- a/UI/Qt/main.cpp +++ b/UI/Qt/main.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) @@ -46,10 +47,9 @@ ErrorOr ladybird_main(Main::Arguments arguments) AK::set_rich_debug_enabled(true); #ifdef AK_OS_MACOS - if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) - qputenv("QT_WIDGETS_RHI", "1"); - if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI_BACKEND")) - qputenv("QT_WIDGETS_RHI_BACKEND", "metal"); + // The web content view is a native QRhiWidget child. Keep it from forcing + // every sibling in the tab UI to become native as well. + QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #endif auto app = TRY(Ladybird::Application::create(arguments));