Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ boption(SERVICE_UPOWER "UPower" ON)
boption(SERVICE_NOTIFICATIONS "Notifications" ON)
boption(BLUETOOTH "Bluetooth" ON)
boption(NETWORK "Network" ON)
boption(WEBENGINE "WebEngine" ON)

if (WEBENGINE_effective AND USE_JEMALLOC_effective)
message(FATAL_ERROR "WEBENGINE and USE_JEMALLOC are incompatible. "
"Chromium's PartitionAlloc conflicts with jemalloc. "
"Set -DUSE_JEMALLOC=OFF to use WebEngine.")
endif()

include(cmake/install-qml-module.cmake)
include(cmake/util.cmake)

Expand Down Expand Up @@ -144,10 +136,6 @@ if (DBUS)
list(APPEND QT_FPDEPS DBus)
endif()

if (WEBENGINE_effective)
list(APPEND QT_FPDEPS WebEngineQuick)
endif()

find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS})

# In Qt 6.10, private dependencies are required to be explicit,
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_subdirectory(ipc)
add_subdirectory(window)
add_subdirectory(io)
add_subdirectory(widgets)
add_subdirectory(webengine)
add_subdirectory(ui)

if (CRASH_HANDLER)
Expand Down
6 changes: 0 additions & 6 deletions src/build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ else()
set(CRASH_HANDLER_DEF 0)
endif()

if (WEBENGINE)
set(WEBENGINE_DEF 1)
else()
set(WEBENGINE_DEF 0)
endif()

configure_file(build.hpp.in build.hpp @ONLY ESCAPE_QUOTES)

target_include_directories(quickshell-build INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
1 change: 0 additions & 1 deletion src/build/build.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define GIT_REVISION "@GIT_REVISION@"
#define DISTRIBUTOR "@DISTRIBUTOR@"
#define CRASH_HANDLER @CRASH_HANDLER_DEF@
#define WEBENGINE @WEBENGINE_DEF@
#define BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#define COMPILER "@CMAKE_CXX_COMPILER_ID@ (@CMAKE_CXX_COMPILER_VERSION@)"
#define COMPILE_FLAGS "@CMAKE_CXX_FLAGS@"
Expand Down
4 changes: 0 additions & 4 deletions src/launch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,4 @@ qs_add_pchset(launch

qs_pch(quickshell-launch SET launch)

if (WEBENGINE)
target_link_libraries(quickshell-launch PRIVATE Qt::WebEngineQuick)
endif()

target_link_libraries(quickshell PRIVATE quickshell-launch)
12 changes: 4 additions & 8 deletions src/launch/launch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#include "../crash/handler.hpp"
#endif

#if WEBENGINE
#include <qtwebenginequickglobal.h>
#endif
#include "../webengine/webengine.hpp"

namespace qs::launch {

Expand Down Expand Up @@ -96,6 +94,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 == "UseWebEngine") pragmas.useWebEngine = true;
else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10);
else if (pragma.startsWith("Env ")) {
auto envPragma = pragma.sliced(4);
Expand All @@ -117,8 +116,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
pragmas.stateDir = pragma.sliced(9).trimmed();
} else if (pragma.startsWith("CacheDir ")) {
pragmas.cacheDir = pragma.sliced(9).trimmed();
} else if (pragma == "UseWebEngine") pragmas.useWebEngine = true;
else {
} else {
qCritical() << "Unrecognized pragma" << pragma;
return -1;
}
Expand Down Expand Up @@ -231,11 +229,9 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
QGuiApplication* app = nullptr;
auto qArgC = 1; // argv[0] must be valid; Chromium requires it, Qt won't consume it

#if WEBENGINE
if (pragmas.useWebEngine) {
QtWebEngineQuick::initialize();
qs::web_engine::init();
}
#endif

if (pragmas.useQApplication) {
app = new QApplication(qArgC, argv);
Expand Down
3 changes: 3 additions & 0 deletions src/webengine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (BUILD_TESTING)
add_subdirectory(test)
endif()
3 changes: 3 additions & 0 deletions src/webengine/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(webengine webengine.cpp)
target_link_libraries(webengine PRIVATE Qt::Core Qt::Test)
add_test(NAME webengine WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMAND $<TARGET_FILE:webengine>)
14 changes: 14 additions & 0 deletions src/webengine/test/manual/webengine.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ pragma UseWebEngine

import Quickshell
import QtWebEngine

FloatingWindow {
width: 800
height: 600

WebEngineView {
anchors.fill: parent
url: "data:text/html,<h1>WebEngine works</h1><p>If you see this, QtWebEngineQuick initialized correctly.</p>"
}
}
10 changes: 10 additions & 0 deletions src/webengine/test/webengine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "webengine.hpp"

#include <qtest.h>
#include <qtestcase.h>

#include "../webengine.hpp"

void WebEngineInitTest::init() { QVERIFY(qs::web_engine::init()); }

QTEST_MAIN(WebEngineInitTest)
11 changes: 11 additions & 0 deletions src/webengine/test/webengine.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <qobject.h>
#include <qtmetamacros.h>

class WebEngineInitTest: public QObject {
Q_OBJECT;

private slots:
static void init();
};
44 changes: 44 additions & 0 deletions src/webengine/webengine.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <qdebug.h>
#include <qlibrary.h>
#include <qlogging.h>

namespace qs::web_engine {

inline bool 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 false;
}

qDebug() << "Loaded library Qt6WebEngineQuick";

auto initialize =
reinterpret_cast<InitializeFunc>(lib.resolve("_ZN16QtWebEngineQuick10initializeEv")); // NOLINT
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 false;
}

qDebug() << "Found symbol QtWebEngineQuick::initialize(). Initializing WebEngine...";

initialize();

qWarning() << "WebEngine initialized. Note: WebEngine is incompatible with jemalloc."
" If quickshell crashes immediately, rebuild with -DUSE_JEMALLOC=OFF.";

qDebug() << "Successfully initialized QtWebEngineQuick";
return true;
}

} // namespace qs::web_engine