Always on top ONLY IF original window is currently focused
I am developing an IDE for a project of mine, and I chose to use GLFW. I want the user to be able to dock and undock windows into tabs. When a window is docked into a tab, the window is destroyed, but all of its contents are moved back into the original (root) window. When the tab is dragged, a new window is created, and its contents are moved into the window. Simple enough.
The naive approach to make a undocked window, would be to set the GLFW_FLOATING flag to true, however, this will make the undocked windows go ontop of other applications the user may be using if the root window is minimized/unfocused.
For example, if I undock some tabs into windows, and these windows are ontop of the root window, then everything looks normal. If I then opened photoshop on the same monitor, and it covered the root window, the floating undocked windows will still be ontop of photoshop, which is not intended.
Is there any solution within GLFW to my problem?
If you're using GLFW 3.2 or earlier, you can now at least update GLFW_FLOATING with glfwSetWindowAttrib in what will become 3.3. This is up and running in master.
That still won't give users a smooth experience, though. This overlaps with features requested for Dear ImGui docking and is something that may get better support in the future.
@orange451 does using glfwSetWindowAttrib to update the GLFW_FLOATING attribute when your application changes focus work as a solution for you?