Remove unused code

This commit is contained in:
Kovid Goyal 2020-02-24 07:10:05 +05:30
parent dec1a0886d
commit 12a24d5c86
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 0 additions and 135 deletions

View File

@ -5,7 +5,6 @@
*/
#include "state.h"
#include "glfw_tests.h"
#include "fonts.h"
#include "monotonic.h"
#include <structmember.h>
@ -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 */
};

View File

@ -1,110 +0,0 @@
/*
* glfw_tests.c
* Copyright (C) 2019 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#include "glfw_tests.h"
#include "glfw-wrapper.h"
#include "gl.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
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);
}

View File

@ -1,11 +0,0 @@
/*
* Copyright (C) 2019 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#pragma once
#include "state.h"
int empty_main(void);