Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add touch input support #6695

Merged
merged 4 commits into from Feb 13, 2023
Merged

Add touch input support #6695

merged 4 commits into from Feb 13, 2023

Conversation

chrisduerr
Copy link
Member

This patch builds upon the prior work by @4z3 and @bytbox to add touchscreen support to Alacritty. While some inspiration was taken from @4z3's patch, it was rewritten from scratch.

This patch supports 4 basic touch interactions:

  • Tap
  • Scroll
  • Select
  • Zoom

Tap allows emulating the mouse to enter a single LMB click. While it would be possible to add more complicated mouse emulation including support for RMB and others, it's likely more confusing than anything else and could conflict with other more useful touch actions.

Scroll and Select are started by horizontal or vertical dragging. While selection isn't particularly accurate with a fat finger, it works reasonably well and the separation from selection through horizontal and vertical start feels pretty natural.

Since horizontal drag is reserved for selection we do not support horizontal scrolling inside the terminal. While it would be possible to somewhat support it by starting a selection with vertical movement and then scrolling horizontally afterwards, it would likely just confuse people so it was left out.

Zoom is pretty simple in just changing the font size when a two-finger pinch gesture is used. Performance of this is pretty terrible especially on low-end hardware since this obviously isn't a cheap operation, but it seems like a worthwhile addition since small touchscreen devices are most likely to need frequent font size adjustment to make output readable.

Closes #3671.

@4z3
Copy link
Contributor

4z3 commented Feb 12, 2023

Thanks for pushing this forward! I've tested this patch and it works for me as expected.

@4z3
Copy link
Contributor

4z3 commented Feb 12, 2023

There is one minor difference from the way this branch works vs. my branch (which is a rebased version of #4346):

When zooming, then it's not possible to keep one finger on the touchscreen while sweeping with the other to zoom out or in. Instead, the zooming gesture has to be done without interruption.

For me that's fine, but the previous behavior is more inline with other touch-enabled stuff.

@chrisduerr
Copy link
Member Author

When zooming, then it's not possible to keep one finger on the touchscreen while sweeping with the other to zoom out or in. Instead, the zooming gesture has to be done without interruption.

Yeah I've intentionally made this change to keep things simpler and at least personally I've never used pinch gestures any other way. I might just be speaking from my personal habit, but either way it should be fairly simple to extend the existing functionality to allow for one finger to be released if people do desire it.

Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need a CHANGELOG entry.

alacritty/src/input.rs Outdated Show resolved Hide resolved
alacritty/src/input.rs Show resolved Hide resolved
alacritty/src/event.rs Show resolved Hide resolved
alacritty/src/input.rs Outdated Show resolved Hide resolved
This patch builds upon the prior work by @4z3 and @bytbox to add
touchscreen support to Alacritty. While some inspiration was taken from
@4z3's patch, it was rewritten from scratch.

This patch supports 4 basic touch interactions:
 - Tap
 - Scroll
 - Select
 - Zoom

Tap allows emulating the mouse to enter a single LMB click. While it
would be possible to add more complicated mouse emulation including
support for RMB and others, it's likely more confusing than anything
else and could conflict with other more useful touch actions.

Scroll and Select are started by horizontal or vertical dragging. While
selection isn't particularly accurate with a fat finger, it works
reasonably well and the separation from selection through horizontal and
vertical start feels pretty natural.

Since horizontal drag is reserved for selection we do not support
horizontal scrolling inside the terminal. While it would be possible to
somewhat support it by starting a selection with vertical movement and
then scrolling horizontally afterwards, it would likely just confuse
people so it was left out.

Zoom is pretty simple in just changing the font size when a two-finger
pinch gesture is used. Performance of this is pretty terrible especially
on low-end hardware since this obviously isn't a cheap operation, but it
seems like a worthwhile addition since small touchscreen devices are
most likely to need frequent font size adjustment to make output
readable.

Closes alacritty#3671.
Since the touch state is referenced everywhere as `touch_purpose`
anyway, it should be named accordingly.
Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing this works good, except the Zoom handler. Though, I guess the issue is that we're actually doing IO and most time is spent re-matching the font...

@chrisduerr chrisduerr merged commit 40be4ca into alacritty:master Feb 13, 2023
@chrisduerr chrisduerr deleted the touchy branch February 13, 2023 22:35
@thorstenweber83
Copy link

Love it!
Just as i moved to a x1 yoga and thought i had to live with kitty's weird selection behavior, alacritty comes along with touch support 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add touchscreen support
4 participants