Commit 00c95afc authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Nate Graham
Browse files

effects: Move WindowHeap in a qml module

The WindowHeap can be useful not only to the Overview effect, but also
other effects, e.g. a desktop grid replacement, etc.
parent e3fe6904
......@@ -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})
......
......@@ -7,8 +7,6 @@ if (KWIN_BUILD_KCMS)
endif()
set(overview_SOURCES
expoarea.cpp
expolayout.cpp
main.cpp
overvieweffect.cpp
)
......
......@@ -5,8 +5,6 @@
*/
#include "overvieweffect.h"
#include "expoarea.h"
#include "expolayout.h"
#include "overviewconfig.h"
#include <KGlobalAccel>
......@@ -23,10 +21,6 @@ namespace KWin
OverviewEffect::OverviewEffect()
: m_shutdownTimer(new QTimer(this))
{
qmlRegisterType<ExpoArea>("org.kde.kwin.private.overview", 1, 0, "ExpoArea");
qmlRegisterType<ExpoLayout>("org.kde.kwin.private.overview", 1, 0, "ExpoLayout");
qmlRegisterType<ExpoCell>("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;
......
......@@ -8,8 +8,6 @@
#include <kwinquickeffect.h>
#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
......@@ -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 {
......
# SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
#
# 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)
/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "plugin.h"
#include "expoarea.h"
#include "expolayout.h"
#include <QQmlEngine>
void EffectKitExtensionPlugin::registerTypes(const char *uri)
{
qmlRegisterType<KWin::ExpoArea>(uri, 1, 0, "ExpoArea");
qmlRegisterType<ExpoLayout>(uri, 1, 0, "ExpoLayout");
qmlRegisterType<ExpoCell>(uri, 1, 0, "ExpoCell");
}
/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <QQmlExtensionPlugin>
class EffectKitExtensionPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri) override;
};
......@@ -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:
......
# SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
#
# SPDX-License-Identifier: CC0-1.0
module org.kde.kwin.private.effects
plugin effectsplugin
classname EffectKitExtensionPlugin
WindowHeap 1.0 WindowHeap.qml
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment