Wire up display distance config

This commit is contained in:
wheaney 2025-08-01 15:02:37 -07:00
parent 0cbc54bd04
commit 7fb48fe77d
14 changed files with 139 additions and 151 deletions

View File

@ -5,7 +5,7 @@ target_sources(breezy_desktop_effect PRIVATE
breezydesktopeffect.cpp
main.cpp
)
kconfig_add_kcfg_files(breezy_desktop_effect cubeconfig.kcfgc)
kconfig_add_kcfg_files(breezy_desktop_effect breezydesktopconfig.kcfgc)
target_include_directories(breezy_desktop_effect PRIVATE /usr/include/kwin)
target_link_libraries(breezy_desktop_effect
@ -23,5 +23,5 @@ target_link_libraries(breezy_desktop_effect
KWin::kwin
)
install(DIRECTORY qml DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/breezy_desktop)
install(FILES metadata.json DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/breezy_desktop)
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)

View File

@ -4,6 +4,12 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc"/>
<group name="Effect-breezy_desktop">
<group name="Effect-breezy_desktop_effect">
<entry name="DisplayDistance" type="Double">
<default>1.05</default>
<min>0.2</min>
<max>2.5</max>
<label>Display Distance</label>
</entry>
</group>
</kcfg>

View File

@ -0,0 +1,4 @@
File=breezydesktopconfig.kcfg
ClassName=BreezyDesktopConfig
Singleton=true
Mutators=true

View File

@ -1,5 +1,5 @@
#include "breezydesktopeffect.h"
#include "cubeconfig.h"
#include "breezydesktopconfig.h"
#include "effect/effect.h"
#include "effect/effecthandler.h"
#include "opengl/glutils.h"
@ -64,7 +64,7 @@ BreezyDesktopEffect::BreezyDesktopEffect()
: m_shutdownTimer(new QTimer(this))
{
qCCritical(KWIN_XR) << "\t\t\tBreezy - constructor";
qmlRegisterUncreatableType<BreezyDesktopEffect>("org.kde.kwin.effect.breezy_desktop", 1, 0, "BreezyDesktopEffect", QStringLiteral("BreezyDesktop cannot be created in QML"));
qmlRegisterUncreatableType<BreezyDesktopEffect>("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_toggleAction = new QAction(this);
@ -86,7 +86,7 @@ BreezyDesktopEffect::BreezyDesktopEffect()
updateCursorImage();
reconfigure(ReconfigureAll);
setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/effects/breezy_desktop/qml/main.qml"))));
setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/effects/breezy_desktop_effect/qml/main.qml"))));
// Monitor the IMU file for changes, even if it doesn't exist at startup
m_shmDirectoryWatcher = new QFileSystemWatcher(this);
@ -122,7 +122,8 @@ BreezyDesktopEffect::BreezyDesktopEffect()
void BreezyDesktopEffect::reconfigure(ReconfigureFlags)
{
CubeConfig::self()->read();
BreezyDesktopConfig::self()->read();
setDisplayDistance(BreezyDesktopConfig::displayDistance());
}
QVariantMap BreezyDesktopEffect::initialProperties(Output *screen)
@ -167,14 +168,6 @@ void BreezyDesktopEffect::deactivate()
disconnect(effects, &EffectsHandler::cursorShapeChanged, this, &BreezyDesktopEffect::updateCursorImage);
m_cursorUpdateTimer->stop();
showCursor();
const QList<Output *> screens = effects->screens();
for (Output *screen : screens) {
if (QuickSceneView *view = viewForScreen(screen)) {
QMetaObject::invokeMethod(view->rootItem(), "stop");
}
}
realDeactivate();
}
@ -184,27 +177,6 @@ void BreezyDesktopEffect::realDeactivate()
setRunning(false);
}
int BreezyDesktopEffect::animationDuration() const
{
return 200;
}
qreal BreezyDesktopEffect::faceDisplacement() const {
return 100;
}
qreal BreezyDesktopEffect::distanceFactor() const {
return 1.5;
}
BreezyDesktopEffect::BackgroundMode BreezyDesktopEffect::backgroundMode() const {
return BackgroundMode::Color;
}
QColor BreezyDesktopEffect::backgroundColor() const {
return QColor(Qt::black);
}
bool BreezyDesktopEffect::isEnabled() const {
return m_enabled;
}
@ -233,6 +205,17 @@ QList<quint32> BreezyDesktopEffect::displayResolution() const {
return m_displayResolution;
}
qreal BreezyDesktopEffect::displayDistance() const {
return m_displayDistance;
}
void BreezyDesktopEffect::setDisplayDistance(qreal distance) {
if (distance != m_displayDistance) {
m_displayDistance = std::clamp(distance, 0.2, 2.5);
Q_EMIT displayDistanceChanged();
}
}
qreal BreezyDesktopEffect::diagonalFOV() const {
return m_diagonalFOV;
}

View File

@ -13,11 +13,6 @@ namespace KWin
class BreezyDesktopEffect : public QuickSceneEffect
{
Q_OBJECT
Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged)
Q_PROPERTY(qreal faceDisplacement READ faceDisplacement NOTIFY faceDisplacementChanged)
Q_PROPERTY(qreal distanceFactor READ distanceFactor NOTIFY distanceFactorChanged)
Q_PROPERTY(BackgroundMode backgroundMode READ backgroundMode NOTIFY backgroundModeChanged)
Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundColorChanged)
Q_PROPERTY(bool isEnabled READ isEnabled NOTIFY enabledStateChanged)
Q_PROPERTY(bool imuResetState READ imuResetState NOTIFY imuRotationsChanged)
Q_PROPERTY(QList<QQuaternion> imuRotations READ imuRotations NOTIFY imuRotationsChanged)
@ -27,18 +22,13 @@ namespace KWin
Q_PROPERTY(QPointF cursorPos READ cursorPos NOTIFY cursorPosChanged)
Q_PROPERTY(QList<qreal> lookAheadConfig READ lookAheadConfig NOTIFY devicePropertiesChanged)
Q_PROPERTY(QList<quint32> displayResolution READ displayResolution NOTIFY devicePropertiesChanged)
Q_PROPERTY(qreal displayDistance READ displayDistance NOTIFY displayDistanceChanged)
Q_PROPERTY(qreal diagonalFOV READ diagonalFOV NOTIFY devicePropertiesChanged)
Q_PROPERTY(qreal lensDistanceRatio READ lensDistanceRatio NOTIFY devicePropertiesChanged)
Q_PROPERTY(bool sbsEnabled READ sbsEnabled NOTIFY devicePropertiesChanged)
Q_PROPERTY(bool customBannerEnabled READ customBannerEnabled NOTIFY devicePropertiesChanged)
public:
enum class BackgroundMode
{
Color,
Skybox,
};
Q_ENUM(BackgroundMode)
BreezyDesktopEffect();
@ -46,11 +36,6 @@ namespace KWin
int requestedEffectChainPosition() const override;
int animationDuration() const;
qreal faceDisplacement() const;
qreal distanceFactor() const;
BackgroundMode backgroundMode() const;
QColor backgroundColor() const;
QString cursorImageSource() const;
QPointF cursorPos() const;
@ -61,6 +46,8 @@ namespace KWin
bool imuResetState() const;
QList<qreal> lookAheadConfig() const;
QList<quint32> displayResolution() const;
qreal displayDistance() const;
void setDisplayDistance(qreal distance);
qreal diagonalFOV() const;
qreal lensDistanceRatio() const;
bool sbsEnabled() const;
@ -78,12 +65,7 @@ namespace KWin
void updateCursorPos();
Q_SIGNALS:
void faceDisplacementChanged();
void distanceFactorChanged();
void animationDurationChanged();
void skyboxChanged();
void backgroundModeChanged();
void backgroundColorChanged();
void displayDistanceChanged();
void enabledStateChanged();
void imuRotationsChanged();
void cursorImageChanged();
@ -119,6 +101,7 @@ namespace KWin
QFileSystemWatcher *m_shmDirectoryWatcher = nullptr;
QPointF m_cursorPos;
QTimer *m_cursorUpdateTimer = nullptr;
qreal m_displayDistance = 1.05;
};
} // namespace KWin

View File

@ -1,4 +0,0 @@
File=cubeconfig.kcfg
ClassName=CubeConfig
Singleton=true
Mutators=true

View File

@ -2,12 +2,12 @@
#
# SPDX-License-Identifier: BSD-3-Clause
set(breezy_desktop_config_SOURCES cubeeffectkcm.cpp)
ki18n_wrap_ui(breezy_desktop_config_SOURCES cubeeffectkcm.ui)
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 ../cubeconfig.kcfgc)
kconfig_add_kcfg_files(breezy_desktop_config ../breezydesktopconfig.kcfgc)
target_link_libraries(breezy_desktop_config
KF6::ConfigCore
KF6::ConfigGui

View File

@ -0,0 +1,74 @@
/*
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "breezydesktopeffectkcm.h"
#include "breezydesktopconfig.h"
#include <kwineffects_interface.h>
#include <KActionCollection>
#include <KGlobalAccel>
#include <KLocalizedString>
#include <KPluginFactory>
#include <QAction>
#include <QFileDialog>
K_PLUGIN_CLASS(BreezyDesktopEffectConfig)
BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KCModule(parent, data)
{
ui.setupUi(widget());
addConfig(BreezyDesktopConfig::self(), widget());
}
BreezyDesktopEffectConfig::~BreezyDesktopEffectConfig()
{
}
void BreezyDesktopEffectConfig::load()
{
KCModule::load();
updateUiFromConfig();
updateUnmanagedState();
}
void BreezyDesktopEffectConfig::save()
{
updateConfigFromUi();
BreezyDesktopConfig::self()->save();
KCModule::save();
updateUnmanagedState();
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("breezy_desktop_effect"));
}
void BreezyDesktopEffectConfig::defaults()
{
KCModule::defaults();
updateUiFromDefaultConfig();
updateUnmanagedState();
}
void BreezyDesktopEffectConfig::updateConfigFromUi()
{
}
void BreezyDesktopEffectConfig::updateUiFromConfig()
{
}
void BreezyDesktopEffectConfig::updateUiFromDefaultConfig()
{
}
void BreezyDesktopEffectConfig::updateUnmanagedState()
{
}
#include "breezydesktopeffectkcm.moc"

View File

@ -8,15 +8,15 @@
#include <KCModule>
#include "ui_cubeeffectkcm.h"
#include "ui_breezydesktopeffectkcm.h"
class CubeEffectConfig : public KCModule
class BreezyDesktopEffectConfig : public KCModule
{
Q_OBJECT
public:
CubeEffectConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~CubeEffectConfig() override;
BreezyDesktopEffectConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~BreezyDesktopEffectConfig() override;
public Q_SLOTS:
void load() override;
@ -29,5 +29,5 @@ private:
void updateConfigFromUi();
void updateUnmanagedState();
::Ui::CubeEffectConfig ui;
::Ui::BreezyDesktopEffectConfig ui;
};

View File

@ -5,8 +5,8 @@
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
-->
<ui version="4.0">
<class>CubeEffectConfig</class>
<widget class="QWidget" name="CubeEffectConfig">
<class>BreezyDesktopEffectConfig</class>
<widget class="QWidget" name="BreezyDesktopEffectConfig">
<property name="geometry">
<rect>
<x>0</x>
@ -23,9 +23,22 @@
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="labelDisplayDistance">
<property name="text">
<string>Cube face displacement:</string>
<string>Display Distance:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="kcfg_DisplayDistance">
<property name="minimum">
<double>0.2</double>
</property>
<property name="maximum">
<double>2.5</double>
</property>
<property name="singleStep">
<double>0.01</double>
</property>
</widget>
</item>

View File

@ -1,74 +0,0 @@
/*
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "cubeeffectkcm.h"
#include "cubeconfig.h"
#include <kwineffects_interface.h>
#include <KActionCollection>
#include <KGlobalAccel>
#include <KLocalizedString>
#include <KPluginFactory>
#include <QAction>
#include <QFileDialog>
K_PLUGIN_CLASS(CubeEffectConfig)
CubeEffectConfig::CubeEffectConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KCModule(parent, data)
{
ui.setupUi(widget());
addConfig(CubeConfig::self(), widget());
}
CubeEffectConfig::~CubeEffectConfig()
{
}
void CubeEffectConfig::load()
{
KCModule::load();
updateUiFromConfig();
updateUnmanagedState();
}
void CubeEffectConfig::save()
{
updateConfigFromUi();
CubeConfig::self()->save();
KCModule::save();
updateUnmanagedState();
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("cube"));
}
void CubeEffectConfig::defaults()
{
KCModule::defaults();
updateUiFromDefaultConfig();
updateUnmanagedState();
}
void CubeEffectConfig::updateConfigFromUi()
{
}
void CubeEffectConfig::updateUiFromConfig()
{
}
void CubeEffectConfig::updateUiFromDefaultConfig()
{
}
void CubeEffectConfig::updateUnmanagedState()
{
}
#include "cubeeffectkcm.moc"

View File

@ -10,6 +10,7 @@
"Category": "Tools",
"Description": "Breezy Desktop XR Effect",
"EnabledByDefault": true,
"Id": "breezy_desktop_effect",
"License": "GPL",
"Name": "Breezy Desktop XR",
"ServiceTypes": [

View File

@ -1,6 +1,8 @@
import QtQuick
QtObject {
property real displayDistance: effect.displayDistance
// Converts degrees to radians
function degreeToRadian(degree) {
return degree * Math.PI / 180;
@ -23,7 +25,7 @@ QtObject {
}
function displayDistanceDefault() {
return 1.0;
return displayDistance;
}
function actualWrapScheme(screens, viewportWidth, viewportHeight) {

View File

@ -1,7 +1,7 @@
import QtQuick
import QtQuick3D
import org.kde.kwin as KWinComponents
import org.kde.kwin.effect.breezy_desktop
import org.kde.kwin.effect.breezy_desktop_effect
Item {
id: root