From f0d6543311af10d06398d07c56019348080958dd Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:32:20 -0700 Subject: [PATCH] Attempt to mimick kwin's built-in cube project structure, works except for config mirroring from UI https://invent.kde.org/plasma/kdeplasma-addons/-/tree/master/kwin/effects/cube --- kwin/.clang-format | 95 +++++++++++++++++++ kwin/CMakeLists.txt | 65 +++++++++++-- kwin/src/CMakeLists.txt | 4 +- kwin/src/breezydesktopeffect.cpp | 6 +- kwin/src/kcm/CMakeLists.txt | 13 +-- kwin/src/kcm/breezydesktopeffectkcm.cpp | 28 ++++-- kwin/src/kcm/breezydesktopeffectkcm.h | 4 +- kwin/src/kcm/resources.qrc | 5 + kwin/src/main.cpp | 2 +- .../contents/ui}/BreezyDesktop.qml | 0 .../contents/ui}/BreezyDesktopDisplay.qml | 0 .../contents/ui}/CameraController.qml | 0 .../contents/ui}/DesktopView.qml | 0 .../{qml => package/contents/ui}/Displays.qml | 0 .../src/{qml => package/contents/ui}/main.qml | 0 kwin/src/{ => package}/metadata.json | 13 +-- 16 files changed, 198 insertions(+), 37 deletions(-) create mode 100644 kwin/.clang-format create mode 100644 kwin/src/kcm/resources.qrc rename kwin/src/{qml => package/contents/ui}/BreezyDesktop.qml (100%) rename kwin/src/{qml => package/contents/ui}/BreezyDesktopDisplay.qml (100%) rename kwin/src/{qml => package/contents/ui}/CameraController.qml (100%) rename kwin/src/{qml => package/contents/ui}/DesktopView.qml (100%) rename kwin/src/{qml => package/contents/ui}/Displays.qml (100%) rename kwin/src/{qml => package/contents/ui}/main.qml (100%) rename kwin/src/{ => package}/metadata.json (53%) diff --git a/kwin/.clang-format b/kwin/.clang-format new file mode 100644 index 0000000..9b5ae0a --- /dev/null +++ b/kwin/.clang-format @@ -0,0 +1,95 @@ +--- +# SPDX-FileCopyrightText: 2019 Christoph Cullmann +# SPDX-FileCopyrightText: 2019 Gernot Gebhard +# +# SPDX-License-Identifier: MIT + +# This file got automatically created by ECM, do not edit +# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the config options +# and https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting +# for clang-format tips & tricks +--- +Language: JavaScript +DisableFormat: true +--- +Language: Json +DisableFormat: false +IndentWidth: 4 +--- + +# Style for C++ +Language: Cpp + +# base is WebKit coding style: https://webkit.org/code-style-guidelines/ +# below are only things set that diverge from this style! +BasedOnStyle: WebKit + +# enforce C++11 (e.g. for std::vector> +Standard: Cpp11 + +# 4 spaces indent +TabWidth: 4 + +# 2 * 80 wide lines +ColumnLimit: 160 + +# sort includes inside line separated groups +SortIncludes: true + +# break before braces on function, namespace and class definitions. +BreakBeforeBraces: Linux + +# CrlInstruction *a; +PointerAlignment: Right + +# horizontally aligns arguments after an open bracket. +AlignAfterOpenBracket: Align + +# don't move all parameters to new line +AllowAllParametersOfDeclarationOnNextLine: false + +# no single line functions +AllowShortFunctionsOnASingleLine: None + +# no single line enums +AllowShortEnumsOnASingleLine: false + +# always break before you encounter multi line strings +AlwaysBreakBeforeMultilineStrings: true + +# don't move arguments to own lines if they are not all on the same +BinPackArguments: false + +# don't move parameters to own lines if they are not all on the same +BinPackParameters: false + +# In case we have an if statement with multiple lines the operator should be at the beginning of the line +# but we do not want to break assignments +BreakBeforeBinaryOperators: NonAssignment + +# format C++11 braced lists like function calls +Cpp11BracedListStyle: true + +# do not put a space before C++11 braced lists +SpaceBeforeCpp11BracedList: false + +# remove empty lines +KeepEmptyLinesAtTheStartOfBlocks: false + +# no namespace indentation to keep indent level low +NamespaceIndentation: None + +# we use template< without space. +SpaceAfterTemplateKeyword: false + +# Always break after template declaration +AlwaysBreakTemplateDeclarations: true + +# macros for which the opening brace stays attached. +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ] + +# keep lambda formatting multi-line if not empty +AllowShortLambdasOnASingleLine: Empty + +# We do not want clang-format to put all arguments on a new line +AllowAllArgumentsOnNextLine: false diff --git a/kwin/CMakeLists.txt b/kwin/CMakeLists.txt index c3df9a4..45c341f 100644 --- a/kwin/CMakeLists.txt +++ b/kwin/CMakeLists.txt @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.20) project(breezy_desktop_kwin_plugin VERSION 0.0.1 LANGUAGES CXX) +set(PROJECT_DEP_VERSION "6.3.90") +set(QT_MIN_VERSION "6.8.0") +set(KF6_MIN_VERSION "6.14.0") +set(KDE_COMPILERSETTINGS_LEVEL "5.82") + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD 20) @@ -10,19 +15,61 @@ set(CMAKE_CXX_EXTENSIONS OFF) include(cmake/default-vars.cmake) -find_package(ECM "5.100" REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} - ${ECM_MODULE_PATH} - ${ECM_KDE_MODULE_DIR} -) -include(cmake/qtversion.cmake) -include(FeatureSummary) +find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) +include(ECMQtDeclareLoggingCategory) +include(ECMGenerateExportHeader) +include(ECMInstallIcons) +include(KDEPackageAppTemplates) +include(GenerateExportHeader) +include(CMakePackageConfigHelpers) +include(KDEClangFormat) +include(KDEGitCommitHooks) +include(ECMDeprecationSettings) +include(ECMQmlModule) + +find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED + Core + Gui + DBus + Network + Quick + Qml + Widgets + Test + Core5Compat +) + +find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS + Config + CoreAddons + DBusAddons + Declarative + GlobalAccel + Holidays + I18n + Auth + KIO + KCMUtils + Notifications + Runner + Service + Sonnet + UnitConversion + XmlGui + NewStuff + JobWidgets + Svg +) + +find_package(Plasma5Support ${PROJECT_DEP_VERSION} REQUIRED) +find_package(Plasma ${PROJECT_DEP_VERSION} REQUIRED) +find_package(PlasmaQuick ${PROJECT_DEP_VERSION} REQUIRED) -include(cmake/qtversion.cmake) # required frameworks by Core find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS diff --git a/kwin/src/CMakeLists.txt b/kwin/src/CMakeLists.txt index d99e237..c4252ab 100644 --- a/kwin/src/CMakeLists.txt +++ b/kwin/src/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(kcm) +kpackage_install_package(package breezy_desktop_effect effects kwin) kcoreaddons_add_plugin(breezy_desktop_effect INSTALL_NAMESPACE "kwin/effects/plugins/") target_sources(breezy_desktop_effect PRIVATE @@ -22,6 +23,3 @@ target_link_libraries(breezy_desktop_effect KWin::kwin ) - -install(DIRECTORY qml DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/breezy_desktop_effect) -install(FILES metadata.json DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/breezy_desktop_effect) diff --git a/kwin/src/breezydesktopeffect.cpp b/kwin/src/breezydesktopeffect.cpp index 81b056c..98e5b95 100644 --- a/kwin/src/breezydesktopeffect.cpp +++ b/kwin/src/breezydesktopeffect.cpp @@ -86,7 +86,7 @@ BreezyDesktopEffect::BreezyDesktopEffect() updateCursorImage(); reconfigure(ReconfigureAll); - setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/effects/breezy_desktop_effect/qml/main.qml")))); + setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/effects/breezy_desktop_effect/contents/ui/main.qml")))); // Monitor the IMU file for changes, even if it doesn't exist at startup m_shmDirectoryWatcher = new QFileSystemWatcher(this); @@ -123,6 +123,8 @@ BreezyDesktopEffect::BreezyDesktopEffect() void BreezyDesktopEffect::reconfigure(ReconfigureFlags) { BreezyDesktopConfig::self()->read(); + qCCritical(KWIN_XR) << "\t\t\tBreezy - reconfigure, focusedDisplayDistance:" << BreezyDesktopConfig::focusedDisplayDistance() + << " allDisplaysDistance:" << BreezyDesktopConfig::allDisplaysDistance(); setFocusedDisplayDistance(BreezyDesktopConfig::focusedDisplayDistance()); setAllDisplaysDistance(BreezyDesktopConfig::allDisplaysDistance()); } @@ -211,6 +213,7 @@ qreal BreezyDesktopEffect::focusedDisplayDistance() const { } void BreezyDesktopEffect::setFocusedDisplayDistance(qreal distance) { + qCCritical(KWIN_XR) << "\t\t\tBreezy - setFocusedDisplayDistance:" << distance; if (distance != m_focusedDisplayDistance) { m_focusedDisplayDistance = std::clamp(distance, 0.2, 2.5); Q_EMIT displayDistanceChanged(); @@ -222,6 +225,7 @@ qreal BreezyDesktopEffect::allDisplaysDistance() const { } void BreezyDesktopEffect::setAllDisplaysDistance(qreal distance) { + qCCritical(KWIN_XR) << "\t\t\tBreezy - setAllDisplaysDistance:" << distance; if (distance != m_allDisplaysDistance) { m_allDisplaysDistance = std::clamp(distance, 0.2, 2.5); Q_EMIT displayDistanceChanged(); diff --git a/kwin/src/kcm/CMakeLists.txt b/kwin/src/kcm/CMakeLists.txt index 5a0913b..b2e7ebe 100644 --- a/kwin/src/kcm/CMakeLists.txt +++ b/kwin/src/kcm/CMakeLists.txt @@ -1,13 +1,10 @@ -# SPDX-FileCopyrightText: 2022 Vlad Zahorodnii -# -# SPDX-License-Identifier: BSD-3-Clause - set(breezy_desktop_config_SOURCES breezydesktopeffectkcm.cpp) ki18n_wrap_ui(breezy_desktop_config_SOURCES breezydesktopeffectkcm.ui) -qt_add_dbus_interface(breezy_desktop_config_SOURCES ${KWIN_EFFECTS_INTERFACE} kwineffects_interface) kcoreaddons_add_plugin(breezy_desktop_config INSTALL_NAMESPACE "kwin/effects/configs" SOURCES ${breezy_desktop_config_SOURCES}) -kconfig_add_kcfg_files(breezy_desktop_config ../breezydesktopconfig.kcfgc) +target_sources(breezy_desktop_config PRIVATE + resources.qrc +) target_link_libraries(breezy_desktop_config KF6::ConfigCore KF6::ConfigGui @@ -18,3 +15,7 @@ target_link_libraries(breezy_desktop_config KF6::KCMUtils KF6::XmlGui ) + +target_compile_definitions(breezy_desktop_config PRIVATE + -DTRANSLATION_DOMAIN=\"breezy_desktop_effect\" +) \ No newline at end of file diff --git a/kwin/src/kcm/breezydesktopeffectkcm.cpp b/kwin/src/kcm/breezydesktopeffectkcm.cpp index 23e47fb..11e46d6 100644 --- a/kwin/src/kcm/breezydesktopeffectkcm.cpp +++ b/kwin/src/kcm/breezydesktopeffectkcm.cpp @@ -5,9 +5,6 @@ */ #include "breezydesktopeffectkcm.h" -#include "breezydesktopconfig.h" - -#include #include #include @@ -15,15 +12,25 @@ #include #include +#include +#include #include +#include + +Q_LOGGING_CATEGORY(KWIN_XR, "kwin.xr") K_PLUGIN_CLASS(BreezyDesktopEffectConfig) -BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args) +BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPluginMetaData &data) : KCModule(parent, data) { ui.setupUi(widget()); - addConfig(BreezyDesktopConfig::self(), widget()); + + QFile xmlFile(QStringLiteral(":/main.xml")); + qCCritical(KWIN_XR) << "\t\t\tBreezy - xml file exists:" << xmlFile.exists(); + KConfigGroup cg = KSharedConfig::openConfig(QStringLiteral("kwinrc"))->group("Effect-breezy_desktop_effect"); + m_configLoader = new KConfigLoader(cg, &xmlFile, this); + addConfig(m_configLoader, widget()); } BreezyDesktopEffectConfig::~BreezyDesktopEffectConfig() @@ -40,12 +47,17 @@ void BreezyDesktopEffectConfig::load() void BreezyDesktopEffectConfig::save() { updateConfigFromUi(); - BreezyDesktopConfig::self()->save(); + m_configLoader->save(); + KCModule::save(); updateUnmanagedState(); - OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); - interface.reconfigureEffect(QStringLiteral("breezy_desktop_effect")); + QDBusMessage reconfigureMessage = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"), + QStringLiteral("/Effects"), + QStringLiteral("org.kde.kwin.Effects"), + QStringLiteral("reconfigureEffect")); + reconfigureMessage.setArguments({QStringLiteral("breezy_desktop_effect")}); + QDBusConnection::sessionBus().call(reconfigureMessage); } void BreezyDesktopEffectConfig::defaults() diff --git a/kwin/src/kcm/breezydesktopeffectkcm.h b/kwin/src/kcm/breezydesktopeffectkcm.h index fa3b5e6..0a11f48 100644 --- a/kwin/src/kcm/breezydesktopeffectkcm.h +++ b/kwin/src/kcm/breezydesktopeffectkcm.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include "ui_breezydesktopeffectkcm.h" @@ -15,7 +16,7 @@ class BreezyDesktopEffectConfig : public KCModule Q_OBJECT public: - BreezyDesktopEffectConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args); + BreezyDesktopEffectConfig(QObject *parent, const KPluginMetaData &data); ~BreezyDesktopEffectConfig() override; public Q_SLOTS: @@ -30,4 +31,5 @@ private: void updateUnmanagedState(); ::Ui::BreezyDesktopEffectConfig ui; + KConfigLoader *m_configLoader = nullptr; }; diff --git a/kwin/src/kcm/resources.qrc b/kwin/src/kcm/resources.qrc new file mode 100644 index 0000000..faaaa02 --- /dev/null +++ b/kwin/src/kcm/resources.qrc @@ -0,0 +1,5 @@ + + + ../breezydesktopconfig.kcfg + + diff --git a/kwin/src/main.cpp b/kwin/src/main.cpp index cdab856..afb289c 100644 --- a/kwin/src/main.cpp +++ b/kwin/src/main.cpp @@ -3,7 +3,7 @@ namespace KWin { -KWIN_EFFECT_FACTORY_SUPPORTED(BreezyDesktopEffect, "metadata.json", return BreezyDesktopEffect::supported();) +KWIN_EFFECT_FACTORY_SUPPORTED(BreezyDesktopEffect, "package/metadata.json", return BreezyDesktopEffect::supported();) } // namespace KWin diff --git a/kwin/src/qml/BreezyDesktop.qml b/kwin/src/package/contents/ui/BreezyDesktop.qml similarity index 100% rename from kwin/src/qml/BreezyDesktop.qml rename to kwin/src/package/contents/ui/BreezyDesktop.qml diff --git a/kwin/src/qml/BreezyDesktopDisplay.qml b/kwin/src/package/contents/ui/BreezyDesktopDisplay.qml similarity index 100% rename from kwin/src/qml/BreezyDesktopDisplay.qml rename to kwin/src/package/contents/ui/BreezyDesktopDisplay.qml diff --git a/kwin/src/qml/CameraController.qml b/kwin/src/package/contents/ui/CameraController.qml similarity index 100% rename from kwin/src/qml/CameraController.qml rename to kwin/src/package/contents/ui/CameraController.qml diff --git a/kwin/src/qml/DesktopView.qml b/kwin/src/package/contents/ui/DesktopView.qml similarity index 100% rename from kwin/src/qml/DesktopView.qml rename to kwin/src/package/contents/ui/DesktopView.qml diff --git a/kwin/src/qml/Displays.qml b/kwin/src/package/contents/ui/Displays.qml similarity index 100% rename from kwin/src/qml/Displays.qml rename to kwin/src/package/contents/ui/Displays.qml diff --git a/kwin/src/qml/main.qml b/kwin/src/package/contents/ui/main.qml similarity index 100% rename from kwin/src/qml/main.qml rename to kwin/src/package/contents/ui/main.qml diff --git a/kwin/src/metadata.json b/kwin/src/package/metadata.json similarity index 53% rename from kwin/src/metadata.json rename to kwin/src/package/metadata.json index 7bf93f5..db75c72 100644 --- a/kwin/src/metadata.json +++ b/kwin/src/package/metadata.json @@ -7,16 +7,13 @@ "Name": "Wayne Heaney" } ], - "Category": "Tools", - "Description": "Breezy Desktop XR Effect", + "Category": "Window Management", + "Description": "Breezy Desktop", "EnabledByDefault": true, "Id": "breezy_desktop_effect", "License": "GPL", - "Name": "Breezy Desktop XR", - "ServiceTypes": [ - "KWin/Effect" - ] + "Name": "Breezy Desktop" }, - "X-Plasma-API-Minimum-Version": "6.0", - "X-KDE-ConfigModule": "breezy_desktop_config" + "X-KDE-ConfigModule": "breezy_desktop_config", + "X-KDE-Ordering": 60 }