Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Touchscreen workspace swipe

Open earboxer opened this issue 1 year ago • 4 comments

Describe your PR, what does it fix/add?

Adds support for workspace-swiping via touchscreen

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

It repurposes existing workspace swiping code, and so it supports most of the the "Gestures" configuration parameters:

  • instead of workspace_swipe, it uses workspace_swipe_touch to enable/disable it.
  • workspace_swipe_fingers not relevant
  • workspace_swipe_distance is unused. Or rather, it is ab-used to map the touchscreen's width to [0,100%]
    • Probably should refactor that 'abuse' out before merging this.
  • workspace_swipe_forever has no effect, because the touchscreen's width is mapped to 0-100x, so you can't swipe more than one at a time.
    • I imagine it could be useful to change multiple workspaces at a time, though I like how it feels to drag the workspace over and have it follow your thumb. Maybe we need some workspace_swipe_touch_distance_multiplier parameter to allow this? (but default to 1, which would be the preferred value)
      • This could be done in the future if someone wants it.
  • workspace_swipe_invert is implemented (though it feels weird to use)
  • workspace_swipe_direction_lock has no effect, because the direction is set based on which edge you grabbed

Is it ready for merging, or does it need work?

~~No, this is not ready for merging.~~ Done some work. I think now it could be fine to merge. Work needed:

  • [x] ~~Currently the margins are hard-coded (at 5%)~~. This needs to
    • [x] Be based on gaps_out
    • [x] Account for a layer shell that might be in the way
    • [x] handle vertical workspace changing as well
  • ~~probably need to test with a multimonitor setup (I imagine something needs to be done so we switch the right monitor)~~ I think this will work fine.
  • [ ] Support no_gaps_when_only??? (maybe a nice enhancement)
    • ~~support fullscreened windows~~? (I don't use fullscreen on mobile, doing so one can get trapped, so actually a workspace swipe could help save from that)
    • [ ] maybe do something generic so that floating windows will obstruct this? (not sure how to detect that I touched a floating window).
  • [X] hyprland-wiki PR to add documentation for this feature: https://github.com/hyprwm/hyprland-wiki/pull/448

earboxer avatar Jan 20 '24 20:01 earboxer

review will be stalled until #4656 as it will cause tons of conflicts, sorry

vaxerski avatar Feb 09 '24 03:02 vaxerski

(marked as a draft because I must have added some bugs when rebasing)

earboxer avatar Feb 22 '24 03:02 earboxer

would be nice to configure the number of fingers.

vaxerski avatar Feb 23 '24 01:02 vaxerski

would be nice to configure the number of fingers.

as-is the gesture tracks a single-finger (the one which started the gesture by grabbing the edge). It's very useful on a slate/phablet mobile phone device (where I mostly use my thumb to do everything and using a second finger is an inconvenience).

I can see the use-case for having a multifinger touch swipe gesture (e.g. on a tablet fixed on a stand), but that doesn't share too much in common with the edge-based implementation that this PR represents; I don't think tacking multifinger behavior onto this edge-based gesture would be worth the effort.

earboxer avatar Feb 23 '24 01:02 earboxer

Here's a [very] quick example of this:

https://github.com/hyprwm/Hyprland/assets/12452738/d1202f6a-e798-4160-ab53-1ab6ecca4c6a

earboxer avatar Mar 16 '24 22:03 earboxer

sorry I forgot about this

I am thinking more about 2-in-1s or laptops with a touchscreen (like mine)

How would one otherwise activate and deactivate this? if they wanna use their screen and not swipe

vaxerski avatar Mar 17 '24 00:03 vaxerski

Just don't touch the edge of the screen. The idea is that you're grabbing the gaps (where there's no content) and moving them.

earboxer avatar Mar 17 '24 01:03 earboxer

aaah, okay

makes sense.

vaxerski avatar Mar 17 '24 15:03 vaxerski

Wouldn't it be a good idea to have a separate workspace_swipe_invert for the touchscreen workspace swipe gesture? Bc on my 2-in-1 laptop I would love to use both touchscreen and touchpad for workspace swipes. For touchpad workspace_swipe_invert=false feels weird and for touchscreen workspace_swipe_invert=true feels weird...

leon-erd avatar Mar 18 '24 14:03 leon-erd

On Mon Mar 18, 2024 at 10:13 AM EDT, Leon wrote:

Wouldn't it be a good idea to have a separate workspace_swipe_invert for the touchscreen workspace swipe gesture? Bc on my 2-in-1 laptop I would love to use both touchscreen and touchpad for workspace swipes.

Yes, that makes sense. Feel free to make a PR and I'll review if you tag me in it. I don't have a 2-in-1, which is probably why I didn't think of that.

earboxer avatar Mar 18 '24 16:03 earboxer

I thought this is probably really easy to implement and was just forgotten (as you said) that's why I commented. Unfortunately, I don't know cpp so I don't want to tinker around with that

leon-erd avatar Mar 18 '24 16:03 leon-erd

@leon-erd I would argue that you don't need to know cpp to make that change. you just need to know how to

  1. Add a new config value
  2. Change which config value is read during the touch gesture

If you're interested, you can learn 1 by looking at https://github.com/hyprwm/Hyprland/pull/4489/files#diff-9993bc2bbc311ab9e2cb878dbc44bc4f9d5edc5216b9aa3172e4b10b9b0d61f5 (and the wiki PR for documentation) and 2 by looking at https://github.com/hyprwm/Hyprland/pull/4489/files#diff-22374f0f24e1efb2102fb42abd58b3bae860444eb5b9cb60015a7608333fc53b (Touch.cpp containts the touch-specific code, while Swipe.cpp contains the code that's common to both)

Of course, being able to compile hyprland would be a good too...

earboxer avatar Mar 18 '24 21:03 earboxer