From 12a24d5c86ca8c9d1e9d169edbbbc8d3abdd5842 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 24 Feb 2020 07:10:05 +0530 Subject: [PATCH] Remove unused code --- kitty/glfw.c | 14 ------ kitty/glfw_tests.c | 110 --------------------------------------------- kitty/glfw_tests.h | 11 ----- 3 files changed, 135 deletions(-) delete mode 100644 kitty/glfw_tests.c delete mode 100644 kitty/glfw_tests.h diff --git a/kitty/glfw.c b/kitty/glfw.c index 79ac0460b..83d36144d 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -5,7 +5,6 @@ */ #include "state.h" -#include "glfw_tests.h" #include "fonts.h" #include "monotonic.h" #include @@ -1179,18 +1178,6 @@ stop_main_loop(void) { } -static PyObject* -test_empty_event(PYNOARG) { - // To run this, use - // kitty +runpy "from kitty.main import init_glfw_module; init_glfw_module('x11'); from kitty.fast_data_types import glfw_test_empty_event; glfw_test_empty_event()" - int ret = empty_main(); - if (ret != EXIT_SUCCESS) { - PyErr_Format(PyExc_RuntimeError, "Empty test returned failure code: %d", ret); - return NULL; - } - Py_RETURN_NONE; -} - // Boilerplate {{{ static PyMethodDef module_methods[] = { @@ -1219,7 +1206,6 @@ static PyMethodDef module_methods[] = { {"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""}, {"glfw_primary_monitor_size", (PyCFunction)primary_monitor_size, METH_NOARGS, ""}, {"glfw_primary_monitor_content_scale", (PyCFunction)primary_monitor_content_scale, METH_NOARGS, ""}, - {"glfw_test_empty_event", (PyCFunction)test_empty_event, METH_NOARGS, ""}, {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/kitty/glfw_tests.c b/kitty/glfw_tests.c deleted file mode 100644 index 2823f0461..000000000 --- a/kitty/glfw_tests.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * glfw_tests.c - * Copyright (C) 2019 Kovid Goyal - * - * Distributed under terms of the GPL3 license. - */ - -#include "glfw_tests.h" - - -#include "glfw-wrapper.h" -#include "gl.h" - -#include -#include -#include -#include - -static volatile bool running = true; - -static void* empty_thread_main(void* data UNUSED) -{ - struct timespec time = { .tv_sec = 1 }; - - while (running) - { - nanosleep(&time, NULL); - wakeup_main_loop(); - } - - return 0; -} - -static void key_callback(GLFWwindow *w UNUSED, GLFWkeyevent *ev) -{ - if (ev->key == GLFW_KEY_ESCAPE && ev->action == GLFW_PRESS) { - glfwSetWindowShouldClose(w, true); - wakeup_main_loop(); - } -} - -static void -window_close_callback(GLFWwindow* window) { - glfwSetWindowShouldClose(window, true); - wakeup_main_loop(); -} - - -static float nrand(void) -{ - return (float) rand() / (float) RAND_MAX; -} - -static void -empty_main_tick(void *data) { - GLFWwindow *window = data; - if (glfwWindowShouldClose(window)) { - running = false; - glfwStopMainLoop(); - return; - } - int width, height; - float r = nrand(), g = nrand(), b = nrand(); - float l = (float) sqrt(r * r + g * g + b * b); - - glfwGetFramebufferSize(window, &width, &height); - - glViewport(0, 0, width, height); - glClearColor(r / l, g / l, b / l, 1.f); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); -} - -int empty_main(void) -{ - pthread_t thread; - GLFWwindow* window; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_REQUIRED_VERSION_MAJOR); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_REQUIRED_VERSION_MINOR); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true); - - - srand((unsigned int) time(NULL)); - - window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL); - if (!window) - { - return (EXIT_FAILURE); - } - - glfwMakeContextCurrent(window); - gl_init(); - glfwSetKeyboardCallback(window, key_callback); - glfwSetWindowCloseCallback(window, window_close_callback); - - if (pthread_create(&thread, NULL, empty_thread_main, NULL) != 0) - { - fprintf(stderr, "Failed to create secondary thread\n"); - return (EXIT_FAILURE); - } - - glfwRunMainLoop(empty_main_tick, window); - - glfwHideWindow(window); - pthread_join(thread, NULL); - glfwDestroyWindow(window); - - return (EXIT_SUCCESS); -} diff --git a/kitty/glfw_tests.h b/kitty/glfw_tests.h deleted file mode 100644 index 4f44e0869..000000000 --- a/kitty/glfw_tests.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (C) 2019 Kovid Goyal - * - * Distributed under terms of the GPL3 license. - */ - -#pragma once - -#include "state.h" - -int empty_main(void);