Quick answer: GLFW window jumping off-screen after unplugging the external monitor it was on? Listen for the monitor disconnect callback and clamp the window position to the primary monitor’s work area.
Devs report the game window vanishes after they undock. It’s positioned at coordinates that map to the now-disconnected display.
Monitor Disconnect Callback
glfwSetMonitorCallback([](GLFWmonitor* m, int ev) {
if (ev == GLFW_DISCONNECTED) RepositionIfOffscreen();
});
Check Window Visibility
Iterate connected monitors. If the window’s rect doesn’t overlap any work area, move it to glfwGetPrimaryMonitor()’s top-left + a margin.
Persist Sensible Defaults
Save window position on close, but on load, validate it overlaps a current monitor before applying. Stops the “ghost monitor” case.
Verifying
Unplug a second monitor while the game is on it — the window moves to the primary monitor and stays visible.
“Track monitor connect/disconnect and validate window rect every time.”
On Windows specifically, WM_DISPLAYCHANGE fires for the same reason — GLFW abstracts it cleanly cross-platform.