From ef1573516110a11a915c488813484cf94928e643 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 10 Oct 2016 01:24:16 +0200 Subject: [PATCH] Make Escape exit threads test --- tests/threads.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/threads.c b/tests/threads.c index 699a0ad1..d5e34838 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -52,6 +52,12 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } +static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +{ + if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) + glfwSetWindowShouldClose(window, GLFW_TRUE); +} + static int thread_main(void* data) { const Thread* thread = data; @@ -101,6 +107,8 @@ int main(void) exit(EXIT_FAILURE); } + glfwSetKeyCallback(threads[i].window, key_callback); + glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); glfwShowWindow(threads[i].window); }