From 2e0cbb88bb114369b956f34d94a642409678d324 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 12 Sep 2017 16:32:25 +0530 Subject: [PATCH] Call draw_borders() directly from C --- kitty/boss.py | 3 +-- kitty/child-monitor.c | 2 ++ kitty/data-types.h | 2 ++ kitty/shaders.c | 5 ++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index eb2918b72..2d379cac0 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -15,7 +15,7 @@ from .constants import ( from .fast_data_types import ( GLFW_CURSOR, GLFW_CURSOR_HIDDEN, GLFW_CURSOR_NORMAL, GLFW_MOUSE_BUTTON_1, GLFW_PRESS, GLFW_REPEAT, ChildMonitor, Timers as _Timers, - destroy_sprite_map, draw_borders, glfw_post_empty_event, layout_sprite_map, + destroy_sprite_map, glfw_post_empty_event, layout_sprite_map, resize_gl_viewport ) from .fonts.render import render_cell_wrapper, set_font_family @@ -365,7 +365,6 @@ class Boss: self.glfw_window.set_title(self.glfw_window_title) if isosx: cocoa_update_title(self.glfw_window_title) - draw_borders() self.tab_manager.render() for window in tab.visible_windows(): if not window.needs_layout: diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index b52886035..1713fc370 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -423,6 +423,7 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) { #undef DECREF_CHILD static double last_render_at = -DBL_MAX; +draw_borders_func draw_borders = NULL; static inline bool render(ChildMonitor *self, double *timeout) { @@ -430,6 +431,7 @@ render(ChildMonitor *self, double *timeout) { double now = monotonic(); double time_since_last_render = now - last_render_at; if (time_since_last_render > self->repaint_delay) { + draw_borders(); ret = PyObject_CallFunctionObjArgs(self->render_func, NULL); if (ret == NULL) { PyErr_Print(); return false; } else Py_DECREF(ret); diff --git a/kitty/data-types.h b/kitty/data-types.h index 696bed39f..b05ad9c92 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -311,6 +311,8 @@ extern GlobalState global_state; clear_sprite_position((line)->cells[(at)]); \ } +typedef void (*draw_borders_func)(); +extern draw_borders_func draw_borders; // Global functions Line* alloc_line(); diff --git a/kitty/shaders.c b/kitty/shaders.c index 37fefda11..2da39ec27 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -714,7 +714,7 @@ init_borders_program() { } static void -draw_borders() { +draw_borders_impl() { if (num_border_rects) { bind_program(BORDERS_PROGRAM); bind_vertex_array(border_vertex_array); @@ -831,7 +831,6 @@ PYWRAP1(draw_cursor) { } NO_ARG(init_borders_program) -NO_ARG(draw_borders) PYWRAP1(add_borders_rect) { unsigned int a, b, c, d, e; PA("IIIII", &a, &b, &c, &d, &e); add_borders_rect(a, b, c, d, e); Py_RETURN_NONE; } TWO_INT(send_borders_rects) @@ -914,7 +913,6 @@ static PyMethodDef module_methods[] = { MW(init_cursor_program, METH_NOARGS), MW(draw_cursor, METH_VARARGS), MW(init_borders_program, METH_NOARGS), - MW(draw_borders, METH_NOARGS), MW(add_borders_rect, METH_VARARGS), MW(send_borders_rects, METH_VARARGS), MW(init_cell_program, METH_NOARGS), @@ -966,6 +964,7 @@ init_shaders(PyObject *module) { #undef C PyModule_AddObject(module, "GL_VERSION_REQUIRED", Py_BuildValue("II", REQUIRED_VERSION_MAJOR, REQUIRED_VERSION_MINOR)); if (PyModule_AddFunctions(module, module_methods) != 0) return false; + draw_borders = &draw_borders_impl; return true; } // }}}