build: add option to not build layershell

This commit is contained in:
outfoxxed 2024-02-04 17:25:27 -08:00
parent 767500b466
commit cab5ffc65e
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 21 additions and 4 deletions

View file

@ -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)
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()

View file

@ -1,4 +1,3 @@
#include <LayerShellQt/shell.h>
#include <qcommandlineoption.h>
#include <qcommandlineparser.h>
#include <qdir.h>
@ -11,6 +10,10 @@
#include "rootwrapper.hpp"
#ifdef CONF_LAYERSHELL
# include <LayerShellQt/shell.h>
#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);