Add look-ahead override slider

This commit is contained in:
wheaney 2025-09-12 22:32:42 -07:00
parent d6cdefc272
commit db1faf706b
6 changed files with 60 additions and 35 deletions

View File

@ -202,6 +202,7 @@ void BreezyDesktopEffect::recenter() {
void BreezyDesktopEffect::reconfigure(ReconfigureFlags)
{
BreezyDesktopConfig::self()->read();
setLookAheadOverride(BreezyDesktopConfig::lookAheadOverride());
setFocusedDisplayDistance(BreezyDesktopConfig::focusedDisplayDistance() / 100.0f);
setAllDisplaysDistance(BreezyDesktopConfig::allDisplaysDistance() / 100.0f);
setDisplaySpacing(BreezyDesktopConfig::displaySpacing() / 1000.0f);
@ -397,6 +398,17 @@ QList<qreal> BreezyDesktopEffect::lookAheadConfig() const {
return m_lookAheadConfig;
}
qreal BreezyDesktopEffect::lookAheadOverride() const {
return m_lookAheadOverride;
}
void BreezyDesktopEffect::setLookAheadOverride(qreal override) {
if (override != m_lookAheadOverride) {
m_lookAheadOverride = override;
Q_EMIT lookAheadOverrideChanged();
}
}
QList<quint32> BreezyDesktopEffect::displayResolution() const {
return m_displayResolution;
}

View File

@ -27,6 +27,7 @@ namespace KWin
Q_PROPERTY(QSize cursorImageSize READ cursorImageSize NOTIFY cursorImageSourceChanged)
Q_PROPERTY(QPointF cursorPos READ cursorPos NOTIFY cursorPosChanged)
Q_PROPERTY(QList<qreal> lookAheadConfig READ lookAheadConfig NOTIFY devicePropertiesChanged)
Q_PROPERTY(qreal lookAheadOverride READ lookAheadOverride WRITE setLookAheadOverride NOTIFY devicePropertiesChanged)
Q_PROPERTY(QList<quint32> displayResolution READ displayResolution NOTIFY devicePropertiesChanged)
Q_PROPERTY(qreal focusedDisplayDistance READ focusedDisplayDistance NOTIFY focusedDisplayDistanceChanged)
Q_PROPERTY(qreal allDisplaysDistance READ allDisplaysDistance NOTIFY allDisplaysDistanceChanged)
@ -63,6 +64,8 @@ namespace KWin
quint64 imuTimestamp() const;
bool imuResetState() const;
QList<qreal> lookAheadConfig() const;
qreal lookAheadOverride() const;
void setLookAheadOverride(qreal override);
QList<quint32> displayResolution() const;
qreal focusedDisplayDistance() const;
void setFocusedDisplayDistance(qreal distance);
@ -98,6 +101,7 @@ namespace KWin
bool removeVirtualDisplay(const QString &id);
Q_SIGNALS:
void lookAheadOverrideChanged();
void focusedDisplayDistanceChanged();
void allDisplaysDistanceChanged();
void displaySpacingChanged();
@ -133,6 +137,7 @@ namespace KWin
quint32 m_imuTimeElapsedMs;
quint64 m_imuTimestamp = 0;
QList<qreal> m_lookAheadConfig;
qreal m_lookAheadOverride = -1.0; // -1 = use device default
QList<quint32> m_displayResolution;
qreal m_diagonalFOV;
qreal m_lensDistanceRatio;

View File

@ -112,6 +112,7 @@ BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPlu
connect(ui.kcfg_DisplaySpacing, &QSlider::valueChanged, this, &BreezyDesktopEffectConfig::save);
connect(ui.kcfg_DisplayHorizontalOffset, &QSlider::valueChanged, this, &BreezyDesktopEffectConfig::save);
connect(ui.kcfg_DisplayVerticalOffset, &QSlider::valueChanged, this, &BreezyDesktopEffectConfig::save);
connect(ui.kcfg_LookAheadOverride, &QSlider::valueChanged, this, &BreezyDesktopEffectConfig::save);
connect(ui.kcfg_DisplayWrappingScheme, qOverload<int>(&QComboBox::currentIndexChanged), this, &BreezyDesktopEffectConfig::save);
connect(ui.kcfg_AntialiasingQuality, qOverload<int>(&QComboBox::currentIndexChanged), this, &BreezyDesktopEffectConfig::save);
connect(ui.kcfg_MirrorPhysicalDisplays, &QCheckBox::toggled, this, &BreezyDesktopEffectConfig::save);
@ -169,6 +170,9 @@ BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPlu
renderVirtualDisplays(list);
});
}
if (auto lookAheadOverrideSlider = widget()->findChild<LabeledSlider*>("kcfg_LookAheadOverride")) {
lookAheadOverrideSlider->setValueText(-1, i18n("Default"));
}
renderVirtualDisplays(dbusListVirtualDisplays());
@ -235,6 +239,7 @@ void BreezyDesktopEffectConfig::updateUiFromConfig()
ui.kcfg_DisplaySpacing->setValue(BreezyDesktopConfig::self()->displaySpacing());
ui.kcfg_DisplayHorizontalOffset->setValue(BreezyDesktopConfig::self()->displayHorizontalOffset());
ui.kcfg_DisplayVerticalOffset->setValue(BreezyDesktopConfig::self()->displayVerticalOffset());
ui.kcfg_LookAheadOverride->setValue(BreezyDesktopConfig::self()->lookAheadOverride());
ui.kcfg_DisplayWrappingScheme->setCurrentIndex(BreezyDesktopConfig::self()->displayWrappingScheme());
ui.kcfg_AntialiasingQuality->setCurrentIndex(BreezyDesktopConfig::self()->antialiasingQuality());
ui.kcfg_MirrorPhysicalDisplays->setChecked(BreezyDesktopConfig::self()->mirrorPhysicalDisplays());

View File

@ -343,7 +343,33 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QLabel" name="labelLookAheadOverride">
<property name="text">
<string>Movement look-ahead (ms):</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="LabeledSlider" name="kcfg_LookAheadOverride">
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
<property name="tickStartOffset">
<double>1</double>
</property>
<property name="tickInterval">
<double>5</double>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tracking">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_RemoveVirtualDisplaysOnDisable">
<property name="visible">
<bool>false</bool>
@ -357,7 +383,7 @@
<property name="checked"><bool>true</bool></property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_MirrorPhysicalDisplays">
<property name="text">
<string>Mirror physical displays (may impact performance)</string>
@ -365,7 +391,7 @@
<property name="checked"><bool>false</bool></property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="EnableMultitap">
<property name="text">
<string>Enable multi-tap detection</string>

View File

@ -32,9 +32,6 @@ class LabeledSlider : public QSlider {
// tickStartOffset: starting offset for label positions relative to minimum().
// Example: minimum=0, tickInterval=20, tickStartOffset=10 -> labels at 10,30,50,...
Q_PROPERTY(int tickStartOffset READ tickStartOffset WRITE setTickStartOffset)
// valueTextPairs: allows setting custom labels from .ui (Designer) as a string list.
// Format each entry as "int: Text" or "int=Text". Example: ["0: Off", "100: Max"].
Q_PROPERTY(QStringList valueTextPairs READ valueTextPairs WRITE setValueTextPairs)
public:
explicit LabeledSlider(QWidget *parent = nullptr)
: QSlider(Qt::Horizontal, parent)
@ -77,34 +74,6 @@ public:
QMap<int, QString> valueTexts() const { return m_valueTexts; }
// Property for .ui usage
QStringList valueTextPairs() const {
QStringList list;
for (auto it = m_valueTexts.constBegin(); it != m_valueTexts.constEnd(); ++it) {
list << (QString::number(it.key()) + QLatin1String(": ") + it.value());
}
return list;
}
void setValueTextPairs(const QStringList &pairs) {
QMap<int, QString> newMap;
for (const QString &raw : pairs) {
QString s = raw.trimmed();
if (s.isEmpty()) continue;
int sep = s.indexOf(QLatin1Char(':'));
if (sep == -1) sep = s.indexOf(QLatin1Char('='));
if (sep == -1) continue; // skip invalid entry
QString left = s.left(sep).trimmed();
QString right = s.mid(sep + 1).trimmed();
bool ok = false;
int v = left.toInt(&ok);
if (!ok) continue;
newMap.insert(v, right);
}
if (m_valueTexts == newMap) return;
m_valueTexts = std::move(newMap);
update();
}
int decimalShift() const { return m_decimalShift; }
void setDecimalShift(int shift) {
// clamp to sensible range
@ -194,7 +163,15 @@ protected:
int topY = handle.top() - gap - extraLift - textRect.height();
if (topY < 0) topY = 0; // clamp to widget
textRect.moveTop(topY);
// Center horizontally over handle
textRect.moveLeft(handle.center().x() - textRect.width()/2);
// Clamp horizontally so we don't paint outside and get clipped
if (textRect.left() < 0) {
textRect.moveLeft(0);
}
if (textRect.right() > width()) {
textRect.moveLeft(width() - textRect.width());
}
// Bubble shape
QPainterPath path;

View File

@ -22,7 +22,7 @@ Item {
effect.imuRotations[0],
effect.imuRotations[1],
effect.imuTimeElapsedMs,
lookAheadMS(effect.imuTimestamp, effect.lookAheadConfig, -1)
lookAheadMS(effect.imuTimestamp, effect.lookAheadConfig, effect.lookAheadOverride)
);
camera.position = effect.imuRotations[0].times(Qt.vector3d(0, 0, -fovDetails.lensDistancePixels));
}