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
Merged

Initial pass on touch support for swaybar #3711

merged 2 commits into from Feb 23, 2019

Conversation

ddevault
Copy link
Member

@ddevault ddevault commented Feb 17, 2019

  • Activate hotspots on tap
  • Cycle workspaces on swipe

Future patches:

Fixes #2377

@emersion emersion added the enhancement New feature or incremental improvement label Feb 17, 2019
swaybar/input.c Outdated 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) {
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link

Choose a reason for hiding this comment

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

Would following condition work?

if (abs(progress - prev_progress) > 10)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so, yep

Copy link
Member

Choose a reason for hiding this comment

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

if (abs(progress) > 10)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

Well I still don't understand it.

Copy link
Member Author

Choose a reason for hiding this comment

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

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).

Copy link
Member Author

@ddevault ddevault Feb 22, 2019

Choose a reason for hiding this comment

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

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 Compare February 22, 2019 16:21
@emersion emersion merged commit d1588e3 into master Feb 23, 2019
@emersion emersion deleted the swaybar-touch branch February 23, 2019 19:00
@emersion
Copy link
Member

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or incremental improvement
Development

Successfully merging this pull request may close these issues.

None yet

3 participants