Add get_screen_mouse_position function for Windows and Linux X11 #486
+60
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This function will return the position of the mouse in screen coordinates. This is useful for if I wanna have my program respond to the mouse movement even when it leaves the program.
The
get_screen_mouse_position
function returns the addedscreen_mouse_position
field on theNativeDisplay
struct. That field gets updated every main loop iteration. To get the mouse screen position, on Linux it'sXQueryPointer
and on Windows it'sGetCursorPos
.I tried to only get the mouse screen position whenever the function gets called, but that would require me to have access to
Display
andWindow
on Linux, which seems to only be accessible in the main loop.I also haven't implemented this for MacOS since I do not have any devices to test on.