diff --git a/CMakeLists.txt b/CMakeLists.txt index 42fcbb95..6a3c7165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,13 @@ endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_CXX_STANDARD 20) +set(THIRD_PARTY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) -set(THIRD_PARTY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/") +list(APPEND CMAKE_MODULE_PATH "${THIRD_PARTY_PATH}/ecm/modules") +list(APPEND CMAKE_MODULE_PATH "${THIRD_PARTY_PATH}/ecm/find-modules") +list(APPEND CMAKE_MODULE_PATH "${THIRD_PARTY_PATH}/ecm/kde-modules") +message(STATUS "[PROJECT] CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") + option(OSX_BUNDLE "Enable distribution macOS bundle" OFF) set(CMAKE_OSX_DEPLOYMENT_TARGET "13.0") @@ -108,6 +113,12 @@ endif() add_subdirectory(CMake) add_subdirectory(ThirdParty) +# if(UNIX and not APPLE) +# # Needs to be append, because we include ecm as third party on linux +# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") +# else() + +# endif() add_subdirectory(Tools) add_subdirectory(ScreenPlay) @@ -148,6 +159,7 @@ message(STATUS "[OPTION] SCREENPLAY_TESTS = ${SCREENPLAY_TESTS}") message(STATUS "[PROJECT] SCREENPLAY_QML_MODULES_PATH = ${SCREENPLAY_QML_MODULES_PATH}") message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") message(STATUS "[PROJECT] VCPKG_PATH = ${VCPKG_PATH}") +message(STATUS "[PROJECT] CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") message(STATUS "[PROJECT] VCPKG_TARGET_TRIPLET = ${VCPKG_TARGET_TRIPLET}") message(STATUS "[PROJECT] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") message(STATUS "[PROJECT] CMAKE_VERSION = ${CMAKE_VERSION}") diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index dacb73ba..d8c5fe3d 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -30,8 +30,8 @@ elseif(APPLE) src/macintegration.h src/macwindow.h) elseif(UNIX) - set(SOURCES src/linuxx11window.cpp) - set(HEADER src/linuxx11window.h) + set(SOURCES src/linuxx11window.cpp src/linuxwaylandwindow.cpp) + set(HEADER src/linuxx11window.h src/linuxwaylandwindow.h) endif() set(SOURCES ${SOURCES} main.cpp src/basewindow.cpp) @@ -86,6 +86,9 @@ elseif(UNIX AND NOT APPLE) endif() if(UNIX AND NOT APPLE) + find_package(ECM CONFIG REQUIRED NO_MODULE) + find_package(LayerShellQt REQUIRED) + include(CopyRecursive) copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/kde/ScreenPlay ${CMAKE_BINARY_DIR}/bin/kde/ScreenPlay "*") endif() diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index 6fbad4d4..1d5e4cd2 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -15,6 +15,7 @@ Q_IMPORT_QML_PLUGIN(ScreenPlaySysInfoPlugin) #elif defined(Q_OS_LINUX) #include "src/linuxx11window.h" +#include "src/linuxwaylandwindow.h" #elif defined(Q_OS_OSX) #include "src/macwindow.h" #endif @@ -33,7 +34,8 @@ int main(int argc, char* argv[]) #if defined(Q_OS_WIN) WinWindow window; #elif defined(Q_OS_LINUX) - LinuxX11Window window; + //LinuxX11Window window; + LinuxWaylandWindow window; #elif defined(Q_OS_OSX) MacWindow window; #endif diff --git a/ScreenPlayWallpaper/src/linuxwaylandwindow.cpp b/ScreenPlayWallpaper/src/linuxwaylandwindow.cpp new file mode 100644 index 00000000..9f05b864 --- /dev/null +++ b/ScreenPlayWallpaper/src/linuxwaylandwindow.cpp @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only +#include "linuxwaylandwindow.h" +#include + +#include "qwaylandlayersurface.h" +#include "qwaylandlayershellintegration.h" + +#include + +ScreenPlay::WallpaperExitCode LinuxWaylandWindow::start() +{ + + if (!debugMode()) { + connect(m_sdk.get(), &ScreenPlaySDK::sdkDisconnected, this, &LinuxWaylandWindow::destroyThis); + } + + qmlRegisterSingletonInstance("ScreenPlayWallpaper", 1, 0, "Wallpaper", this); + + QDir workingDir(QGuiApplication::instance()->applicationDirPath()); + m_window.engine()->addImportPath(workingDir.path() + "/qml"); + m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); + m_window.setSource(QUrl("qrc:/qml/ScreenPlayWallpaper/qml/Wallpaper.qml")); + + // Get the Wayland display + if (QGuiApplication::platformName() == "wayland") { + QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); + void *display = native->nativeResourceForWindow("display", nullptr); + + // Create the layer shell + LayerShellQt::QWaylandLayerShellIntegration layerShell(display); + + // Create the layer surface + LayerShellQt::QWaylandLayerSurface layerSurface(&layerShell, window.windowHandle()); + + // Set the layer to background + layerSurface.setLayer(LayerShellQt::zwlr_layer_shell_v1::layer::background); + + // Set the size of the layer surface to match the screen size + QScreen *screen = QGuiApplication::primaryScreen(); + layerSurface.setSize(screen->size().width(), screen->size().height()); + + // Set the anchor to all edges + layerSurface.setAnchor(LayerShellQt::zwlr_layer_surface_v1::anchor::top | + LayerShellQt::zwlr_layer_surface_v1::anchor::bottom | + LayerShellQt::zwlr_layer_surface_v1::anchor::left | + LayerShellQt::zwlr_layer_surface_v1::anchor::right); + } + + m_window.show(); + return ScreenPlay::WallpaperExitCode::Ok; +} + +void LinuxWaylandWindow::setupWallpaperForOneScreen(int activeScreen) +{ +} + +void LinuxWaylandWindow::setupWallpaperForAllScreens() +{ +} + +void LinuxWaylandWindow::setupWallpaperForMultipleScreens(const QVector& activeScreensList) +{ +} + +void LinuxWaylandWindow::setVisible(bool show) +{ + m_window.setVisible(show); +} + +void LinuxWaylandWindow::destroyThis() +{ + QCoreApplication::quit(); +} + +void LinuxWaylandWindow::terminate() +{ + QCoreApplication::quit(); +} \ No newline at end of file diff --git a/ScreenPlayWallpaper/src/linuxwaylandwindow.h b/ScreenPlayWallpaper/src/linuxwaylandwindow.h new file mode 100644 index 00000000..2a949a61 --- /dev/null +++ b/ScreenPlayWallpaper/src/linuxwaylandwindow.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "basewindow.h" + +class LinuxWaylandWindow : public BaseWindow { + Q_OBJECT + +public: + ScreenPlay::WallpaperExitCode start() override; + +signals: + +public slots: + void setVisible(bool show) override; + void destroyThis() override; + void terminate() override; + +private: + QQuickView m_window; + void setupWallpaperForOneScreen(int activeScreen); + void setupWallpaperForAllScreens(); + void setupWallpaperForMultipleScreens(const QVector& activeScreensList); +}; diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 56e23b71..be485917 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -8,13 +8,30 @@ FetchContent_Populate( # https://bugreports.qt.io/browse/QTCREATORBUG-27083 SOURCE_DIR ${THIRD_PARTY_PATH}/QArchive) -FetchContent_Populate( - qml-plausible - GIT_REPOSITORY https://gitlab.com/kelteseth/qml-plausible.git - GIT_TAG 5069ba3bf25663ea06be8b94c398d6c61058d4d5 - # Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder - # https://bugreports.qt.io/browse/QTCREATORBUG-27083 - SOURCE_DIR ${THIRD_PARTY_PATH}/qml-plausible) - + FetchContent_Populate( + qml-plausible + GIT_REPOSITORY https://gitlab.com/kelteseth/qml-plausible.git + GIT_TAG 5069ba3bf25663ea06be8b94c398d6c61058d4d5 + # Workaround because: 1. QtCreator cannot handle QML_ELEMENT stuff when it is in bin folder + # https://bugreports.qt.io/browse/QTCREATORBUG-27083 + SOURCE_DIR ${THIRD_PARTY_PATH}/qml-plausible) + add_subdirectory(qml-plausible) add_subdirectory(QArchive) + +if(UNIX AND NOT APPLE) + # FetchContent_Populate( + # ecm + # GIT_REPOSITORY https://github.com/KDE/extra-cmake-modules.git + # GIT_TAG ff820f0b556d169f210a1289b6bd67888ec492dd + # SOURCE_DIR ${THIRD_PARTY_PATH}/ecm) + # #add_subdirectory(ecm) + # list(APPEND CMAKE_MODULE_PATH "${THIRD_PARTY_PATH}/ecm/modules") + + # FetchContent_Populate( + # layer-shell-qt + # GIT_REPOSITORY https://invent.kde.org/plasma/layer-shell-qt.git + # GIT_TAG d6aeaef1dc89b6b5ada0a835bf46d9adaee4838a + # SOURCE_DIR ${THIRD_PARTY_PATH}/layer-shell-qt) + add_subdirectory(layer-shell-qt) +endif() diff --git a/Tools/setup.py b/Tools/setup.py index 8823451a..56729ce7 100755 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -132,7 +132,6 @@ def main(): vcpkg_triplet = ["64-osx-universal"] elif system() == "Linux": vcpkg_command = "./vcpkg" - #vcpkg_packages_list.append("infoware[opengl]") platform_command = commands_list() platform_command.add("chmod +x bootstrap-vcpkg.sh", vcpkg_path) platform_command.add("./bootstrap-vcpkg.sh", vcpkg_path, False)