test(docks): assert that a dock receives the clicks at any edge
CI / check (pull_request) Successful in 5m44s
CI / check (pull_request) Successful in 5m44s
The mouse handling of the docked windows had no test: the existing dock tests only checked the regions the layout carves, and nothing checked which window the clicks are routed to, so a click lost on a right dock could not be caught by the test suite. The two windows of a tab are now hit tested with their own areas, in both orders, so the same point on a right dock and on a left dock must resolve to the dock. The layout tests also pin the position of a right dock, which previously only had its width and its containment checked. Refs #44
This commit is contained in:
3 files changed
+109
No files matched your search
@@ -834,3 +834,31 @@ class TestMouse(BaseTest):
|
||||
ac([], 4)
|
||||
self.assertTrue(s.callbacks.wtcbuf, 'the wheel event was not reported to the program')
|
||||
parse_bytes(s, b'\x1b[?1000l')
|
||||
|
||||
def test_docked_window_receives_clicks_at_any_edge(self):
|
||||
from kitty.fast_data_types import mock_window_under_mouse
|
||||
|
||||
s = self.create_screen(cols=140, lines=30)
|
||||
w = create_mock_window(s)
|
||||
terminal, right_dock = (0, 0, 1000, 600), (1000, 0, 1400, 600)
|
||||
left_dock, offset_terminal = (0, 0, 400, 600), (400, 0, 1400, 600)
|
||||
|
||||
def under(first, second, x, y):
|
||||
return mock_window_under_mouse(w, *first, *second, x, y)
|
||||
|
||||
# A dock at the right receives the clicks in its own area and the
|
||||
# terminal receives the clicks in the area left over
|
||||
self.ae(under(terminal, right_dock, 500, 300), 1)
|
||||
self.ae(under(terminal, right_dock, 999, 300), 1)
|
||||
self.ae(under(terminal, right_dock, 1000, 300), 2)
|
||||
self.ae(under(terminal, right_dock, 1200, 300), 2)
|
||||
# Swapping the two areas over must give the same answer for a dock at
|
||||
# the left, so the hit test does not depend on the edge
|
||||
self.ae(under(left_dock, offset_terminal, 500, 300), 2)
|
||||
self.ae(under(left_dock, offset_terminal, 100, 300), 1)
|
||||
self.ae(under(left_dock, offset_terminal, 399, 300), 1)
|
||||
# The first window wins when two areas overlap, as with an overlay
|
||||
self.ae(under(terminal, (500, 0, 1400, 600), 700, 300), 1)
|
||||
# A window with an empty area is never hit, even inside the other one
|
||||
self.ae(under(terminal, (0, 0, 0, 0), 1200, 300), 0)
|
||||
self.ae(under((0, 0, 0, 0), right_dock, 1200, 300), 2)
|
||||
Reference in new issue
Block a user