mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-11 02:59:40 +02:00
Fix a couple of recursive timer adds
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from functools import partial
|
||||
from gettext import gettext as _
|
||||
from time import monotonic
|
||||
from weakref import WeakValueDictionary
|
||||
@@ -144,15 +143,12 @@ class Boss:
|
||||
self.window_id_map[window.id] = window
|
||||
wakeup()
|
||||
|
||||
def retry_resize_pty(self, window_id, timers_call=False):
|
||||
def retry_resize_pty(self, window_id):
|
||||
# In case the child has not yet been added in the child monitor
|
||||
if timers_call:
|
||||
w = self.window_id_map.get(window_id)
|
||||
if w is not None:
|
||||
if not self.child_monitor.resize_pty(window_id, *w.current_pty_size):
|
||||
self.retry_resize_pty(window_id)
|
||||
else:
|
||||
self.ui_timers.add(0, partial(self.retry_resize_pty, window_id, timers_call=True))
|
||||
w = self.window_id_map.get(window_id)
|
||||
if w is not None:
|
||||
if not self.child_monitor.resize_pty(window_id, *w.current_pty_size):
|
||||
return 0.0 # re-add this timer
|
||||
|
||||
def on_child_death(self, window_id):
|
||||
w = self.window_id_map.pop(window_id, None)
|
||||
|
||||
@@ -88,7 +88,7 @@ class Window:
|
||||
self.char_grid.resize(new_geometry)
|
||||
self.needs_layout = False
|
||||
if not child_monitor.resize_pty(self.id, *self.current_pty_size):
|
||||
boss.retry_resize_pty(self.id)
|
||||
boss.ui_timers.add(0, boss.retry_resize_pty, self.id)
|
||||
else:
|
||||
self.char_grid.update_position(new_geometry)
|
||||
self.geometry = new_geometry
|
||||
@@ -251,12 +251,11 @@ class Window:
|
||||
|
||||
def drag_scroll(self):
|
||||
x, y = self.last_mouse_cursor_pos
|
||||
tm = get_boss()
|
||||
margin = cell_size.height // 2
|
||||
if y <= margin or y >= self.geometry.bottom - margin:
|
||||
self.scroll_line_up() if y < 50 else self.scroll_line_down()
|
||||
self.char_grid.update_drag(None, x, y)
|
||||
tm.ui_timers.add(0.02, self.drag_scroll)
|
||||
return 0.02 # causes the timer to be re-added
|
||||
|
||||
def on_mouse_scroll(self, x, y):
|
||||
s = int(round(y * self.opts.wheel_scroll_multiplier))
|
||||
|
||||
Reference in New Issue
Block a user