/** * This function sets the monitor configuration callback, or removes the currently set callback. This is called when * a monitor is connected to or disconnected from the system. * * @param callback The new callback, or {@code null} to remove the currently set callback. * * @return The previously set callback, or {@code null} if no callback was set or the library had not been * initialized. */ public static IMonitorCallback setCallback(IMonitorCallback callback) { IMonitorCallback previousCallback = monitorCallback; if (callback == null) callback = (monitor, event) -> { }; monitorCallback = callback; if (glfwMonitorCallback != null) glfwMonitorCallback.free(); glfwMonitorCallback = GLFWMonitorCallback.create((monitor, event) -> monitorCallback.invoke(registeredMonitors.get(monitor), event) ); glfwSetMonitorCallback(glfwMonitorCallback); return previousCallback; }