From 0f93d243066aff0ed3ad97326ba1f1bfff3f65ac Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 8 Nov 2012 18:20:31 +0100 Subject: [PATCH] Added more details on connected monitors. --- tests/events.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/tests/events.c b/tests/events.c index 9febb2d0..f10a2738 100644 --- a/tests/events.c +++ b/tests/events.c @@ -220,19 +220,6 @@ static const char* get_character_string(int character) return result; } -static const char* get_monitor_event_name(int event) -{ - switch (event) - { - case GLFW_MONITOR_CONNECTED: - return "connected"; - case GLFW_MONITOR_DISCONNECTED: - return "disconnected"; - } - - return NULL; -} - static void window_size_callback(GLFWwindow window, int width, int height) { printf("%08x at %0.3f: Window size: %i %i\n", @@ -363,12 +350,28 @@ static void char_callback(GLFWwindow window, int character) void monitor_callback(GLFWmonitor monitor, int event) { - printf("%08x at %0.3f: Monitor %s %s\n", - counter++, - glfwGetTime(), - glfwGetMonitorName(monitor), - get_monitor_event_name(event)); + if (event == GLFW_MONITOR_CONNECTED) + { + GLFWvidmode mode; + glfwGetVideoMode(monitor, &mode); + printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n", + counter++, + glfwGetTime(), + glfwGetMonitorName(monitor), + mode.width, mode.height, + glfwGetMonitorParam(monitor, GLFW_MONITOR_POS_X), + glfwGetMonitorParam(monitor, GLFW_MONITOR_POS_Y), + glfwGetMonitorParam(monitor, GLFW_MONITOR_PHYSICAL_WIDTH), + glfwGetMonitorParam(monitor, GLFW_MONITOR_PHYSICAL_HEIGHT)); + } + else + { + printf("%08x at %0.3f: Monitor %s was disconnected\n", + counter++, + glfwGetTime(), + glfwGetMonitorName(monitor)); + } } int main(void)