From c2d36383b582d71b538ac01f6450f5a47ea1ee41 Mon Sep 17 00:00:00 2001
From: wheaney <42350981+wheaney@users.noreply.github.com>
Date: Mon, 8 Sep 2025 14:42:25 -0700
Subject: [PATCH] Add "remove virtual displays on disable" option
---
kwin/src/breezydesktopconfig.kcfg | 5 +++++
kwin/src/breezydesktopeffect.cpp | 14 +++++++++++---
kwin/src/breezydesktopeffect.h | 4 ++++
kwin/src/kcm/breezydesktopeffectkcm.cpp | 7 +++++++
kwin/src/kcm/breezydesktopeffectkcm.ui | 18 ++++++++++++++++--
5 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/kwin/src/breezydesktopconfig.kcfg b/kwin/src/breezydesktopconfig.kcfg
index 7ba2b62..2a8ec8b 100644
--- a/kwin/src/breezydesktopconfig.kcfg
+++ b/kwin/src/breezydesktopconfig.kcfg
@@ -57,5 +57,10 @@
0=None, 1=Medium, 2=High, 3=Very High
+
+ true
+
+ Whether to remove any virtual displays when the effect is disabled
+
diff --git a/kwin/src/breezydesktopeffect.cpp b/kwin/src/breezydesktopeffect.cpp
index e1f83e8..d20a1d2 100644
--- a/kwin/src/breezydesktopeffect.cpp
+++ b/kwin/src/breezydesktopeffect.cpp
@@ -204,11 +204,13 @@ void BreezyDesktopEffect::reconfigure(ReconfigureFlags)
qreal vert = BreezyDesktopConfig::displayVerticalOffset() / 100.0f;
int wrap = BreezyDesktopConfig::displayWrappingScheme();
int aaQuality = BreezyDesktopConfig::antialiasingQuality();
+ bool removeVD = BreezyDesktopConfig::removeVirtualDisplaysOnDisable();
bool changed = false;
if (!qFuzzyCompare(m_displayHorizontalOffset, horiz)) { m_displayHorizontalOffset = horiz; changed = true; }
if (!qFuzzyCompare(m_displayVerticalOffset, vert)) { m_displayVerticalOffset = vert; changed = true; }
if (m_displayWrappingScheme != wrap) { m_displayWrappingScheme = wrap; Q_EMIT displayWrappingSchemeChanged(); }
if (m_antialiasingQuality != aaQuality) { m_antialiasingQuality = aaQuality; Q_EMIT antialiasingQualityChanged(); }
+ if (m_removeVirtualDisplaysOnDisable != removeVD) { m_removeVirtualDisplaysOnDisable = removeVD; Q_EMIT removeVirtualDisplaysOnDisableChanged(); }
if (changed) Q_EMIT displayOffsetChanged();
}
@@ -260,10 +262,12 @@ void BreezyDesktopEffect::deactivate()
m_cursorUpdateTimer->stop();
showCursor();
- for (auto output : m_virtualOutputs) {
- KWin::kwinApp()->outputBackend()->removeVirtualOutput(output);
+ if (m_removeVirtualDisplaysOnDisable) {
+ for (auto output : m_virtualOutputs) {
+ KWin::kwinApp()->outputBackend()->removeVirtualOutput(output);
+ }
+ m_virtualOutputs.clear();
}
- m_virtualOutputs.clear();
setRunning(false);
}
@@ -414,6 +418,10 @@ int BreezyDesktopEffect::antialiasingQuality() const {
return m_antialiasingQuality;
}
+bool BreezyDesktopEffect::removeVirtualDisplaysOnDisable() const {
+ return m_removeVirtualDisplaysOnDisable;
+}
+
bool BreezyDesktopEffect::checkParityByte(const char* data) {
const uint8_t parityByte = static_cast(data[DataView::IMU_PARITY_BYTE[DataView::OFFSET_INDEX]]);
uint8_t parity = 0;
diff --git a/kwin/src/breezydesktopeffect.h b/kwin/src/breezydesktopeffect.h
index e0ad83b..f49dba8 100644
--- a/kwin/src/breezydesktopeffect.h
+++ b/kwin/src/breezydesktopeffect.h
@@ -36,6 +36,7 @@ namespace KWin
Q_PROPERTY(bool sbsEnabled READ sbsEnabled NOTIFY devicePropertiesChanged)
Q_PROPERTY(bool customBannerEnabled READ customBannerEnabled NOTIFY devicePropertiesChanged)
Q_PROPERTY(int antialiasingQuality READ antialiasingQuality NOTIFY antialiasingQualityChanged)
+ Q_PROPERTY(bool removeVirtualDisplaysOnDisable READ removeVirtualDisplaysOnDisable NOTIFY removeVirtualDisplaysOnDisableChanged)
public:
@@ -73,6 +74,7 @@ namespace KWin
bool sbsEnabled() const;
bool customBannerEnabled() const;
int antialiasingQuality() const;
+ bool removeVirtualDisplaysOnDisable() const;
void showCursor();
void hideCursor();
@@ -101,6 +103,7 @@ namespace KWin
void cursorPosChanged();
void devicePropertiesChanged();
void antialiasingQualityChanged();
+ void removeVirtualDisplaysOnDisableChanged();
protected:
QVariantMap initialProperties(Output *screen) override;
@@ -138,6 +141,7 @@ namespace KWin
qreal m_displayVerticalOffset = 0.0;
int m_displayWrappingScheme = 0; // 0=auto,1=horizontal,2=vertical,3=flat
int m_antialiasingQuality = 3; // 0=None, 1=Medium, 2=High, 3=VeryHigh
+ bool m_removeVirtualDisplaysOnDisable = true;
QList