From 22b095e340edd011292c41628fb98f739afe5517 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Tue, 16 Dec 2025 19:55:50 -0500 Subject: [PATCH] gestures: Set kwin touch area to be gesture guide area height Use a heuristic (the height of the gesture guide panel) to set the gesture trigger area. --- .../mobileshell/qml/components/Constants.qml | 7 +++++ .../shellsettingsplugin/kwinsettings.cpp | 29 +++++++++++++++++-- components/shellsettingsplugin/kwinsettings.h | 15 ++++++++++ containments/taskpanel/CMakeLists.txt | 1 + .../taskpanel/qml/GesturePanelComponent.qml | 20 +++++++++++++ containments/taskpanel/qml/main.qml | 5 +--- 6 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 containments/taskpanel/qml/GesturePanelComponent.qml diff --git a/components/mobileshell/qml/components/Constants.qml b/components/mobileshell/qml/components/Constants.qml index 4ab68605..9b0c9491 100644 --- a/components/mobileshell/qml/components/Constants.qml +++ b/components/mobileshell/qml/components/Constants.qml @@ -40,6 +40,13 @@ QtObject { return root.panelSettings.navigationPanelHeight; } + readonly property real screenEdgeTouchTarget: (ShellSettings.Settings.gesturePanelEnabled && !ShellSettings.Settings.navigationPanelEnabled) ? defaultGesturePanelThickness : 8 + onScreenEdgeTouchTargetChanged: { + if (ShellSettings.KWinSettings.screenEdgeTouchTarget != screenEdgeTouchTarget) { + ShellSettings.KWinSettings.screenEdgeTouchTarget = screenEdgeTouchTarget; + } + } + function navigationPanelOnSide(screenWidth: real, screenHeight: real): bool { // TODO: we have this disabled for now, we might consider just removing this feature entirely due to it causing several issues: // (the feature being the navigation panel being moved to the right when the screen height is small) diff --git a/components/shellsettingsplugin/kwinsettings.cpp b/components/shellsettingsplugin/kwinsettings.cpp index def45ae3..66fae4fa 100644 --- a/components/shellsettingsplugin/kwinsettings.cpp +++ b/components/shellsettingsplugin/kwinsettings.cpp @@ -7,17 +7,22 @@ #include "kwinsettings.h" 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"); KWinSettings::KWinSettings(QObject *parent) : QObject{parent} , m_config{KSharedConfig::openConfig(CONFIG_FILE)} + , m_overlayConfig{KSharedConfig::openConfig(OVERLAY_CONFIG_FILE)} { m_configWatcher = KConfigWatcher::create(m_config); connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void { Q_UNUSED(names) if (group.name() == WAYLAND_CONFIG_GROUP) { Q_EMIT doubleTapWakeupChanged(); + } else if (group.name() == SCREEN_EDGES_CONFIG_GROUP) { + Q_EMIT screenEdgeTouchTargetChanged(); } }); } @@ -30,7 +35,25 @@ bool KWinSettings::doubleTapWakeup() const void KWinSettings::setDoubleTapWakeup(bool enabled) { - auto group = KConfigGroup{m_config, WAYLAND_CONFIG_GROUP}; - group.writeEntry("DoubleTapWakeup", enabled, KConfigGroup::Notify); - m_config->sync(); + if (enabled != doubleTapWakeup()) { + auto group = KConfigGroup{m_config, WAYLAND_CONFIG_GROUP}; + group.writeEntry("DoubleTapWakeup", enabled, KConfigGroup::Notify); + m_config->sync(); + } +} + +int KWinSettings::screenEdgeTouchTarget() const +{ + auto group = KConfigGroup{m_overlayConfig, SCREEN_EDGES_CONFIG_GROUP}; + return group.readEntry("TouchTarget", 0); +} + +void KWinSettings::setScreenEdgeTouchTarget(int target) +{ + // Use m_overlayConfig instead of m_config so we don't affect other shells + if (target != screenEdgeTouchTarget()) { + auto group = KConfigGroup{m_overlayConfig, SCREEN_EDGES_CONFIG_GROUP}; + group.writeEntry("TouchTarget", target, KConfigGroup::Notify); + m_overlayConfig->sync(); + } } diff --git a/components/shellsettingsplugin/kwinsettings.h b/components/shellsettingsplugin/kwinsettings.h index 99bd6682..87ab3805 100644 --- a/components/shellsettingsplugin/kwinsettings.h +++ b/components/shellsettingsplugin/kwinsettings.h @@ -19,6 +19,7 @@ class KWinSettings : public QObject QML_SINGLETON Q_PROPERTY(bool doubleTapWakeup READ doubleTapWakeup WRITE setDoubleTapWakeup NOTIFY doubleTapWakeupChanged) + Q_PROPERTY(int screenEdgeTouchTarget READ screenEdgeTouchTarget WRITE setScreenEdgeTouchTarget NOTIFY screenEdgeTouchTargetChanged) public: KWinSettings(QObject *parent = nullptr); @@ -35,10 +36,24 @@ public: */ void setDoubleTapWakeup(bool enabled); + /** + * Get the screen edge touch target value. + */ + int screenEdgeTouchTarget() const; + + /** + * Set the screen edge touch target value. + * + * @param target + */ + void setScreenEdgeTouchTarget(int target); + Q_SIGNALS: void doubleTapWakeupChanged(); + void screenEdgeTouchTargetChanged(); private: KConfigWatcher::Ptr m_configWatcher; KSharedConfig::Ptr m_config; + KSharedConfig::Ptr m_overlayConfig; }; diff --git a/containments/taskpanel/CMakeLists.txt b/containments/taskpanel/CMakeLists.txt index ef297d92..b00404f4 100644 --- a/containments/taskpanel/CMakeLists.txt +++ b/containments/taskpanel/CMakeLists.txt @@ -7,6 +7,7 @@ plasma_add_applet(org.kde.plasma.mobile.taskpanel QML_SOURCES qml/main.qml qml/NavigationPanelComponent.qml + qml/GesturePanelComponent.qml CPP_SOURCES taskpanel.cpp ) diff --git a/containments/taskpanel/qml/GesturePanelComponent.qml b/containments/taskpanel/qml/GesturePanelComponent.qml new file mode 100644 index 00000000..dc1c79d9 --- /dev/null +++ b/containments/taskpanel/qml/GesturePanelComponent.qml @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2015 Marco Martin +// SPDX-FileCopyrightText: 2021-2023 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +import QtQuick + +import org.kde.kirigami 2.20 as Kirigami + +import org.kde.plasma.plasmoid + +import org.kde.plasma.private.mobileshell as MobileShell +import org.kde.plasma.private.mobileshell.state as MobileShellState +import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings + +MobileShell.GesturePanel { + id: root + + onHandlePressedAndHeld: MobileShellState.ShellDBusClient.openHomeScreen() + onHandleClicked: Plasmoid.triggerTaskSwitcher() +} diff --git a/containments/taskpanel/qml/main.qml b/containments/taskpanel/qml/main.qml index 106e0105..a6117389 100644 --- a/containments/taskpanel/qml/main.qml +++ b/containments/taskpanel/qml/main.qml @@ -197,15 +197,12 @@ ContainmentItem { Component { id: gesturePanelComponent - MobileShell.GesturePanel { + GesturePanelComponent { opaqueBar: root.opaqueBar Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: (!opaqueBar && !startupFeedbackColorAnimation.isShowing) ? Kirigami.Theme.Complementary : Kirigami.Theme.Window - onHandlePressedAndHeld: MobileShellState.ShellDBusClient.openHomeScreen() - onHandleClicked: Plasmoid.triggerTaskSwitcher() - transform: [ Translate { y: inLandscape ? 0 : navigationPanel.offset