mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-11 02:59:40 +02:00
Enable timers for the UI thread as well
This commit is contained in:
@@ -61,6 +61,20 @@ def clear_buffers(window, opts):
|
||||
glfw_swap_interval(1)
|
||||
|
||||
|
||||
def dispatch_pending_calls(tabs):
|
||||
while True:
|
||||
try:
|
||||
func, args = tabs.pending_ui_thread_calls.get_nowait()
|
||||
except Empty:
|
||||
break
|
||||
try:
|
||||
func(*args)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
tabs.ui_timers()
|
||||
|
||||
|
||||
def run_app(opts, args):
|
||||
setup_opengl()
|
||||
window = Window(
|
||||
@@ -75,17 +89,8 @@ def run_app(opts, args):
|
||||
while not window.should_close():
|
||||
tabs.render()
|
||||
window.swap_buffers()
|
||||
glfw_wait_events()
|
||||
while True:
|
||||
try:
|
||||
func, args = tabs.pending_ui_thread_calls.get_nowait()
|
||||
except Empty:
|
||||
break
|
||||
try:
|
||||
func(*args)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
glfw_wait_events(tabs.ui_timers.timeout())
|
||||
dispatch_pending_calls(tabs)
|
||||
finally:
|
||||
tabs.destroy()
|
||||
del window
|
||||
|
||||
@@ -113,6 +113,7 @@ class TabManager(Thread):
|
||||
self.read_dispatch_map = {self.signal_fd: self.signal_received, self.read_wakeup_fd: self.on_wakeup}
|
||||
self.all_writers = []
|
||||
self.timers = Timers()
|
||||
self.ui_timers = Timers()
|
||||
self.pending_ui_thread_calls = Queue()
|
||||
self.write_dispatch_map = {}
|
||||
set_tab_manager(self)
|
||||
|
||||
Reference in New Issue
Block a user