feat: drag across overlay retargets touch selection

This commit is contained in:
Andrew Hamilton 2026-09-16 21:36:57 +10:00
parent 0d65efdd49
commit d91cc8ba8d
2 changed files with 105 additions and 11 deletions

View file

@ -4897,6 +4897,71 @@ def test_overlay_touch_select(session):
assert session.active() == target
def test_overlay_touch_drag(session):
"""Dragging a finger across the overlay while Alt is held re-targets
the preview as the touch slides into each row's titles; sliding out
of every row sticks to the last preview; a second finger never steals
the drag; lifting commits nothing (Alt release still commits)."""
session.wait_any_active()
session.wait_surface_mapped(0)
session.wait_surface_mapped(1)
session.mods(ALT)
try:
path = session.dump_host()
w, h, _ = session.ppm_rgb(path)
cx = w // 2
# Locate both rows by tapping down the middle.
rows = {}
deadline = time.monotonic() + 25.0
y = 0
while time.monotonic() < deadline and len(rows) < 2 and y < h:
before = len(re.findall(r"\[touch\] select app=", session.read_log()))
session.touch(7, TOUCH_DOWN, cx, y)
time.sleep(0.05)
session.touch(7, TOUCH_UP, cx, y)
time.sleep(0.12)
m = re.findall(r"\[touch\] select app=(\d+)", session.read_log())
if len(m) > before and m[-1] not in rows:
rows[m[-1]] = y
y += 20
assert len(rows) == 2, f"touch sweep found rows {rows}"
yA, yB = sorted(rows.values())
# Drag from the upper row into the lower one step by step.
base = len(re.findall(r"\[touch\] select app=", session.read_log()))
session.touch(7, TOUCH_DOWN, cx, yA)
time.sleep(0.2)
for yy in range(yA, yB + 1, 10):
session.touch(7, TOUCH_MOTION, cx, yy)
time.sleep(0.03)
time.sleep(0.3)
sels = re.findall(r"\[touch\] select app=(\d+)", session.read_log())
assert len(sels) > base and sels[base] != sels[-1], \
f"drag never re-targeted: {sels[base:]}"
drag_target = int(sels[-1])
# Sliding out of every row keeps the last preview.
n0 = len(re.findall(r"\[touch\] select app=", session.read_log()))
session.touch(7, TOUCH_MOTION, 5, 5)
time.sleep(0.3)
n1 = len(re.findall(r"\[touch\] select app=", session.read_log()))
assert n1 == n0, "off-row drag motion changed selection"
# A second finger's down+motion never steals the drag.
session.touch(9, TOUCH_DOWN, cx, yA)
time.sleep(0.1)
session.touch(9, TOUCH_MOTION, cx, yB)
time.sleep(0.2)
n2 = len(re.findall(r"\[touch\] select app=", session.read_log()))
session.touch(9, TOUCH_UP, cx, yB)
time.sleep(0.1)
assert n2 == n1, "second finger stole the overlay drag"
session.touch(7, TOUCH_UP, cx, yB)
time.sleep(0.2)
assert session.active() == drag_target
finally:
session.mods(0)
session.wait_for(r"\[mru\] commit app=%d" % drag_target, timeout=10.0)
assert session.active() == drag_target
def test_synth_feed_drives_host_listeners(tmp_path):
"""Synthesized host pointer/touch events go through the real host
wl_pointer/wl_touch listeners instead of bypassing them for the shared