diff --git a/checks/vm-pointer.nix b/checks/vm-pointer.nix index 3acaf27..10712d6 100644 --- a/checks/vm-pointer.nix +++ b/checks/vm-pointer.nix @@ -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