rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.88k stars 913 forks source link

api: move primary from FingerId to Pointer events #3947

Closed kchibisov closed 3 weeks ago

kchibisov commented 1 month ago

Whether the pointer event is primary or not generally matters for the context where all input is done by the same event, so users can ignore non-primary events since they are likely from users clicking something else with their other fingers.

Having it only on a FingerId made it useless, since it's usually used to avoid multi-touch, but if you start mapping on touch event you already can track things like that yourself.

Fixes #3943.

--

@daxpedda I left the web, since it's starting to get messy with those callbacks, so you might want to refactor things to your liking. I could still plumb those bools though. That's also the reason PR doesn't really build.

@madsmtm I did only true for ios, which is likely fine, but I guess we could track based on some Option<Touch>? I decided not to, since ios uses pointer casts for its id, etc.

kchibisov commented 1 month ago

Pointer cast for ID is the proper way to do this on iOS according to my research I did last time already. I don't believe its fine to merge it with just true.

true is more correct in general, since false will potentially prevent you from processing valid input.

In general, my main issue is not that to e.g. track fingers like you did, but which styles + finger should result in primary tracking stuff. For example, all ios input is done the same way via touch, as I said, so e.g. pencil/pen/whatever is also going here, and given that ID is a pointer cast, it's not really a touch in some cases, and according to the primary in the web docs, it seems like for pen/whatever it should be true.

daxpedda commented 1 month ago

In general, my main issue is not that to e.g. track fingers like you did, but which styles + finger should result in primary tracking stuff. For example, all ios input is done the same way via touch, as I said, so e.g. pencil/pen/whatever is also going here, and given that ID is a pointer cast, it's not really a touch in some cases, and according to the primary in the web docs, it seems like for pen/whatever it should be true.

Yes, good point, we should only apply false for touch input. I'm gonna go ahead and do just that for Android and iOS.

kchibisov commented 1 month ago

I'm gonna go ahead and do just that for Android and iOS.

That already works for Android though the way I've implemented If I read the docs correctly, it's not though for ios here, but its docs are not that clear what things actually are. That's the reason I check those up/down events on android since it tells that some of them are primary and the rest is not primary.

kchibisov commented 1 month ago

I've pushed a separate commit with merging all the FingerId under the same thing and squashed what was present.

kchibisov commented 1 month ago

Rebased/changed the type to FingerId on ios/and also made Wayland backend to follow ios behavior.