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

Initial pass on touch support for swaybar #3711

Merged
merged 2 commits into from Feb 23, 2019

Conversation

Projects
None yet
3 participants
@ddevault
Copy link
Member

ddevault commented Feb 17, 2019

  • Activate hotspots on tap
  • Cycle workspaces on swipe

Future patches:

  • Make padding (constants in render.c) configurable so my fat fingers have bigger targets
  • Incorporate with #3697 to create new workspaces on swipe(?)

Fixes #2377

@ddevault ddevault requested a review from emersion Feb 17, 2019

Show resolved Hide resolved swaybar/input.c
Show resolved Hide resolved swaybar/input.c Outdated
Show resolved Hide resolved swaybar/input.c Outdated
// and negative when moving to the left.
int progress = (int)((slot->x - slot->start_x)
/ slot->output->width * 100);
if (abs(progress) % 10 < abs(prev_progress) % 10) {

This comment has been minimized.

Copy link
@emersion

emersion Feb 18, 2019

Member

I'm not sure I get how this condition works. Why use a modulo?

This comment has been minimized.

Copy link
@ddevault

ddevault Feb 18, 2019

Author Member

This is true each time your finger slides past a threshold of 10% of the width of the screen.

This comment has been minimized.

Copy link
@ddevault

ddevault Feb 19, 2019

Author Member

Actually this is pretty weird, not sure what I was thinking here. Will revisit this

This comment has been minimized.

Copy link
@benutzer193

benutzer193 Feb 20, 2019

Would following condition work?

if (abs(progress - prev_progress) > 10)

This comment has been minimized.

Copy link
@ddevault

ddevault Feb 20, 2019

Author Member

I think so, yep

This comment has been minimized.

Copy link
@emersion

emersion Feb 22, 2019

Member
if (abs(progress) > 10)

?

This comment has been minimized.

Copy link
@ddevault

ddevault Feb 22, 2019

Author Member

No, after further testing and reasoning I believe the original conditional is correct.

This comment has been minimized.

Copy link
@emersion

emersion Feb 22, 2019

Member

Well I still don't understand it.

This comment has been minimized.

Copy link
@ddevault

ddevault Feb 22, 2019

Author Member

Progress is a value from [0..100) which represents how far your finger has travelled from its starting point to the starting point plus the width of the screen. We subdivide the bar into 10 segments, and passing from one segment to the next causes the workspace to change. We offset these by your starting position, so if you touch, then travel 10% of the screen, you go to workspace +1, then 10% more and workspace +2, and so on.

progress will be < prev_progress when you cross one of these thresholds - the previous value will be near the end of the last segment, so a higher number (in this example 9), and the new value will be near the start of the next segment, so a lower number (in this example 2).

This comment has been minimized.

Copy link
@ddevault

ddevault Feb 22, 2019

Author Member

Actually, reworked this a bit to make it behave a bit more intuitively. Does the new approach make more sense?

@ddevault ddevault force-pushed the swaybar-touch branch 3 times, most recently from 9945124 to 0ae8a80 Feb 22, 2019

@ddevault ddevault force-pushed the swaybar-touch branch from 0ae8a80 to 8e95c85 Feb 22, 2019

@ddevault ddevault force-pushed the swaybar-touch branch from 8e95c85 to 9ecf478 Feb 22, 2019

@emersion emersion merged commit d1588e3 into master Feb 23, 2019

3 checks passed

builds.sr.ht: alpine.yml builds.sr.ht job completed successfully
Details
builds.sr.ht: archlinux.yml builds.sr.ht job completed successfully
Details
builds.sr.ht: freebsd.yml builds.sr.ht job completed successfully
Details

@emersion emersion deleted the swaybar-touch branch Feb 23, 2019

@emersion

This comment has been minimized.

Copy link
Member

emersion commented Feb 23, 2019

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.