From 85ca402006f29a1eae533891985d1453454eab8b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 20 Mar 2024 04:50:15 -0700 Subject: [PATCH] Fix termselect overshoot --- .../user/modules/quickshell/shell/SelectionArea.qml | 2 +- .../user/modules/quickshell/shell/SelectionLayer.qml | 12 ++++++++++-- modules/user/modules/quickshell/shell/shell.qml | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/user/modules/quickshell/shell/SelectionArea.qml b/modules/user/modules/quickshell/shell/SelectionArea.qml index 2f3a44e..b96ed83 100644 --- a/modules/user/modules/quickshell/shell/SelectionArea.qml +++ b/modules/user/modules/quickshell/shell/SelectionArea.qml @@ -14,7 +14,7 @@ Item { selectionArea.startY = mouseY; selectionArea.endX = mouseX; selectionArea.endY = mouseY; - selectionArea.selecting = true; + selectionArea.startSelection(false); } onPositionChanged: { diff --git a/modules/user/modules/quickshell/shell/SelectionLayer.qml b/modules/user/modules/quickshell/shell/SelectionLayer.qml index 2ad6b51..30e0758 100644 --- a/modules/user/modules/quickshell/shell/SelectionLayer.qml +++ b/modules/user/modules/quickshell/shell/SelectionLayer.qml @@ -23,6 +23,7 @@ WlrLayershell { id: area property bool selecting: false property bool initializing: false + property bool locked: false property real startX: 0 property real startY: 0 property real endX: 0 @@ -41,7 +42,13 @@ WlrLayershell { width: Math.max(startX, endX) - x + border.width * 2 height: Math.max(startY, endY) - y + border.width * 2 - function startSelection() { + function startSelection(initialize: bool) { + locked = false; + if (!initialize) { + selecting = true; + return; + } + initializing = true if (selecting) { area.startX = mouseArea.mouseX; @@ -56,6 +63,7 @@ WlrLayershell { initializing = false; if (wasSelecting && bigEnough) { + locked = true; selectionComplete(x + 1, y + 1, width - 2, height - 2); } else { selecting = false; @@ -81,7 +89,7 @@ WlrLayershell { area.selecting = true; } - if (selectionArea.selecting) { + if (!selectionArea.locked) { area.endX = mouseX; area.endY = mouseY; } diff --git a/modules/user/modules/quickshell/shell/shell.qml b/modules/user/modules/quickshell/shell/shell.qml index 82cc55b..ae1af0a 100644 --- a/modules/user/modules/quickshell/shell/shell.qml +++ b/modules/user/modules/quickshell/shell/shell.qml @@ -64,7 +64,7 @@ ShellRoot { function onTermSelectChanged() { if (ShellIpc.termSelect) { - selectionLayer.selectionArea.startSelection(); + selectionLayer.selectionArea.startSelection(true); } else { selectionLayer.selectionArea.endSelection(); }