The only window that we can create perfectly handles all input events, but never is focused?
For example, in the ImGui's opengl2_example the GLFW_FOCUSED attribure checked beafore work with window, but window never is focused.
For more info see ocornut/imgui/pull/1713.
Do you mean that the user must click on the window manually first?
May be... Any plans to add more then one canvas on the page?
Perhaps the simplest solution now is to set the window attribure GLFW_FOCUSED to 1 by default. It's very strange for me that the window that handles user input is out of focus, but method
glfwGetWindowAttrib(window,GLFW_FOCUSED) allways return 0.
And if I call glfwFocusWindow(window), then glfwGetWindowAttrib(window,GLFW_FOCUSED) return 0 too.
There is an open PR for adding multiwindow/multicanvas support for SDL (I don't remember if in the SDL2 ports repo or in this one).
I'm not familiar with glfw, but yeah, it sounds like that flag should be changed. In theory perhaps the right behavior is to say the window is focused if the tab is active, or something like that? Anyhow, PR for this would be very welcome.
Hey guys, can anyone help here or advise a possible implementor?
Cc: @satoshinm, @guillaumeblanc, @cgibson...
In your init code before creating a window call
glfwWindowHint(GLFW_FOCUSED, 1);
Of course we could also add direct support for that feature but if you just want things to work that will do it.
You can also hack on library_glfw.js and just change line 96 from
0x00020001:0, // GLFW_FOCUSED
to
0x00020001:1, // GLFW_FOCUSED
Maybe that should be the default?
I thought about looking into making focus work but it's not an easy as it sounds. Is it that the tab is focused or is it that particular canvas? In other words you can run multiple emscripten apps on a single page, clicking on one seems like it should focus that particular app. But I can also imagine that even if that particular canvas does not have the focus some apps want the focus constantly (meaning even if the user never clicks the canvas they want the mouse position to be transmitted to the app).
So, not really sure what to do there.
I suppose an app that doesn't care about focus wouldn't be calling glfwGetWindowAttrib
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
Most helpful comment
There is an open PR for adding multiwindow/multicanvas support for SDL (I don't remember if in the SDL2 ports repo or in this one).
I'm not familiar with glfw, but yeah, it sounds like that flag should be changed. In theory perhaps the right behavior is to say the window is focused if the tab is active, or something like that? Anyhow, PR for this would be very welcome.