From ba1428851e99cc140764ff4e1a8360bfc54052a5 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Tue, 5 May 2026 13:30:52 +0200 Subject: [PATCH] Expose KWin titlebar button order to QML Snap-assist needs the configured decoration button order to find the maximize button after users move titlebar controls between sides. --- components/shellsettingsplugin/kwinsettings.cpp | 15 +++++++++++++++ components/shellsettingsplugin/kwinsettings.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/components/shellsettingsplugin/kwinsettings.cpp b/components/shellsettingsplugin/kwinsettings.cpp index 361a2188..11bd8b95 100644 --- a/components/shellsettingsplugin/kwinsettings.cpp +++ b/components/shellsettingsplugin/kwinsettings.cpp @@ -13,6 +13,7 @@ const QString CONFIG_FILE = QStringLiteral("kwinrc"); const QString OVERLAY_CONFIG_FILE = QStringLiteral("plasma-mobile/kwinrc"); const QString WAYLAND_CONFIG_GROUP = QStringLiteral("Wayland"); const QString SCREEN_EDGES_CONFIG_GROUP = QStringLiteral("ScreenEdges"); +const QString DECORATION_CONFIG_GROUP = QStringLiteral("org.kde.kdecoration2"); KWinSettings::KWinSettings(QObject *parent) : QObject{parent} @@ -26,6 +27,8 @@ KWinSettings::KWinSettings(QObject *parent) Q_EMIT doubleTapWakeupChanged(); } else if (group.name() == SCREEN_EDGES_CONFIG_GROUP) { Q_EMIT screenEdgeTouchTargetChanged(); + } else if (group.name() == DECORATION_CONFIG_GROUP) { + Q_EMIT titleButtonsChanged(); } }); } @@ -64,3 +67,15 @@ void KWinSettings::setScreenEdgeTouchTarget(int target) QDBusConnection::sessionBus().send(message); } } + +QString KWinSettings::titleButtonsOnLeft() const +{ + auto group = KConfigGroup{m_config, DECORATION_CONFIG_GROUP}; + return group.readEntry("ButtonsOnLeft", QStringLiteral("MSE")); +} + +QString KWinSettings::titleButtonsOnRight() const +{ + auto group = KConfigGroup{m_config, DECORATION_CONFIG_GROUP}; + return group.readEntry("ButtonsOnRight", QStringLiteral("HIAX")); +} diff --git a/components/shellsettingsplugin/kwinsettings.h b/components/shellsettingsplugin/kwinsettings.h index 87ab3805..8c47c010 100644 --- a/components/shellsettingsplugin/kwinsettings.h +++ b/components/shellsettingsplugin/kwinsettings.h @@ -20,6 +20,8 @@ class KWinSettings : public QObject Q_PROPERTY(bool doubleTapWakeup READ doubleTapWakeup WRITE setDoubleTapWakeup NOTIFY doubleTapWakeupChanged) Q_PROPERTY(int screenEdgeTouchTarget READ screenEdgeTouchTarget WRITE setScreenEdgeTouchTarget NOTIFY screenEdgeTouchTargetChanged) + Q_PROPERTY(QString titleButtonsOnLeft READ titleButtonsOnLeft NOTIFY titleButtonsChanged) + Q_PROPERTY(QString titleButtonsOnRight READ titleButtonsOnRight NOTIFY titleButtonsChanged) public: KWinSettings(QObject *parent = nullptr); @@ -48,9 +50,20 @@ public: */ void setScreenEdgeTouchTarget(int target); + /** + * Configured KWin titlebar buttons on the left side. + */ + QString titleButtonsOnLeft() const; + + /** + * Configured KWin titlebar buttons on the right side. + */ + QString titleButtonsOnRight() const; + Q_SIGNALS: void doubleTapWakeupChanged(); void screenEdgeTouchTargetChanged(); + void titleButtonsChanged(); private: KConfigWatcher::Ptr m_configWatcher;