emersion / slurp

Select a region in a Wayland compositor
https://wayland.emersion.fr/slurp
MIT License
951 stars 57 forks source link

Feature: Alternate selection mode for easier touchpad usage? #76

Open wisp3rwind opened 3 years ago

wisp3rwind commented 3 years ago

I rarely use my computer with a physical mouse attached, so I need to use the touchpad to make selections. When selecting larger regions, the click-drag-release method of defining the region often doesn't work well (even when pointer movement is configured quite fast). Would you consider adding an alternative mode (i.e. a CLI option to switch to it) where the first click/tap sets the first corner, then the cursor could be moved freely with no button held, and the second corner would only be set after a second click/tap?

As with my other feature request, I might look into implementing it myself. I've essentially no knowledge of sway/slurp/wayland internals, though, so if someone else would go ahead, I'd appreciate it a lot. Thanks!

maximbaz commented 3 years ago

I agree with the problem but I would like to propose an alternative solution to it: how about we keep click-drag-release mode, but allow to correct it? In other words, you draw an initial rectangle, once you release the button slurp doesn't immediately exit but keeps the rectangle drawn, you can then grab it by any edge and continue resizing, and only after pressing Enter slurp exits and prints the dimensions of the final rectangle. This way you don't have to be precise on the first try (not with dragging, nor with clicking on two points), and at the same slurp doesn't have to have two completely different modes of operation (click-drag-release and click-release-click-release).

What do you think?

wisp3rwind commented 3 years ago

That sounds quite useful, too! Without a prototype, it's probably hard to tell which approach works out better. My approach would have the advantage that I don't need to double-tap when selecting the first point. On the other hand, I agree that your idea integrates better with the current behaviour. It would also open the way to use keybindings to modify the selection.

emersion commented 3 years ago

I'm a little worried about feature creep here. I'd like to keep slurp relatively simple, it seems like adding alternate modes or the ability to amend the selection would make it significantly more complicated.

wisp3rwind commented 3 years ago

Yeah, I see your point. In particular, having two alternate modes which are switched by a CLI option doesn't really sound ideal to me either.

cristobaltapia commented 3 years ago

Maybe a key can be configured to act as alternative mouse click? That way you can hold the key while you are drawing with the touchpad.

layus commented 2 years ago

Or maybe make Ctrl preserve the selection until it is released ? A key would also move the behavior switch away from the cli options.

RyanGibb commented 2 years ago

It's not ideal, but this script to convert 2 points to a region may be of use to some people:

#!/usr/bin/env bash

set -o pipefail

point="$(slurp -p | cut -d \  -f 1)" || exit

IFS=',' read -ra coord <<< "$point"
x1="${coord[0]}"
y1="${coord[1]}"

point="$(slurp -p | cut -d \  -f 1)" || exit

IFS=',' read -ra coord <<< "$point"
x2="${coord[0]}"
y2="${coord[1]}"

if (($x1 < $x2)); then
    x_size=$(($x2 - $x1))
    x=$x1
else
    x_size=$(($x1 - $x2))
    x=$x2
fi

if (($y1 < $y2)); then
    y_size=$(($y2 - $y1))
    y=$y1
else
    y_size=$(($y1 - $y2))
    y=$y2
fi

echo $x,$y ${x_size}x$y_size