diff --git a/src/effects/CMakeLists.txt b/src/effects/CMakeLists.txt index 835f39e418..325371cc17 100644 --- a/src/effects/CMakeLists.txt +++ b/src/effects/CMakeLists.txt @@ -3,6 +3,9 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kwin_effects\" -DEFFECT_BUILTINS) include_directories(${KWin_SOURCE_DIR}/src) # for xcbutils.h +add_subdirectory(private) + + function(kwin_add_effect_config name) list(REMOVE_ITEM ARGV ${name}) kcoreaddons_add_plugin(${name} INSTALL_NAMESPACE "kwin/effects/configs" SOURCES ${ARGV}) diff --git a/src/effects/overview/CMakeLists.txt b/src/effects/overview/CMakeLists.txt index 129a47ff46..749b90eddd 100644 --- a/src/effects/overview/CMakeLists.txt +++ b/src/effects/overview/CMakeLists.txt @@ -7,8 +7,6 @@ if (KWIN_BUILD_KCMS) endif() set(overview_SOURCES - expoarea.cpp - expolayout.cpp main.cpp overvieweffect.cpp ) diff --git a/src/effects/overview/overvieweffect.cpp b/src/effects/overview/overvieweffect.cpp index 7faea2e155..71eab3223b 100644 --- a/src/effects/overview/overvieweffect.cpp +++ b/src/effects/overview/overvieweffect.cpp @@ -5,8 +5,6 @@ */ #include "overvieweffect.h" -#include "expoarea.h" -#include "expolayout.h" #include "overviewconfig.h" #include @@ -23,10 +21,6 @@ namespace KWin OverviewEffect::OverviewEffect() : m_shutdownTimer(new QTimer(this)) { - qmlRegisterType("org.kde.kwin.private.overview", 1, 0, "ExpoArea"); - qmlRegisterType("org.kde.kwin.private.overview", 1, 0, "ExpoLayout"); - qmlRegisterType("org.kde.kwin.private.overview", 1, 0, "ExpoCell"); - m_shutdownTimer->setSingleShot(true); connect(m_shutdownTimer, &QTimer::timeout, this, &OverviewEffect::realDeactivate); @@ -94,7 +88,7 @@ QVariantMap OverviewEffect::initialProperties(EffectScreen *screen) void OverviewEffect::reconfigure(ReconfigureFlags) { OverviewConfig::self()->read(); - setLayout(ExpoLayout::LayoutMode(OverviewConfig::layoutMode())); + setLayout(OverviewConfig::layoutMode()); setAnimationDuration(animationTime(200)); setBlurBackground(OverviewConfig::blurBackground()); @@ -154,12 +148,12 @@ void OverviewEffect::setAnimationDuration(int duration) } } -ExpoLayout::LayoutMode OverviewEffect::layout() const +int OverviewEffect::layout() const { return m_layout; } -void OverviewEffect::setLayout(ExpoLayout::LayoutMode layout) +void OverviewEffect::setLayout(int layout) { if (m_layout != layout) { m_layout = layout; diff --git a/src/effects/overview/overvieweffect.h b/src/effects/overview/overvieweffect.h index 979f23d2d4..38711b59a3 100644 --- a/src/effects/overview/overvieweffect.h +++ b/src/effects/overview/overvieweffect.h @@ -8,8 +8,6 @@ #include -#include "expolayout.h" - namespace KWin { @@ -17,7 +15,7 @@ class OverviewEffect : public QuickSceneEffect { Q_OBJECT Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged) - Q_PROPERTY(ExpoLayout::LayoutMode layout READ layout NOTIFY layoutChanged) + Q_PROPERTY(int layout READ layout NOTIFY layoutChanged) Q_PROPERTY(bool blurBackground READ blurBackground NOTIFY blurBackgroundChanged) Q_PROPERTY(qreal partialActivationFactor READ partialActivationFactor NOTIFY partialActivationFactorChanged) // More efficient from a property binding pov rather than binding to partialActivationFactor !== 0 @@ -32,8 +30,8 @@ public: OverviewEffect(); ~OverviewEffect() override; - ExpoLayout::LayoutMode layout() const; - void setLayout(ExpoLayout::LayoutMode layout); + int layout() const; + void setLayout(int layout); int animationDuration() const; void setAnimationDuration(int duration); @@ -79,7 +77,7 @@ private: bool m_blurBackground = false; Status m_status = Status::Inactive; int m_animationDuration = 200; - ExpoLayout::LayoutMode m_layout = ExpoLayout::LayoutNatural; + int m_layout = 1; }; } // namespace KWin diff --git a/src/effects/overview/qml/ScreenView.qml b/src/effects/overview/qml/ScreenView.qml index 1630ac36e7..30e9a6b9ac 100644 --- a/src/effects/overview/qml/ScreenView.qml +++ b/src/effects/overview/qml/ScreenView.qml @@ -7,7 +7,7 @@ import QtQuick 2.12 import QtGraphicalEffects 1.12 import org.kde.kwin 3.0 as KWinComponents -import org.kde.kwin.private.overview 1.0 +import org.kde.kwin.private.effects 1.0 import org.kde.milou 0.3 as Milou import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.core 2.0 as PlasmaCore @@ -191,7 +191,9 @@ FocusScope { id: heap visible: !(container.organized && searchField.text) anchors.fill: parent + layout: effect.layout padding: PlasmaCore.Units.largeSpacing + animationDuration: effect.animationDuration animationEnabled: container.animationEnabled organized: container.organized model: KWinComponents.ClientFilterModel { @@ -203,6 +205,7 @@ FocusScope { ~KWinComponents.ClientFilterModel.Desktop & ~KWinComponents.ClientFilterModel.Notification; } + onActivated: effect.deactivate(); } Milou.ResultsView { diff --git a/src/effects/private/CMakeLists.txt b/src/effects/private/CMakeLists.txt new file mode 100644 index 0000000000..8a275b02f3 --- /dev/null +++ b/src/effects/private/CMakeLists.txt @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2021 Vlad Zahorodnii +# +# SPDX-License-Identifier: BSD-3-Clause + +add_library(effectsplugin + expoarea.cpp + expolayout.cpp + plugin.cpp +) + +target_link_libraries(effectsplugin + kwineffects + + Qt5::Core + Qt5::Gui + Qt5::Qml + Qt5::Quick +) + +install(DIRECTORY qml/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kwin/private/effects) +install(TARGETS effectsplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kwin/private/effects) +install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/kwin/private/effects) diff --git a/src/effects/overview/expoarea.cpp b/src/effects/private/expoarea.cpp similarity index 100% rename from src/effects/overview/expoarea.cpp rename to src/effects/private/expoarea.cpp diff --git a/src/effects/overview/expoarea.h b/src/effects/private/expoarea.h similarity index 100% rename from src/effects/overview/expoarea.h rename to src/effects/private/expoarea.h diff --git a/src/effects/overview/expolayout.cpp b/src/effects/private/expolayout.cpp similarity index 100% rename from src/effects/overview/expolayout.cpp rename to src/effects/private/expolayout.cpp diff --git a/src/effects/overview/expolayout.h b/src/effects/private/expolayout.h similarity index 100% rename from src/effects/overview/expolayout.h rename to src/effects/private/expolayout.h diff --git a/src/effects/private/plugin.cpp b/src/effects/private/plugin.cpp new file mode 100644 index 0000000000..aa6245894d --- /dev/null +++ b/src/effects/private/plugin.cpp @@ -0,0 +1,18 @@ +/* + SPDX-FileCopyrightText: 2021 Vlad Zahorodnii + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "plugin.h" +#include "expoarea.h" +#include "expolayout.h" + +#include + +void EffectKitExtensionPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 1, 0, "ExpoArea"); + qmlRegisterType(uri, 1, 0, "ExpoLayout"); + qmlRegisterType(uri, 1, 0, "ExpoCell"); +} diff --git a/src/effects/private/plugin.h b/src/effects/private/plugin.h new file mode 100644 index 0000000000..a8ac29f0d2 --- /dev/null +++ b/src/effects/private/plugin.h @@ -0,0 +1,18 @@ +/* + SPDX-FileCopyrightText: 2021 Vlad Zahorodnii + + SPDX-License-Identifier: GPL-3.0-or-later +*/ + +#pragma once + +#include + +class EffectKitExtensionPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) override; +}; diff --git a/src/effects/overview/qml/WindowHeap.qml b/src/effects/private/qml/WindowHeap.qml similarity index 98% rename from src/effects/overview/qml/WindowHeap.qml rename to src/effects/private/qml/WindowHeap.qml index 0a4eb56c78..869eb5df7d 100644 --- a/src/effects/overview/qml/WindowHeap.qml +++ b/src/effects/private/qml/WindowHeap.qml @@ -7,7 +7,7 @@ import QtQuick 2.12 import org.kde.kirigami 2.12 as Kirigami import org.kde.kwin 3.0 as KWinComponents -import org.kde.kwin.private.overview 1.0 +import org.kde.kwin.private.effects 1.0 import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.core 2.0 as PlasmaCore @@ -22,20 +22,23 @@ FocusScope { } property alias model: windowsRepeater.model + property alias layout: expoLayout.mode property int selectedIndex: -1 + property int animationDuration: PlasmaCore.Units.longDuration property bool animationEnabled: false property real padding: 0 required property bool organized readonly property bool effectiveOrganized: expoLayout.ready && organized + signal activated() + ExpoLayout { id: expoLayout x: heap.padding y: heap.padding width: parent.width - 2 * heap.padding height: parent.height - 2 * heap.padding - mode: effect.layout spacing: PlasmaCore.Units.largeSpacing Repeater { @@ -246,9 +249,9 @@ FocusScope { to: "initial, active" enabled: heap.animationEnabled NumberAnimation { - duration: effect.animationDuration + duration: heap.animationDuration properties: "x, y, width, height, opacity" - easing.type: Easing.OutCubic + easing.type: Easing.InOutCubic } } @@ -273,7 +276,7 @@ FocusScope { acceptedButtons: Qt.LeftButton onTapped: { KWinComponents.Workspace.activeClient = thumb.client; - effect.deactivate(); + heap.activated(); } } @@ -528,7 +531,7 @@ FocusScope { } if (selectedItem) { KWinComponents.Workspace.activeClient = selectedItem.client; - effect.deactivate(); + heap.activated(); } break; default: diff --git a/src/effects/private/qmldir b/src/effects/private/qmldir new file mode 100644 index 0000000000..ee0ffb03a2 --- /dev/null +++ b/src/effects/private/qmldir @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2021 Vlad Zahorodnii +# +# SPDX-License-Identifier: CC0-1.0 + +module org.kde.kwin.private.effects + +plugin effectsplugin +classname EffectKitExtensionPlugin + +WindowHeap 1.0 WindowHeap.qml