From cab5ffc65e0257419fab019d03946e7b71173298 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 4 Feb 2024 17:25:27 -0800 Subject: [PATCH] build: add option to not build layershell --- CMakeLists.txt | 17 ++++++++++++++--- src/cpp/main.cpp | 8 +++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a56eb229..774d28d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ set(QT_MIN_VERSION "6.6.0") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +option(LAYERSHELL "Enable wayland layershell support" ON) + add_compile_options(-Wall -Wextra) # nix workaround @@ -18,7 +20,10 @@ if (NOT CMAKE_BUILD_TYPE) endif() find_package(Qt6 REQUIRED COMPONENTS Qml QuickControls2) -find_package(LayerShellQt REQUIRED) + +if (LAYERSHELL) + find_package(LayerShellQt REQUIRED) +endif() qt_standard_project_setup(REQUIRES 6.6) @@ -30,7 +35,6 @@ qt_add_executable(qtshell src/cpp/proxywindow.cpp src/cpp/scavenge.cpp src/cpp/rootwrapper.cpp - src/cpp/layershell.cpp src/cpp/qmlglobal.cpp src/cpp/qmlscreen.cpp ) @@ -40,4 +44,11 @@ qt_add_qml_module(qtshell URI QtShell) # qml type registration requires this target_include_directories(qtshell PRIVATE src/cpp) -target_link_libraries(qtshell PRIVATE Qt6::Qml Qt6::QuickControls2 LayerShellQtInterface) +target_link_libraries(qtshell PRIVATE Qt6::Qml Qt6::QuickControls2) + +if (LAYERSHELL) + target_link_libraries(qtshell PRIVATE LayerShellQtInterface) + target_compile_definitions(qtshell PRIVATE CONF_LAYERSHELL) + + target_sources(qtshell PRIVATE src/cpp/layershell.cpp) +endif() diff --git a/src/cpp/main.cpp b/src/cpp/main.cpp index c38c145e..f3dcfd50 100644 --- a/src/cpp/main.cpp +++ b/src/cpp/main.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -11,6 +10,10 @@ #include "rootwrapper.hpp" +#ifdef CONF_LAYERSHELL +# include +#endif + int main(int argc, char** argv) { const auto app = QGuiApplication(argc, argv); QGuiApplication::setApplicationName("qtshell"); @@ -40,7 +43,10 @@ int main(int argc, char** argv) { return -1; } +#if CONF_LAYERSHELL LayerShellQt::Shell::useLayerShell(); +#endif + // Base window transparency appears to be additive. // Use a fully transparent window with a colored rect. QQuickWindow::setDefaultAlphaBuffer(true);