Skip to content
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 SDL2 option to disable mouse capture. #6410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

audetto
Copy link

@audetto audetto commented May 6, 2023

It can cause issues when debugging the application, as the mouse events are not passed to the IDE.

#3650

@ocornut
Copy link
Owner

ocornut commented May 6, 2023

(git tip: FYI when you make change to a PR you can amend/rework then force-push to existing branch. This way you keep same PR # and we can still access its history, no need to create a new PR)

@audetto
Copy link
Author

audetto commented Nov 18, 2023

Is there a chance that this PR is merged?
Should I add something more?

@ocornut
Copy link
Owner

ocornut commented Nov 18, 2023

My last answer on the other thread stands:

“It's hard to trust a PR if you don't put the effort of understanding why we normally need the capture on other systems, in order to decide what is actually the best design/solution for e.g. Wayland.”

And your reply was to suggest you didn’t understand why that capture was needed for. I can’t trust any solution or workaround if you don’t understand the problem (of not capturing) first.

@ocornut
Copy link
Owner

ocornut commented Nov 18, 2023

Since imho it is particularly undesirable to disable mouse capture, at minimum you should understand why and the feature should contains ample comments to explain it to the user, as well as explanining the situation where it may be useful, and explaining why it shouldn’t be used in other situations, and explaining the debugger side solutions etc.

@audetto
Copy link
Author

audetto commented Nov 18, 2023

“It's hard to trust a PR if you don't put the effort of understanding why we normally need the capture on other systems, in order to decide what is actually the best design/solution for e.g. Wayland.”

I am afraid only someone with a full understanding of X11, Wayland, gdb, SDL and ImGui can provide an answer which ticks all your criteria.

I am definitely not that developer.

I can only bring my frustration when the mouse clicks are not passed to the debugger UI and a similar solution provided by Qt: https://doc.qt.io/qt-6/debug.html#command-line-options-recognized-by-qt

This is all I can provide, but I understand it might not be enough.

@ocornut
Copy link
Owner

ocornut commented Nov 18, 2023

I will work on something based on what has been written in both threads.

Could you test the GLFW examples and confirm if the same issue is observed on your setup, and should be lifted?

if so I think i may move this to a backend agnostic configuration flag.

edit: out of clarity you don’t need full understanding of those technologies above to understand what mouse capture does. Since you can mouse capture working on the system you can see the effect it would have on eg: click on a imgui item and move cursor outside of your platform window while holding the click: do you get updated mouse positions while doing so, with and without mouse capture ?

@audetto
Copy link
Author

audetto commented Nov 18, 2023

I have tried 2 examples: example_glfw_opengl3 and example_sdl2_opengl3.

I put a break point https://github.com/ocornut/imgui/blob/3733b5064e1820dc8517fedba2b34bfbdef569ab/imgui_demo.cpp#L1662C28-L1662C28

With glfw I can use the mouse in VSCode, but with SDL2 I cannot.

I used to be able to avoid the issue with a gdb hook: gdb.execute("call SDL_CaptureMouse(0)")

This has stopped working, more or less at the same time as I moved to the default Ubuntu Wayland desktop.
Ubuntu's SDL still prefers to run under X11 (which means XWayland), and I suspect VSCode, gdb and SDL might have different opinions about who manages the mouse (X or Wayland), so the gdb hook call goes to the wrong one.

About capturing the mouse: my UI is not affected by it, but I probably make a very primitive usage of the available features. I only click, there is not dragging or movement tracking while clicking

It can cause issues when debugging the application, as the mouse events are not passed to the IDE.

ocornut#3650

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
@audetto
Copy link
Author

audetto commented Nov 26, 2023

The last paragraph of this:

https://wiki.libsdl.org/SDL2/SDL_CaptureMouse#remarks

seems to talk about a similar use case, but I am not able to test nor confirm what it actually does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants