checks(vm-pointer): the two-warp acquire invalidated a premise, not a property

Found by running vm-pointer after fixing the helper derivation, which is
the only reason it could be found: the heredoc bug meant this check had
not run, so nothing noticed that Stage 2 had broken it. Two bugs hiding
each other.

The subtest "the cursor reaches a session that does not hold focus"
needed the lease holder and the focused window to be different sessions,
and used to get that for free -- the second session's window took focus
when it opened, and `acquire` left it there, because one warp moves the
cursor and not keyboard focus. `pointer acquire` now takes the keyboard
too, so after the acquire the focused window IS the holder's and the
precondition assertion fired:

  this subtest needs the OTHER session focused; ['hh-target-epoqmb'] is

The property is still worth proving, so it is still proved: the premise
is now arranged with one `hyprctl dispatch focuswindow` on the other
session. That is SETUP and not the thing under test -- what is measured
is which client the compositor hands the warp to, which is unaffected by
how focus came to be where it is. Asserting "acquire takes focus" here
as well would make the subtest about the acquire rather than about
routing, and vm-keyboard already asserts that against both layouts.

Re-run, and the discriminator is intact:

  nix build --no-link -L .#checks.x86_64-linux.vm-pointer
    test script finished in 181.53s   (12/12, exit 0)

  the compositor's focused window belongs to: ['hh-target-qnly47']
  aimed at target-awyant: it reports [..., (747.0, 267.0)]
  focused is  target-qnly47: it reports []

The warp went to the session it was aimed at and the focused one was
told nothing, which is what this check exists to catch.

One behavioural consequence of the two-warp acquire, visible in that
same log and worth knowing: the focus nudge is delivered to the client
as a real motion. `[(299.0, 521.88), (299.0, 519.0), ...]` is the nudge
and then the target, about 3 px apart, so an application sees a small
cursor jiggle on every acquire.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GhNPM6rGcuzxocM1nATnuM
This commit is contained in:
HermenixandClaude Opus 5 committed 2026-10-05 01:32:58 +00:00
1 parent a6a4094e6a
commit 54dd109dde
1 file changed
+41 -4
+41 -4
View File
@@ -80,6 +80,16 @@
# overrides the one line through the module's `extraConfig`, and the
# subtest "the cursor reaches a session that does not hold focus" is the
# assertion that goes red if the shipped default comes back.
#
# That subtest now has to ARRANGE its own situation rather than inherit it.
# It used to be free -- the second session's window took focus when it
# opened and `acquire` left it there -- but `pointer acquire` now takes the
# keyboard as well as the cursor, so the acquiring session ends up focused.
# The subtest moves focus back with one `hyprctl dispatch`, as setup. Worth
# knowing because the two bugs hid each other: the helper derivation that
# this check's victim comes from was not building at all (see
# checks/lib/session-tools.nix), so nothing ran here to notice the premise
# had gone stale.
# `nix/hyprland-conf.nix` is not this slice's file; the fix belongs there,
# and whether it should be `1` (Hyprland's own default, keyboard focus
# follows the cursor too) or a looser setting that leaves keyboard focus
@@ -437,9 +447,9 @@ testers.runNixOSTest (
raise
with subtest("the cursor reaches a session that does not hold focus"):
# Two assertions in one, because they need the same situation: a
# second session exists and its window took focus when it opened
# (the BUSY subtest above started it).
# Two assertions in one, because they need the same situation: the
# lease is held by one session while a DIFFERENT session's window
# holds keyboard focus.
#
# 1. `acquire` restores the bookmark the previous lease left --
# the point of a bookmark is that a gesture is resumable, and
@@ -450,6 +460,21 @@ testers.runNixOSTest (
# are worth nothing if a click aimed at one session arrives at
# another, and `input:follow_mouse` is where that would go
# wrong (see the block at the top of this file).
#
# HOW THE SITUATION IS SET UP, AND WHY IT CHANGED. It used to be
# free: the second session's window took focus when it opened, and
# `acquire` left it there, because one warp moves the cursor and
# not keyboard focus. `pointer acquire` now takes the keyboard too
# -- two warps a real pixel apart, see `_warp_taking_focus` -- so
# after the acquire below the focused window is the acquiring
# session's, and this subtest's premise no longer arranges itself.
#
# So focus is moved back explicitly. `hyprctl dispatch` is SETUP
# here and not the thing under test: what is measured is which
# client the compositor hands the warp to, and that is unaffected
# by how focus came to be where it is. (The keyboard check is where
# "acquire takes focus" is asserted; asserting it here as well
# would make this subtest about the acquire and not about routing.)
try:
before = len(positions(session_id))
reply = cli_json(f"pointer acquire --json {session_id}", timeout=120)
@@ -458,6 +483,16 @@ testers.runNixOSTest (
f"acquire restored to {reply['bookmark']}, not where the "
"previous lease left the cursor"
)
other_window = [
c for c in compositor("clients")
if c.get("initialClass") == f"hh-{other}"
]
assert other_window, f"the other session {other} has no window"
address = other_window[0]["address"]
machine.succeed(
f"{HYPRCTL} dispatch focuswindow address:{address}", timeout=120
)
focused = [
c.get("initialClass")
for c in compositor("clients")
@@ -465,7 +500,9 @@ testers.runNixOSTest (
]
print(f"the compositor's focused window belongs to: {focused}")
assert focused and focused[0] != output, (
f"this subtest needs the OTHER session focused; {focused} is"
f"this subtest needs the OTHER session focused; {focused} is. "
"The `dispatch focuswindow` above was supposed to arrange "
"that and did not."
)
# Somewhere the cursor is not, so there is a motion to deliver