From 9e8f0a0c74e5da86450fd90ab76cc4c31f762150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20B=C3=BCchi?= Date: Wed, 17 Jul 2024 09:42:15 +0000 Subject: [PATCH] make taskswitcher preview reluctant to track far finger moves the further up the finger in the gesture activation goes, the less direct the tracking is. fixes the last part of https://invent.kde.org/plasma/plasma-mobile/-/issues/368 --- kwin/mobiletaskswitcher/qml/TaskList.qml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/kwin/mobiletaskswitcher/qml/TaskList.qml b/kwin/mobiletaskswitcher/qml/TaskList.qml index 00ddfab9..44168b63 100644 --- a/kwin/mobiletaskswitcher/qml/TaskList.qml +++ b/kwin/mobiletaskswitcher/qml/TaskList.qml @@ -32,7 +32,23 @@ MouseArea { return baseY + diff / 2 - shellTopMargin - trackFingerYOffset; } - readonly property real trackFingerYOffset: taskSwitcherHelpers.isScaleClamped ? taskSwitcherState.yPosition - taskSwitcherHelpers.openedYPosition : 0 + readonly property real trackFingerYOffset: { + if (taskSwitcherHelpers.isScaleClamped) { + let openedPos = taskSwitcherHelpers.openedYPosition; + let directTrackingOffset = openedPos * 0.2 + if (taskSwitcherState.yPosition < openedPos + directTrackingOffset) { + // Allow the task list to move further up than the fully opened position + return taskSwitcherState.yPosition - openedPos; + } else { + // but make it more reluctant the further up it goes + let overDragProgress = (taskSwitcherState.yPosition - directTrackingOffset - openedPos) / openedPos; + // Base formula is 1-2.3^(-progress) which asymptotically approaches 1 + return (1 - Math.pow(2.3, -overDragProgress)) * openedPos + directTrackingOffset; + } + } else { + return 0; + } + } function getTaskAt(index) { return repeater.itemAt(index);