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
Conversation
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (abs(progress) > 10)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
9945124
to
0ae8a80
Compare
0ae8a80
to
8e95c85
Compare
8e95c85
to
9ecf478
Compare
|
Nice, thanks! |

Future patches:
render.c) configurable so my fat fingers have bigger targetsFixes #2377