diff kitten: Fix images losing position when scrolling using mouse wheel/touchpad

This commit is contained in:
Kovid Goyal
2020-03-19 18:46:10 +05:30
parent e2339697b9
commit eddd45bbc3
3 changed files with 57 additions and 4 deletions

View File

@@ -10,7 +10,8 @@ from collections import defaultdict, deque
from contextlib import suppress
from itertools import count
from typing import (
Any, DefaultDict, Deque, Dict, List, Optional, Sequence, Tuple, Union
Any, Callable, DefaultDict, Deque, Dict, List, Optional, Sequence, Tuple,
Union
)
from kitty.typing import (
@@ -191,6 +192,7 @@ class ImageManager:
self.image_id_to_converted_data: Dict[int, ImageKey] = {}
self.transmission_status: Dict[int, Union[str, int]] = {}
self.placements_in_flight: DefaultDict[int, Deque[Placement]] = defaultdict(deque)
self.update_image_placement_for_resend: Optional[Callable[[int, Placement], bool]]
@property
def next_image_id(self) -> int:
@@ -254,6 +256,8 @@ class ImageManager:
self.placements_in_flight.pop(image_id, None)
def resend_image(self, image_id: int, pl: Placement) -> None:
if self.update_image_placement_for_resend is not None and not self.update_image_placement_for_resend(image_id, pl):
return
image_data = self.image_id_to_image_data[image_id]
skey = self.image_id_to_converted_data[image_id]
self.transmit_image(image_data, image_id, *skey)