imgui-sfml
imgui-sfml copied to clipboard
Don't care about focus when processing events / updating
Fixes #212, #206, #88 Now the user has to not call Update/ProcessEvent on lost focus manually. Might break some things (e.g. trigger some asserts if the user didn't call NewFrame/Render on focus lost).
@oprypin @ChrisThrasher, please review
Thanks. But sadly, this does not work well :disappointed:
Consider the situation when another window (ideally a translucent one) is active and is partially covering the imgui window. The behavior of hover events over menu items is as follows:
-
Without this change: no hover events, ever
-
imgui SDL backend: hover events happen only on the unobscured part of the window
-
With this change: hover and click events happen even on the obscured part of the window
How does SDL backend manage it? Does it keep track of which window is active?
And can’t it be left to the user? E.g. making sure to only call ProcessEvent of the currently focused window, but not others?
SDL backend uses a combination of SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH to check whether a window is hovered without focus, but this isn't something SFML supports so I don't think there's anything you can do about it
To me this change seems sensible - windows don't get events anyway when they aren't focussed so adding extra checks in your code is redundant and just adds risk of issues (as reported)
I don't think it's OK that clicking on an unrelated application will send clicks to an imgui-sfml application that happens to be hidden behind it.
I don't think it's OK that clicking on an unrelated application will send clicks to an imgui-sfml application that happens to be hidden behind it.
How does this happen? SFML only receives events if the window has focus
Just run it and see for yourself if you don't believe
I guess hover events happen because we're changing io.MouseDown
- we can just not do that when window has no focus (same with io.MouseDown
, gamepad etc.)
But it looks like it lands us at square one. 🤔
Yeah I don’t think you can do anything about hovering on partially visible windows unless you write the platform implementations for it yourself.
If you just change to use events then users would still be able to implement this themselves if desired