Fix termselect overshoot

This commit is contained in:
outfoxxed 2024-03-20 04:50:15 -07:00
parent eeb47e9dc1
commit 85ca402006
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 12 additions and 4 deletions

View file

@ -14,7 +14,7 @@ Item {
selectionArea.startY = mouseY; selectionArea.startY = mouseY;
selectionArea.endX = mouseX; selectionArea.endX = mouseX;
selectionArea.endY = mouseY; selectionArea.endY = mouseY;
selectionArea.selecting = true; selectionArea.startSelection(false);
} }
onPositionChanged: { onPositionChanged: {

View file

@ -23,6 +23,7 @@ WlrLayershell {
id: area id: area
property bool selecting: false property bool selecting: false
property bool initializing: false property bool initializing: false
property bool locked: false
property real startX: 0 property real startX: 0
property real startY: 0 property real startY: 0
property real endX: 0 property real endX: 0
@ -41,7 +42,13 @@ WlrLayershell {
width: Math.max(startX, endX) - x + border.width * 2 width: Math.max(startX, endX) - x + border.width * 2
height: Math.max(startY, endY) - y + 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 initializing = true
if (selecting) { if (selecting) {
area.startX = mouseArea.mouseX; area.startX = mouseArea.mouseX;
@ -56,6 +63,7 @@ WlrLayershell {
initializing = false; initializing = false;
if (wasSelecting && bigEnough) { if (wasSelecting && bigEnough) {
locked = true;
selectionComplete(x + 1, y + 1, width - 2, height - 2); selectionComplete(x + 1, y + 1, width - 2, height - 2);
} else { } else {
selecting = false; selecting = false;
@ -81,7 +89,7 @@ WlrLayershell {
area.selecting = true; area.selecting = true;
} }
if (selectionArea.selecting) { if (!selectionArea.locked) {
area.endX = mouseX; area.endX = mouseX;
area.endY = mouseY; area.endY = mouseY;
} }

View file

@ -64,7 +64,7 @@ ShellRoot {
function onTermSelectChanged() { function onTermSelectChanged() {
if (ShellIpc.termSelect) { if (ShellIpc.termSelect) {
selectionLayer.selectionArea.startSelection(); selectionLayer.selectionArea.startSelection(true);
} else { } else {
selectionLayer.selectionArea.endSelection(); selectionLayer.selectionArea.endSelection();
} }