-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add pygame.mouse.get_desktop_pos
#3070
Conversation
How does this work with multiple desktops / monitors? In SDL3 this function will return floats, should this function cast to floats before returning to be ready for that change? |
Unfortunately I can't really test as I only have one monitor. In the past andrew has been the monitor tester so that could be the case here too. About the floats, yeah it's good to return them so for pygame 3 we will have one api breaking change less to worry about. People (when I say people I mean me) usually cast to Vector2 anyways. I can't see a scenario where floats would be annoying. |
I also added the test code I forgot previously in the PR description |
I tried this on my dual monitor setup - I have 1440p monitors and with the monitor layout set to side by side, the mouse positions reported as follows: As you can probably guess, when I changed the monitor layout to vertical i.e. one above the other, the mouse positions reported as follows: This also updated realtime, when changing the monitor layout. |
Also - detecting mouse hover was based on window location and not focus - it was reporting hover even when other apps were in the foreground and my mouse moved over the position where the window was located. |
I am aware of that. That hover detection only works for always-on-top windows. But hovering has nothing to do with this PR core concept therefore I don't think it's a problem. It was only an example |
so I guess the position is relative to the main monitor, not the current monitor, am I wrong? |
Yes, looks like it treats it as one big display area, but the co-ordinates depend on which display is set as primary monitor. The results I gave above are when the right monitor is set to be the primary display. When I change it so the left monitor is the primary display the coordinates range from (0, 0) to (5119, 1439). The left (primary) monitor ranged from (0, 0) to (2559, 1439). |
Alright, that's what I'm gonna say in the documentation. Thank you very much for testing it!! ❤️ |
No problem! In fact, in testing this I discovered that my monitors had not been properly aligned in Windows display settings, with one being 5 pixels higher than the other, so really I should be thanking you 😁 |
This seems broken on both X11 and wayland, and in different ways. I know it's not your fault, but I'd prefer to not expose SDL API that isn't portable, atleast until SDL can fix the issues |
I see where you're coming from, but if we only exposed stuff that worked on Wayland we'd have to delete most of the Window module. What about a Also what does broken mean? I don't see any exception raising in here. |
|
I'm not against exporting stuff that don't work on wayland, for example I think exporting opacity and always-on-top is a good thing despite it not working on wayland because I can see the usecases. In this instance, I don't really see a strong usecase for why an application would need this and not Though feel free to let me know if you have a usecase in mind that is useful enough to ignore the x11/wayland concerns |
@ankith26, so I can think of at least 2 usecases in my most recent application:
|
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.
Okay, I am approving this PR. I think the warning note in the doc on wayland is a good addition. Thanks for contributing! 🎉
Original discord message:
This is simply a wrapper around
SDL_GetGlobalMouseState
which was not wrapped before.Function name changes are welcome.
Test code: