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

library_glfw.js: glfwFocusWindow/glfwGetWindowAttrib(window,GLFW_FOCUSED) broken #6409

Closed
podsvirov opened this issue Mar 31, 2018 · 7 comments

Comments

@podsvirov
Copy link
Contributor

The only window that we can create perfectly handles all input events, but never is focused?

@podsvirov
Copy link
Contributor Author

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.

@kripken
Copy link
Member

kripken commented Apr 2, 2018

Do you mean that the user must click on the window manually first?

@podsvirov
Copy link
Contributor Author

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.

@kripken
Copy link
Member

kripken commented Apr 3, 2018

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.

@podsvirov
Copy link
Contributor Author

Hey guys, can anyone help here or advise a possible implementor?

Cc: @satoshinm, @guillaumeblanc, @cgibson...

@greggman
Copy link
Contributor

greggman commented May 25, 2018

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

@stale
Copy link

stale bot commented Sep 19, 2019

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.

@stale stale bot added the wontfix label Sep 19, 2019
@stale stale bot closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants