diff --git a/kwin/src/breezydesktopconfig.kcfg b/kwin/src/breezydesktopconfig.kcfg
index e6772ef..5164008 100644
--- a/kwin/src/breezydesktopconfig.kcfg
+++ b/kwin/src/breezydesktopconfig.kcfg
@@ -5,16 +5,16 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
-
- 0.85
- 0.2
- 2.5
+
+ 85
+ 20
+ 250
-
- 1.05
- 0.2
- 2.5
+
+ 105
+ 20
+ 250
diff --git a/kwin/src/breezydesktopeffect.cpp b/kwin/src/breezydesktopeffect.cpp
index 81b056c..ffcf90e 100644
--- a/kwin/src/breezydesktopeffect.cpp
+++ b/kwin/src/breezydesktopeffect.cpp
@@ -66,17 +66,20 @@ BreezyDesktopEffect::BreezyDesktopEffect()
qCCritical(KWIN_XR) << "\t\t\tBreezy - constructor";
qmlRegisterUncreatableType("org.kde.kwin.effect.breezy_desktop_effect", 1, 0, "BreezyDesktopEffect", QStringLiteral("BreezyDesktop cannot be created in QML"));
- const QKeySequence defaultToggleShortcut = Qt::META | Qt::Key_B;
+ m_shutdownTimer->setSingleShot(true);
+ connect(m_shutdownTimer, &QTimer::timeout, this, &BreezyDesktopEffect::realDeactivate);
+
+ const QKeySequence defaultToggleShortcut = Qt::CTRL | Qt::META | Qt::Key_Backslash;
m_toggleAction = new QAction(this);
- m_toggleAction->setObjectName(QStringLiteral("BreezyDesktop"));
- m_toggleAction->setText(i18n("Toggle BreezyDesktop"));
+ m_toggleAction->setObjectName(QStringLiteral("Breezy Desktop"));
+ m_toggleAction->setText(i18n("Toggle Breezy Desktop"));
KGlobalAccel::self()->setDefaultShortcut(m_toggleAction, {defaultToggleShortcut});
KGlobalAccel::self()->setShortcut(m_toggleAction, {defaultToggleShortcut});
m_toggleShortcut = KGlobalAccel::self()->shortcut(m_toggleAction);
connect(m_toggleAction, &QAction::triggered, this, &BreezyDesktopEffect::toggle);
connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, [this](QAction *action, const QKeySequence &seq) {
- if (action->objectName() == QStringLiteral("BreezyDesktop")) {
+ if (action->objectName() == QStringLiteral("Breezy Desktop")) {
m_toggleShortcut.clear();
m_toggleShortcut.append(seq);
}
@@ -123,8 +126,8 @@ BreezyDesktopEffect::BreezyDesktopEffect()
void BreezyDesktopEffect::reconfigure(ReconfigureFlags)
{
BreezyDesktopConfig::self()->read();
- setFocusedDisplayDistance(BreezyDesktopConfig::focusedDisplayDistance());
- setAllDisplaysDistance(BreezyDesktopConfig::allDisplaysDistance());
+ setFocusedDisplayDistance(BreezyDesktopConfig::focusedDisplayDistance() / 100.0f);
+ setAllDisplaysDistance(BreezyDesktopConfig::allDisplaysDistance() / 100.0f);
}
QVariantMap BreezyDesktopEffect::initialProperties(Output *screen)
@@ -142,7 +145,13 @@ int BreezyDesktopEffect::requestedEffectChainPosition() const
void BreezyDesktopEffect::toggle()
{
- // TODO update this to use a persistent on/off value
+ if (isRunning()) {
+ qCCritical(KWIN_XR) << "\t\t\tBreezy - toggle - deactivating";
+ deactivate();
+ } else {
+ qCCritical(KWIN_XR) << "\t\t\tBreezy - toggle - activating";
+ activate();
+ }
}
void BreezyDesktopEffect::activate()
@@ -165,11 +174,18 @@ void BreezyDesktopEffect::activate()
void BreezyDesktopEffect::deactivate()
{
+ if (m_shutdownTimer->isActive()) {
+ return;
+ }
+
qCCritical(KWIN_XR) << "\t\t\tBreezy - deactivate";
disconnect(effects, &EffectsHandler::cursorShapeChanged, this, &BreezyDesktopEffect::updateCursorImage);
m_cursorUpdateTimer->stop();
showCursor();
- realDeactivate();
+
+ // this triggers realDeactivate with a delay so if it's triggered from QML it gives the QML function time to
+ // exit, avoiding a crash
+ m_shutdownTimer->start(250);
}
void BreezyDesktopEffect::realDeactivate()
@@ -212,7 +228,7 @@ qreal BreezyDesktopEffect::focusedDisplayDistance() const {
void BreezyDesktopEffect::setFocusedDisplayDistance(qreal distance) {
if (distance != m_focusedDisplayDistance) {
- m_focusedDisplayDistance = std::clamp(distance, 0.2, 2.5);
+ m_focusedDisplayDistance = std::clamp(distance, 0.2, m_allDisplaysDistance);
Q_EMIT displayDistanceChanged();
}
}
@@ -223,7 +239,7 @@ qreal BreezyDesktopEffect::allDisplaysDistance() const {
void BreezyDesktopEffect::setAllDisplaysDistance(qreal distance) {
if (distance != m_allDisplaysDistance) {
- m_allDisplaysDistance = std::clamp(distance, 0.2, 2.5);
+ m_allDisplaysDistance = std::clamp(distance, m_focusedDisplayDistance, 2.5);
Q_EMIT displayDistanceChanged();
}
}
diff --git a/kwin/src/breezydesktopeffect.h b/kwin/src/breezydesktopeffect.h
index fd208cc..ffa222f 100644
--- a/kwin/src/breezydesktopeffect.h
+++ b/kwin/src/breezydesktopeffect.h
@@ -85,8 +85,6 @@ namespace KWin
QTimer *m_shutdownTimer;
QAction *m_toggleAction = nullptr;
QList m_toggleShortcut;
- QList m_borderActivate;
- QList m_touchBorderActivate;
QString m_cursorImageSource;
bool m_enabled = false;
diff --git a/kwin/src/kcm/breezydesktopeffectkcm.cpp b/kwin/src/kcm/breezydesktopeffectkcm.cpp
index 23e47fb..11d58f3 100644
--- a/kwin/src/kcm/breezydesktopeffectkcm.cpp
+++ b/kwin/src/kcm/breezydesktopeffectkcm.cpp
@@ -24,10 +24,27 @@ BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPlu
{
ui.setupUi(widget());
addConfig(BreezyDesktopConfig::self(), widget());
+
+ auto actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
+ actionCollection->setComponentDisplayName(i18n("KWin"));
+ actionCollection->setConfigGroup(QStringLiteral("breezy_desktop_effect"));
+ actionCollection->setConfigGlobal(true);
+
+ const QKeySequence defaultToggleShortcut = Qt::CTRL | Qt::META | Qt::Key_Backslash;
+ QAction *toggleAction = actionCollection->addAction(QStringLiteral("Breezy Desktop"));
+ toggleAction->setText(i18n("Toggle Breezy Desktop"));
+ toggleAction->setProperty("isConfigurationAction", true);
+ KGlobalAccel::self()->setDefaultShortcut(toggleAction, {defaultToggleShortcut});
+ KGlobalAccel::self()->setShortcut(toggleAction, {defaultToggleShortcut});
+
+ ui.shortcutsEditor->addCollection(actionCollection);
+ connect(ui.shortcutsEditor, &KShortcutsEditor::keyChange, this, &BreezyDesktopEffectConfig::markAsChanged);
}
BreezyDesktopEffectConfig::~BreezyDesktopEffectConfig()
{
+ // If save() is called, undo() has no effect.
+ ui.shortcutsEditor->undo();
}
void BreezyDesktopEffectConfig::load()
@@ -57,6 +74,7 @@ void BreezyDesktopEffectConfig::defaults()
void BreezyDesktopEffectConfig::updateConfigFromUi()
{
+ ui.shortcutsEditor->save();
}
void BreezyDesktopEffectConfig::updateUiFromConfig()
@@ -65,6 +83,7 @@ void BreezyDesktopEffectConfig::updateUiFromConfig()
void BreezyDesktopEffectConfig::updateUiFromDefaultConfig()
{
+ ui.shortcutsEditor->allDefault();
}
void BreezyDesktopEffectConfig::updateUnmanagedState()
diff --git a/kwin/src/kcm/breezydesktopeffectkcm.ui b/kwin/src/kcm/breezydesktopeffectkcm.ui
index ac90744..50048e9 100644
--- a/kwin/src/kcm/breezydesktopeffectkcm.ui
+++ b/kwin/src/kcm/breezydesktopeffectkcm.ui
@@ -30,15 +30,24 @@
-
-
+
- 0.2
+ 20
- 2.5
+ 250
-
- 0.01
+
+ QSlider::TicksBelow
+
+
+ 20
+
+
+ Qt::Horizontal
+
+
+ true
@@ -50,21 +59,46 @@
-
-
+
- 0.2
+ 20
- 2.5
+ 250
-
- 0.01
+
+ QSlider::TicksBelow
+
+
+ 20
+
+
+ Qt::Horizontal
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+ KShortcutsEditor
+ QWidget
+
+ 1
+
diff --git a/kwin/src/qml/BreezyDesktop.qml b/kwin/src/qml/BreezyDesktop.qml
index 1d5ff40..4081e91 100644
--- a/kwin/src/qml/BreezyDesktop.qml
+++ b/kwin/src/qml/BreezyDesktop.qml
@@ -102,7 +102,6 @@ Node {
breezyDesktop.screens.map(screen => screen.geometry)
);
- console.log(`\t\t\tBreezy - Next focused monitor index: ${focusedIndex}`);
if (focusedIndex !== breezyDesktop.focusedMonitorIndex) {
zoomOutAnimation.stop();
zoomInAnimation.stop();
@@ -129,7 +128,6 @@ Node {
NumberAnimation {
id: zoomOutAnimation
property: "monitorDistance"
- from: effect.focusedDisplayDistance
to: effect.allDisplaysDistance
duration: 150
running: false
@@ -138,7 +136,6 @@ Node {
NumberAnimation {
id: zoomInAnimation
property: "monitorDistance"
- from: effect.allDisplaysDistance
to: effect.focusedDisplayDistance
duration: 300
running: false
@@ -151,7 +148,6 @@ Node {
NumberAnimation {
id: zoomOutSeqAnimation
property: "monitorDistance"
- from: effect.focusedDisplayDistance
to: effect.allDisplaysDistance
duration: 150
}
@@ -159,7 +155,6 @@ Node {
NumberAnimation {
id: zoomInSeqAnimation
property: "monitorDistance"
- from: effect.allDisplaysDistance
to: effect.focusedDisplayDistance
duration: 300
}
diff --git a/kwin/src/qml/Displays.qml b/kwin/src/qml/Displays.qml
index a126c62..3dc73ee 100644
--- a/kwin/src/qml/Displays.qml
+++ b/kwin/src/qml/Displays.qml
@@ -371,8 +371,6 @@ QtObject {
westConversionFns.angleToLength
) * effect.focusedDisplayDistance / effect.allDisplaysDistance;
- console.log(`\t\t\tBreezy - Focused monitor index: ${currentFocusedIndex}, distance: ${focusedDistance}`);
-
if (smoothFollowEnabled || focusedDistance < unfocusThreshold)
return currentFocusedIndex;
}
@@ -390,7 +388,6 @@ QtObject {
upConversionFns.angleToLength,
westConversionFns.angleToLength
);
- console.log(`\t\t\tBreezy - Monitor index: ${i}, distance: ${distance}`);
if (distance < closestDistance) {
closestIndex = i;
diff --git a/kwin/src/qml/main.qml b/kwin/src/qml/main.qml
index a40c553..be6aba3 100644
--- a/kwin/src/qml/main.qml
+++ b/kwin/src/qml/main.qml
@@ -80,8 +80,6 @@ Item {
Component.onCompleted: {
const targetScreenSupported = supportedModels.some(model => root.targetScreen.model.endsWith(model));
- console.log(`Breezy - initialized with target screen: ${root.targetScreen.model}, supported: ${targetScreenSupported}`);
-
viewLoader.sourceComponent = targetScreenSupported ? view3DComponent : desktopViewComponent;
}
}