mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Fix timers not being replaced
This commit is contained in:
@@ -24,7 +24,7 @@ from .constants import (
|
|||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GLFW_CURSOR, GLFW_CURSOR_HIDDEN,
|
GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GLFW_CURSOR, GLFW_CURSOR_HIDDEN,
|
||||||
GLFW_CURSOR_NORMAL, GLFW_MOUSE_BUTTON_1, GLFW_PRESS, GLFW_REPEAT,
|
GLFW_CURSOR_NORMAL, GLFW_MOUSE_BUTTON_1, GLFW_PRESS, GLFW_REPEAT,
|
||||||
drain_read, glBlendFunc, glfw_post_empty_event, glViewport, Timers
|
drain_read, glBlendFunc, glfw_post_empty_event, glViewport, Timers as _Timers
|
||||||
)
|
)
|
||||||
from .fonts.render import set_font_family
|
from .fonts.render import set_font_family
|
||||||
from .keys import (
|
from .keys import (
|
||||||
@@ -39,6 +39,23 @@ if isosx:
|
|||||||
from .fast_data_types import cocoa_update_title
|
from .fast_data_types import cocoa_update_title
|
||||||
|
|
||||||
|
|
||||||
|
class Timers(_Timers):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
_Timers.__init__(self)
|
||||||
|
self.timer_hash = {}
|
||||||
|
|
||||||
|
def add(self, delay, timer, *args):
|
||||||
|
# Needed because bound methods are recreated on every access
|
||||||
|
timer = self.timer_hash.setdefault(timer, timer)
|
||||||
|
return _Timers.add(self, delay, timer) if args else _Timers.add(self, delay, timer, args)
|
||||||
|
|
||||||
|
def remove(self, timer):
|
||||||
|
# Needed because bound methods are recreated on every access
|
||||||
|
timer = self.timer_hash.setdefault(timer, timer)
|
||||||
|
return _Timers.remove_event(self, timer)
|
||||||
|
|
||||||
|
|
||||||
def conditional_run(w, i):
|
def conditional_run(w, i):
|
||||||
if w is None or not w.destroyed:
|
if w is None or not w.destroyed:
|
||||||
next(i, None)
|
next(i, None)
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ PyTypeObject Timers_Type = {
|
|||||||
.tp_name = "fast_data_types.Timers",
|
.tp_name = "fast_data_types.Timers",
|
||||||
.tp_basicsize = sizeof(Timers),
|
.tp_basicsize = sizeof(Timers),
|
||||||
.tp_dealloc = (destructor)dealloc,
|
.tp_dealloc = (destructor)dealloc,
|
||||||
.tp_flags = Py_TPFLAGS_DEFAULT,
|
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
||||||
.tp_doc = "Timers",
|
.tp_doc = "Timers",
|
||||||
.tp_methods = methods,
|
.tp_methods = methods,
|
||||||
.tp_new = new,
|
.tp_new = new,
|
||||||
|
|||||||
Reference in New Issue
Block a user