-
Notifications
You must be signed in to change notification settings - Fork 947
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
X11: Report CursorMoved
when touch event occurs
#1297
X11: Report CursorMoved
when touch event occurs
#1297
Conversation
@dhardy Can you confirm that this PR resolves the issue? |
Ah, sorry. Yes, it does, but it causes another more subtle bug because now all touch events fire The solution would be to only fire |
@dhardy I've implemented the fix you described. Does everything seem to be working as expected now? |
I didn't think to test a third touch event started after the first ends (but while the second is still active). Both commits fail in this case. Instead, a touch should only be able to become a "first touch" if there are no other active touch events when it starts. |
@dhardy Oh, what a silly mistake on my part. I'm glad you caught it. I've pushed another fix. |
Just tested, and it passes my obscure test, but not the much simpler test of touch and drag across buttons: the first button remains highlighted. I will investigate tomorrow. (Also, touch-cancel events seem to be causing issues but this may be my UI). |
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.
Corrected version here (tested): https://github.com/dhardy/winit/commits/x11-touch-cursor-moved
I also took the liberty of removing that complicated data structure we don't actually need. Counting is enough in this case.
@@ -1216,3 +1241,19 @@ impl<T: 'static> EventProcessor<T> { | |||
} | |||
} | |||
} | |||
|
|||
fn is_first_touch(m: &mut HashSet<u64>, id: u64, phase: TouchPhase) -> bool { | |||
let is_first = m.is_empty(); |
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 logic is incorrect except on TouchPhase::Started.
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.
Fixed again. Hopefully.
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.
Also, I changed the code from using a HashSet
to a simple count of concurrent running touch events. As long as winit doesn't receive a duplicate Ended
event, it should work as well as the HashSet
.
Is there any reason you keep re-writing my patches? I already tested mine, now I have to test this one too. |
@dhardy I didn't realize you were writing any patches. It seems we each arrived at the same solution independently. |
The first I created a pull-request against your fork, and the second I linked above. |
Well, I'm sorry, but I didn't see either of those. I just saw the one comment on my code, so I wrote my own fix, which appears to have essentially the same logic. If you've tested your version and can confirm that it resolves the issue, I think this PR is ready to be reviewed and merged. |
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.
Anyway, the above below optimisation is irrelevant. I tested this code and it appears to work correctly, so this gets a 👍 and thanks for the effort!
(For what it's worth, the reason I didn't open a PR myself is that I was unsure if adding an X11-specific workaround was the correct thing to do.)
} | ||
TouchPhase::Cancelled | TouchPhase::Ended => { | ||
if *first == Some(id) { | ||
*first = None; |
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.
My understanding is that this is correct, but unnecessary: if num == 0
then first == Some(id)
is never evaluated (except on TouchPhase::Ended
for the last event, when the above ids are still valid). As soon as the next event starts, first
is re-assigned. Thus in my version I didn't bother using an Option
here.
@goddessfreya I believe this PR is now ready for review. |
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.
lgtm if it works for @dhardy
Closes #1261
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to users