Wayland: Fix duplicate monitor connection events

GLFW would report a monitor as connected each time its wl_output
received an update, for example if its scale changed.

This would also cause the monitor to be added to the monitor array
again, causing glfwTerminate to segfault when it attempted to destroy
its already destroyed wl_output.
This commit is contained in:
Camilla Löwy
2022-06-14 18:44:24 +02:00
parent 209f6cf093
commit c3ad3d49ed
2 changed files with 10 additions and 0 deletions

View File

@@ -97,6 +97,12 @@ static void outputHandleDone(void* userData, struct wl_output* output)
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
}
for (int i = 0; i < _glfw.monitorCount; i++)
{
if (_glfw.monitors[i] == monitor)
return;
}
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
}