From addb977ef1942f3cfdc9182fa5342fb6c112d8e9 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 13 Dec 2015 19:11:21 +0100 Subject: [PATCH] Use monitor callback event more strictly --- docs/monitor.dox | 12 +++++++++--- tests/events.c | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/monitor.dox b/docs/monitor.dox index 51b9a9f5..3b3c843c 100644 --- a/docs/monitor.dox +++ b/docs/monitor.dox @@ -67,16 +67,22 @@ glfwSetMonitorCallback(monitor_callback); @endcode The callback function receives the handle for the monitor that has been -connected or disconnected and a monitor action. +connected or disconnected and the event that occurred. @code void monitor_callback(GLFWmonitor* monitor, int event) { + if (event == GLFW_CONNECTED) + { + // The monitor was connected + } + else if (event == GLFW_DISCONNECTED) + { + // The monitor was disconnected + } } @endcode -The action is one of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. - @section monitor_properties Monitor properties diff --git a/tests/events.c b/tests/events.c index 8419918d..3d4a8106 100644 --- a/tests/events.c +++ b/tests/events.c @@ -442,7 +442,7 @@ static void monitor_callback(GLFWmonitor* monitor, int event) x, y, widthMM, heightMM); } - else + else if (event == GLFW_DISCONNECTED) { printf("%08x at %0.3f: Monitor %s was disconnected\n", counter++,