-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Fix GLFW_CURSOR_DISABLED being ignored when updating cursor position #5625
Conversation
Hello, Thanks for the PR. I believe it is debatable as to whether we want the backend to honor this GLFW setting. Note that you can set The PR technically is missing a few spots (ImGui_ImplGlfw_CursorEnterCallback should not submit an event, ImGui_ImplGlfw_UpdateMouseData |
Hello, |
Good point.
Indeed. What I was suggesting initially what that setting But based on your first point above I agree we should merge this. Let me know if you want to finish the PR otherwise I can do it. |
I can finish the PR. For docking, do I need to open a seperate PR? |
Your suggested changes
have now been implemented. Let me know if there is anything missing. If not, I would open a seperate PR with the same changes for the docking branch. |
Do the PR on master and i’ll look if it’s easy to merge on docking i can do that part. Thank you.
|
Sorry if I'm misunderstanding, but the changes are already pushed in this PR |
This is now merged as 5867a43. Thank you! For reference, a super minimal test bed is running:
|
So how can I now achieve exactly this behavior? I have a viewer application that supports a fullscreen mode. While being windowed, you press e.g. a mouse button to drag the current view on a 3d scene around, which is handled through ImGUIs mouse events. When going to fullscreen, the component that handles these events is stretched over the full screen. For multi-screen systems it is useful when the mouse never leaves the current screen and the cursor still can send events, even when it would hit a screen border. I also don't need any cursor in that mode. Imagine it like a game editor where you can switch to an FPS mode by pressing a button. But now with this change I cannot receive mouse events any more in fullscreen. To work around this, I'd now have to directly grab the mouse events from GLFW, which breaks the abstraction through ImGUI. So, for me, this fix introduced a new bug. So why exactly is setting |
Reopening as this seems like a reasonable statement. |
You're right, that's something I didn't keep in mind when writing the patch. Since I'm thinking of (somehow) intercepting the ImGui's consumption of the coordinates instead of the emission by the backend, so cursor callbacks could still be called if needed. @ocornut Feel free to revert this commit (I'm unfortunately currently unable to) until I submit a rewrite of this PR, because breaking functionality is probably more serious than a mostly visual issue. |
@pborsutzki I just opened another PR, which should fix your issue. Can you confirm that this is the case? |
Hello @scorpion-26, Thanks for your PR.
As the user/app is in control of manipulating GLFW cursor state, it could freely set/clear This strategy would always work. |
I have pushed the revert only (e5977f0) presently I don't see the need for anything else. Let me know @scorpion-26 if I am wrong? I was swayed/convinced in #5625 (comment) but I think the reasoning was wrong since it mandates a backend-specific solution that a third variant exists in GLFW. AFAIK setting |
The GLFW backend currently ignores that the cursor is disabled (GLFW_CURSOR_DISABLED is set by glfwSetInputMode).
This leads to an invisible cursor, that still highlights new ImGui elements when moving the mouse around, even though the cursor should remain static and only highlight the element it was last over before being disabled. This PR adds an check for the flag and returns out of function before ImGuiIO's position is updated.
The current behavior stems from the fact, that GLFW still provides updated cursor position when GLFW_CURSOR_DISABLED is set. I don't know if this is intended though (The documentation is a bit unclear about that, I think).