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
@@ -126,6 +126,16 @@ class TestDocks(BaseTest):
|
||||
content, placements = carve_docks(Region((0, 0, -1, -1, 0, 0)), groups, CELL_WIDTH, CELL_HEIGHT)
|
||||
self.ae([r.height for g, r in placements], [0, 0])
|
||||
|
||||
# A dock at the right is placed against the right edge of what remains,
|
||||
# the same way a dock at the left is placed against the left edge
|
||||
groups = []
|
||||
left, right = dock('left', '10%'), dock('right', '5%')
|
||||
content, placements = carve_docks(VIEWPORT, groups, CELL_WIDTH, CELL_HEIGHT)
|
||||
regions = {g.id: rect(r) for g, r in placements}
|
||||
self.ae(regions[left.id], (0, 0, 100, 600))
|
||||
self.ae(regions[right.id], (950, 0, 1000, 600))
|
||||
self.ae(rect(content), (100, 0, 950, 600))
|
||||
|
||||
def test_tab_docks(self):
|
||||
q = make_layout(Tall)
|
||||
windows = make_windows(q, 2)
|
||||
@@ -183,6 +193,9 @@ class TestDocks(BaseTest):
|
||||
self.assertTrue(rect(r)[0] >= allocated.left and rect(r)[2] <= allocated.left + allocated.width)
|
||||
self.ae(rect(dock_regions[0])[1], allocated.top + allocated.height - 2 * CELL_HEIGHT - 2 * DECORATION)
|
||||
self.ae(dock_regions[1].width, allocated.width // 4)
|
||||
# The dock at the right sits past the content, at the right of the area
|
||||
self.assertGreaterEqual(rect(dock_regions[1])[0], rect(content)[2])
|
||||
self.assertLessEqual(rect(dock_regions[1])[2], allocated.left + allocated.width)
|
||||
self.check_no_overlaps(windows)
|
||||
# The decorations chosen by the layout for the owner are preserved
|
||||
self.ae(main.geometry.spaces.left - main.geometry.compensatory.left, DECORATION)
|
||||
|
||||
@@ -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