From 9945246a5d73773041508e801855f6e3864431e0 Mon Sep 17 00:00:00 2001 From: just-some-entity Date: Sat, 8 Nov 2025 23:36:51 +0100 Subject: [PATCH 1/4] Added support for webview and changed qArgc in launch.cpp from 0 to 1 since webview expects QCoreApplication to atleast have the program name as argument, otherwise aborts leading to a crash in quickshell. --- CMakeLists.txt | 5 +++++ src/launch/CMakeLists.txt | 5 +++++ src/launch/launch.cpp | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 880b9ca3..4b77cd93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,7 @@ boption(SERVICE_GREETD "Greetd" ON) boption(SERVICE_UPOWER "UPower" ON) boption(SERVICE_NOTIFICATIONS "Notifications" ON) boption(BLUETOOTH "Bluetooth" ON) +boption(WEBVIEW "WebView" ON) include(cmake/install-qml-module.cmake) include(cmake/util.cmake) @@ -127,6 +128,10 @@ if (DBUS) list(APPEND QT_FPDEPS DBus) endif() +if (WEBVIEW) + list(APPEND QT_FPDEPS WebView) +endif() + find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS}) # In Qt 6.10, private dependencies are required to be explicit, diff --git a/src/launch/CMakeLists.txt b/src/launch/CMakeLists.txt index 4db11bf0..358c9791 100644 --- a/src/launch/CMakeLists.txt +++ b/src/launch/CMakeLists.txt @@ -11,6 +11,11 @@ target_link_libraries(quickshell-launch PRIVATE Qt::Quick Qt::Widgets CLI11::CLI11 quickshell-build ) +if(WEBVIEW) + add_compile_definitions(WEBVIEW_ENABLED) + target_link_libraries(quickshell-launch PRIVATE Qt::WebView) +endif() + qs_add_pchset(launch DEPENDENCIES Qt::Core CLI11::CLI11 HEADERS diff --git a/src/launch/launch.cpp b/src/launch/launch.cpp index f269f61d..7585717c 100644 --- a/src/launch/launch.cpp +++ b/src/launch/launch.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef WEBVIEW_ENABLED +#include +#endif + #include "../core/common.hpp" #include "../core/instanceinfo.hpp" #include "../core/logging.hpp" @@ -222,7 +226,13 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio delete coreApplication; QGuiApplication* app = nullptr; - auto qArgC = 0; + auto qArgC = 1; + +#ifdef WEBVIEW_ENABLED + if (qEnvironmentVariable("QS_WEBVIEW", "0") == "1") { + QtWebView::initialize(); + } +#endif if (pragmas.useQApplication) { app = new QApplication(qArgC, argv); From 93a6468cfed7ccd50ced8de6f65439c6cc36c804 Mon Sep 17 00:00:00 2001 From: just-some-entity Date: Tue, 11 Nov 2025 09:29:18 +0100 Subject: [PATCH 2/4] Removed compile options for webengine support. Added pragma for loading Qt6WebEngineQuick at runtime --- CMakeLists.txt | 4 ---- src/launch/CMakeLists.txt | 5 ----- src/launch/launch.cpp | 13 +++++-------- src/webengine/webengine.hpp | 39 +++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 src/webengine/webengine.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b962d94..00d67d14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,10 +129,6 @@ if (DBUS) list(APPEND QT_FPDEPS DBus) endif() -if (WEBVIEW) - list(APPEND QT_FPDEPS WebView) -endif() - find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS}) # In Qt 6.10, private dependencies are required to be explicit, diff --git a/src/launch/CMakeLists.txt b/src/launch/CMakeLists.txt index 358c9791..4db11bf0 100644 --- a/src/launch/CMakeLists.txt +++ b/src/launch/CMakeLists.txt @@ -11,11 +11,6 @@ target_link_libraries(quickshell-launch PRIVATE Qt::Quick Qt::Widgets CLI11::CLI11 quickshell-build ) -if(WEBVIEW) - add_compile_definitions(WEBVIEW_ENABLED) - target_link_libraries(quickshell-launch PRIVATE Qt::WebView) -endif() - qs_add_pchset(launch DEPENDENCIES Qt::Core CLI11::CLI11 HEADERS diff --git a/src/launch/launch.cpp b/src/launch/launch.cpp index 7585717c..63aa2ed1 100644 --- a/src/launch/launch.cpp +++ b/src/launch/launch.cpp @@ -17,10 +17,6 @@ #include #include -#ifdef WEBVIEW_ENABLED -#include -#endif - #include "../core/common.hpp" #include "../core/instanceinfo.hpp" #include "../core/logging.hpp" @@ -28,6 +24,7 @@ #include "../core/plugin.hpp" #include "../core/rootwrapper.hpp" #include "../ipc/ipc.hpp" +#include "../webengine/webengine.hpp" #include "build.hpp" #include "launch_p.hpp" @@ -78,6 +75,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio bool nativeTextRendering = false; bool desktopSettingsAware = true; bool useSystemStyle = false; + bool useQtWebEngineQuick = false; QString iconTheme = qEnvironmentVariable("QS_ICON_THEME"); QHash envOverrides; QString dataDir; @@ -95,6 +93,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio else if (pragma == "NativeTextRendering") pragmas.nativeTextRendering = true; else if (pragma == "IgnoreSystemSettings") pragmas.desktopSettingsAware = false; else if (pragma == "RespectSystemStyle") pragmas.useSystemStyle = true; + else if (pragma == "EnableQtWebEngineQuick") pragmas.useQtWebEngineQuick = true; else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10); else if (pragma.startsWith("Env ")) { auto envPragma = pragma.sliced(4); @@ -228,11 +227,9 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio QGuiApplication* app = nullptr; auto qArgC = 1; -#ifdef WEBVIEW_ENABLED - if (qEnvironmentVariable("QS_WEBVIEW", "0") == "1") { - QtWebView::initialize(); + if(pragmas.useQtWebEngineQuick) { + web_engine::init(); } -#endif if (pragmas.useQApplication) { app = new QApplication(qArgC, argv); diff --git a/src/webengine/webengine.hpp b/src/webengine/webengine.hpp new file mode 100644 index 00000000..2b135022 --- /dev/null +++ b/src/webengine/webengine.hpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +namespace qs::web_engine { + +inline void init() +{ + using InitializeFunc = void (*)(); + + QLibrary lib("Qt6WebEngineQuick"); + if (!lib.load()) { + qWarning() << "Failed to load library:" << lib.errorString(); + qWarning() << "You might need to install the necessary package for Qt6WebEngineQuick."; + qWarning() << "QtWebEngineQuick is not Loaded. Using the qml type WebEngineView from " + "QtWebEngine might lead to undefined behaviour!"; + return; + } + + qDebug() << "Loaded library Qt6WebEngineQuick"; + + auto initialize = reinterpret_cast(lib.resolve("_ZN16QtWebEngineQuick10initializeEv")); + if (!initialize) { + qWarning() << "Failed to resolve symbol 'void QtWebEngineQuick::initialize()' in lib " + "Qt6WebEngineQuick. This should not happen"; + qWarning() << "QtWebEngineQuick is not Loaded. Using the qml type WebEngineView from " + "QtWebEngine might lead to undefined behaviour!"; + return; + } + + qDebug() << "Found symbol QtWebEngineQuick::initialize(). Initializing WebEngine..."; + + initialize(); + + qDebug() << "Successfully initialized QtWebEngineQuick"; +} + +} // namespace qs::web_engine \ No newline at end of file From e78c7e3d2e5a457164586cae500d752c00fc3288 Mon Sep 17 00:00:00 2001 From: just-some-entity Date: Tue, 11 Nov 2025 09:41:40 +0100 Subject: [PATCH 3/4] remove boption for webview in CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00d67d14..c8670013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,6 @@ boption(SERVICE_GREETD "Greetd" ON) boption(SERVICE_UPOWER "UPower" ON) boption(SERVICE_NOTIFICATIONS "Notifications" ON) boption(BLUETOOTH "Bluetooth" ON) -boption(WEBVIEW "WebView" ON) include(cmake/install-qml-module.cmake) include(cmake/util.cmake) From 8d3ad7d88b66b0cc37adc8420783035ff97c722a Mon Sep 17 00:00:00 2001 From: just-some-entity Date: Tue, 11 Nov 2025 09:51:44 +0100 Subject: [PATCH 4/4] format code with clangd --- src/launch/launch.cpp | 2 +- src/webengine/webengine.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/launch/launch.cpp b/src/launch/launch.cpp index 63aa2ed1..4c617cc8 100644 --- a/src/launch/launch.cpp +++ b/src/launch/launch.cpp @@ -227,7 +227,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio QGuiApplication* app = nullptr; auto qArgC = 1; - if(pragmas.useQtWebEngineQuick) { + if (pragmas.useQtWebEngineQuick) { web_engine::init(); } diff --git a/src/webengine/webengine.hpp b/src/webengine/webengine.hpp index 2b135022..3cd3aaf1 100644 --- a/src/webengine/webengine.hpp +++ b/src/webengine/webengine.hpp @@ -5,8 +5,7 @@ namespace qs::web_engine { -inline void init() -{ +inline void init() { using InitializeFunc = void (*)(); QLibrary lib("Qt6WebEngineQuick"); @@ -20,7 +19,8 @@ inline void init() qDebug() << "Loaded library Qt6WebEngineQuick"; - auto initialize = reinterpret_cast(lib.resolve("_ZN16QtWebEngineQuick10initializeEv")); + auto initialize = + reinterpret_cast(lib.resolve("_ZN16QtWebEngineQuick10initializeEv")); if (!initialize) { qWarning() << "Failed to resolve symbol 'void QtWebEngineQuick::initialize()' in lib " "Qt6WebEngineQuick. This should not happen";