Skip to content

Change relevant mouse event attributes to floats #2428

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

Closed

Conversation

Starbuck5
Copy link
Member

In preparation for SDL3, where these attributes are floats. See SDL3 include: https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_events.h.

It would be un-ideal to get these attributes as floats and then cast them to ints before returning them to our users, just throwing away the precision. So we should get ready for the higher precision.

This is not 100% backwards compatible, somebody could be indexing an area with a mousemotion.pos for instance. But I think the vast majority of projects will be unaffected. Especially in Python3, where ints do floating division by default anyways. @ankith26 I'm curious if you think the MOUSEWHEEL change will be too disruptive? I feel like it's more of a change than the pos ones.

In preparation for SDL3, where these attributes are floats.
@Starbuck5 Starbuck5 added Code quality/robustness Code quality and resilience to changes event pygame.event labels Aug 29, 2023
@Starbuck5 Starbuck5 requested a review from a team as a code owner August 29, 2023 07:40
@ankith26
Copy link
Member

An alternative is to add precise_pos and precise_rel instead. I know adding more attributes is not super elegant, but atleast it's going to be consistent with precise_x and precise_y that we already added kinda recently (and not deprecate it)?

I'm not pushing for this suggestion, just put up a point for discussion with more people

@Starbuck5
Copy link
Member Author

Closing to wait on this

@Starbuck5 Starbuck5 closed this Sep 5, 2023
@Starbuck5 Starbuck5 deleted the mouse-events-float branch September 5, 2023 07:31
@MyreMylar MyreMylar added this to the 3.0.0 milestone Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code quality/robustness Code quality and resilience to changes event pygame.event
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants