Wayland: Partially implement glfwSetCursorPos
#2496
+37
−2
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.
Wayland does support setting the cursor position with
set_cursor_position_hint
, but in order to call that function we need azwp_locked_pointer_v1
object.By "partially implement" I mean that calling
glfwSetCursorPos
while the cursor mode is not DISABLED will do nothing immediately. I implemented a mechanism that defers the call toset_cursor_position_hint
until we have locked the pointer, if the pointer is not currently locked. This has an effect in these two situations:In situation two we input an error that notifies the application about this.
This is everything required to make the use of
glfwSetCursorPos
in Minecraft work. When closing an GUI in Minecraft, it first sets the cursor position to the center, then sets the cursor mode to DISABLED immediately after. Because of this, Minecraft inadvertently makes use of this "defer" mechanism. Situation two applies. This does mean that the log is hit with an GLFW error every time an GUI is closed, but I don't think there's much that can be done to avoid this.