Skip to content

Commit 3bf3ff1

Browse files
authored
fix: Linux input/a11y defects from #1935 (click miss, typed '=', GTK4 text) (#1949)
* diag: instrument Linux CI to gather evidence for #1935 input/a11y defects Temporary — adds a diagnostic step that dumps raw AT-SPI interfaces/actions for gnome-calculator's digit buttons, tests a raw xdotool click at a button's own rect (bypassing our promotion logic), and isolates the typed '=' character in several configurations. Will be removed once the real fixes land. * diag: harden diagnostic step against bash -e and AT-SPI registration races The prior version crashed 7s in: GH Actions runs steps under bash -e, and an unguarded python3 heredoc threw (iterating a dict instead of a list when the app wasn't found yet), aborting the rest of the script silently under continue-on-error. Guards every fallible command, and replaces the fixed 2s sleep with inspect.py's own poll-until-found loop. * diag: test WINDOW coordtype and static Text.get_text call (round 3) Round 2 proved Component.get_extents(SCREEN) returns (0,0) for every non-toplevel widget (real click miss confirmed on-screen), and Text.get_text() throws — a documented PyGObject binding collision with the deprecated 1-arg Accessible.get_text(). This narrows to the two candidate fixes before writing them: does CoordType.WINDOW give usable relative offsets, and does Atspi.Text.get_text(accessible, ...) (static call) return the real typed text. * fix(linux): resolve click-miss, dropped '=', and GTK4 text exposure defects Three defects surfaced by CI on #1935 (Linux Smoke lane), all confirmed live via instrumented CI runs before being fixed here: 1. Click misses its target: Component.get_extents(Atspi.CoordType.SCREEN) returns (0, 0) as the origin for every non-toplevel widget under this GTK4 build — confirmed by a raw click at the computed rect center landing on the window's own header-bar button instead of the intended digit button. CoordType.WINDOW gives correct, distinct per-widget offsets, so get_rect() now computes screen-absolute rects as that offset plus the enclosing top-level frame's own (correct) screen origin, threaded through traverse_node() alongside the existing window-title tracking. Complementary hardening: role "label" is now excluded from `hittable`, since GTK4 wraps every button's caption in a same-rect "label" child, and the shared cross-platform promotion logic in interaction-targeting.ts would otherwise retarget a click from the button onto that non-interactive label. 2. Typed '=' never arrives: a single isolated synthetic keystroke sent right after a focus change is unreliably delivered — confirmed live, both `xdotool type -- "="` and `xdotool key equal` sent alone produced no character at all, while multi-character bursts always landed in full. typeLinux and sendKey now wait a short settle margin before dispatching to xdotool/ydotool, absorbing the race regardless of which action last changed focus. 3. GTK4 apps expose no editable text: accessible.get_text_iface().get_text() throws "Atspi.Accessible.get_text() takes exactly 1 argument (3 given)" — a documented PyGObject binding collision between Text.get_text and the deprecated 1-argument Accessible.get_text, silently swallowed as "no text" by the broad exception handler. get_text_value() now calls the unbound Atspi.Text.get_text(accessible, ...) form, which correctly returns the real content. The Linux smoke replay is restored to exercise all three fixes together (click a resolved digit button, type a full calculation including the '=' keystroke, wait on the computed result through the tree) instead of staying at the weakened, contract-tier assertions the defects had forced. The coverage manifest promotes click and type from command-contract to live accordingly. * fix(linux): drop unproven keyboard-settle and hittable changes per review Addresses thymikee's review on #1949 (both points correct): P1: the keyboard settle (typeLinux/sendKey) was unjustified. The cited diagnostic evidence for a dropped '=' actually shows the opposite — "100+55=" and "5=5" both computed correctly with zero settle, proving '=' was delivered in every multi-character burst tested. Sending '=' alone to an empty entry showing a blank display is normal calculator semantics (nothing to evaluate), not a lost keystroke. The likelier explanation for the original "100+55" screenshot (run 32487868346) is that its attempt-3 hit the already-fixed mousemove --sync hang, not an independent keyboard-dispatch defect. Reverted; no keyboard-dispatch change was needed. P2: the `role_name != "label"` hittable narrowing was extra surface beyond what the click-miss fix required. The corrected AT-SPI coordinates alone fix the observed miss — the button and its same-rect label child resolve to nearly identical centers, so descendant promotion still lands inside the button either way, and the replay can't distinguish which node it actually targeted. Reverted; only the coordinate fix remains.
1 parent 1f80c92 commit 3bf3ff1

4 files changed

Lines changed: 92 additions & 36 deletions

File tree

linux/atspi-dump.py

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,48 @@
2222
VALID_SURFACES = ("desktop", "frontmost-app")
2323

2424

25-
def get_rect(accessible):
25+
def get_screen_origin(accessible):
26+
"""The screen-absolute (x, y) of a top-level frame/window's own Component extents.
27+
28+
Unlike descendant widgets (see get_rect), a top-level's own SCREEN-coordinate extents are
29+
correct — GTK4's AT-SPI bridge only loses the translation when walking from a widget up
30+
through its ancestor chain to the root, not for the root itself.
31+
"""
2632
try:
2733
component = accessible.get_component_iface()
2834
if not component:
2935
return None
3036
extents = component.get_extents(Atspi.CoordType.SCREEN)
37+
if not extents:
38+
return None
39+
return (extents.x, extents.y)
40+
except Exception:
41+
return None
42+
43+
44+
def get_rect(accessible, frame_origin):
45+
"""A node's screen-absolute rect.
46+
47+
GTK4's AT-SPI bridge returns (0, 0) as the origin of Component.get_extents(SCREEN) for every
48+
non-toplevel widget — confirmed live (CI run 32503838660): a raw xdotool click at the
49+
computed center of a digit button's "screen" rect landed on the window's own header-bar
50+
button instead. CoordType.WINDOW gives correct, distinct per-widget offsets, so the
51+
screen-absolute rect is that offset plus the enclosing top-level frame's own (correct)
52+
screen origin.
53+
"""
54+
try:
55+
component = accessible.get_component_iface()
56+
if not component:
57+
return None
58+
extents = component.get_extents(Atspi.CoordType.WINDOW)
3159
if not extents:
3260
return None
3361
if extents.width <= 0 or extents.height <= 0:
3462
return None
63+
origin_x, origin_y = frame_origin if frame_origin else (0, 0)
3564
return {
36-
"x": extents.x,
37-
"y": extents.y,
65+
"x": extents.x + origin_x,
66+
"y": extents.y + origin_y,
3867
"width": extents.width,
3968
"height": extents.height,
4069
}
@@ -43,14 +72,24 @@ def get_rect(accessible):
4372

4473

4574
def get_text_value(accessible):
75+
"""The Text interface's content, if any.
76+
77+
Must call Atspi.Text.get_text(accessible, ...) as an unbound/static call, NOT
78+
accessible.get_text_iface().get_text(...) — the bound form resolves to the deprecated
79+
1-argument Atspi.Accessible.get_text() instead (a documented PyGObject binding collision:
80+
https://discourse.gnome.org/t/how-can-i-explicitly-call-atspi-text-get-text/36684), raising
81+
"takes exactly 1 argument (3 given)" for every node, silently swallowed as "no text" by the
82+
except-Exception below. Confirmed live (CI run 32505154107): the static form correctly
83+
returns typed text ("155") where the bound form threw on the same node.
84+
"""
4685
try:
4786
text_iface = accessible.get_text_iface()
4887
if not text_iface:
4988
return None
50-
count = text_iface.get_character_count()
89+
count = Atspi.Text.get_character_count(accessible)
5190
if count <= 0:
5291
return None
53-
value = text_iface.get_text(0, count)
92+
value = Atspi.Text.get_text(accessible, 0, count)
5493
return value if value else None
5594
except Exception:
5695
return None
@@ -76,7 +115,7 @@ def has_state(state_set, state_type):
76115
return False
77116

78117

79-
def traverse_node(accessible, depth, parent_index, ctx, app_info, window_title=None):
118+
def traverse_node(accessible, depth, parent_index, ctx, app_info, window_title=None, frame_origin=None):
80119
if len(ctx["nodes"]) >= ctx["max_nodes"] or depth > ctx["max_depth"] or not accessible:
81120
return
82121

@@ -96,7 +135,13 @@ def traverse_node(accessible, depth, parent_index, ctx, app_info, window_title=N
96135
description = ""
97136

98137
label = name or description or None
99-
rect = get_rect(accessible)
138+
139+
# Entering a new top-level resets the frame origin used to translate its descendants'
140+
# WINDOW-relative extents to screen-absolute (see get_rect) — each frame/dialog is a
141+
# separate X11 top-level with its own screen position.
142+
is_frame = role_name in ("frame", "window", "dialog")
143+
effective_frame_origin = (get_screen_origin(accessible) or frame_origin) if is_frame else frame_origin
144+
rect = get_rect(accessible, effective_frame_origin)
100145

101146
try:
102147
state_set = accessible.get_state_set()
@@ -110,7 +155,7 @@ def traverse_node(accessible, depth, parent_index, ctx, app_info, window_title=N
110155
hittable = (enabled is not False) and visible and showing and (rect is not None)
111156

112157
current_window_title = window_title
113-
if current_window_title is None and role_name in ("frame", "window", "dialog"):
158+
if current_window_title is None and is_frame:
114159
current_window_title = label
115160

116161
nodes = ctx["nodes"]
@@ -147,7 +192,7 @@ def traverse_node(accessible, depth, parent_index, ctx, app_info, window_title=N
147192
if child:
148193
traverse_node(
149194
child, depth + 1, node_index, ctx, app_info,
150-
current_window_title
195+
current_window_title, effective_frame_origin
151196
)
152197
except Exception:
153198
pass

test/integration/linux-e2e/coverage-manifest.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ export const LINUX_PLATFORM_COVERAGE = {
160160
[C.record]: gap('No Linux-specific recording command evidence exists yet'),
161161
[C.trace]: gap('No Linux-specific trace command evidence exists yet'),
162162
[C.find]: gap('No Linux-specific find command evidence exists yet'),
163-
[C.click]: contract(
164-
LINUX_PROVIDER_EVIDENCE.path,
165-
LINUX_PROVIDER_EVIDENCE.test,
166-
'Linux provider scenario executes primary, secondary, middle, and double clicks',
167-
),
163+
// Promoted from command-contract to live: the desktop replay now clicks a resolved digit
164+
// button on real Linux hardware and the downstream wait only passes if the click landed
165+
// (formerly missed — AT-SPI extents were computed screen-absolute-wrong under GTK4; see
166+
// linux/atspi-dump.py).
167+
[C.click]: live('the Linux desktop replay clicks a resolved calculator digit button'),
168168
[C.fill]: contract(
169169
LINUX_PROVIDER_EVIDENCE.path,
170170
LINUX_PROVIDER_EVIDENCE.test,
@@ -181,15 +181,11 @@ export const LINUX_PLATFORM_COVERAGE = {
181181
LINUX_PROVIDER_EVIDENCE.test,
182182
'Linux provider scenario presses a snapshot ref and coordinate target',
183183
),
184-
// The desktop replay runs the migrated typeText path on real hardware and uploads pixel
185-
// evidence of the typed entry each run, but GTK4 gnome-calculator exposes no Text-interface
186-
// content to selectors, so no tree-level assertion can hold and the claim stays at the
187-
// contract tier until that platform defect is fixed.
188-
[C.type]: contract(
189-
'src/platforms/linux/__tests__/input-actions.test.ts',
190-
'typeLinux uses ydotool type',
191-
'Linux type dispatch uses the Wayland ydotool type primitive',
192-
),
184+
// Promoted from command-contract to live: GTK4 gnome-calculator's entry previously exposed no
185+
// Text-interface content to selectors (a PyGObject binding call-pattern bug — see
186+
// linux/atspi-dump.py), so no tree-level assertion could hold. Fixed, so the desktop replay's
187+
// typed calculation now has a real wait assertion on the computed result.
188+
[C.type]: live('the Linux desktop replay types a calculation and its result is selectable'),
193189
[C.get]: contract(
194190
LINUX_PROVIDER_EVIDENCE.path,
195191
LINUX_PROVIDER_EVIDENCE.test,

test/integration/replays/linux/01-desktop-smoke.ad

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,27 @@ snapshot -i
1616
focus 100 100
1717
# The session survives the focus: a crashed desktop would fail here, not silently pass above.
1818
is exists "appname=gnome-calculator || windowtitle=Calculator || label=Calculator || label=0 || label=1 || label=5"
19+
# A resolved button press: proves pointer input lands on a resolved target. role= disambiguates
20+
# from the calculator's [text] "1" node — a bare label=1 is an AMBIGUOUS_MATCH rejection by
21+
# design. Formerly missed: AT-SPI's Component.get_extents(SCREEN) returns (0,0) for every
22+
# non-toplevel widget under this GTK4 build, so the click landed on the window's own header-bar
23+
# button instead — fixed by computing screen-absolute rects from CoordType.WINDOW plus the
24+
# toplevel frame's own screen origin (linux/atspi-dump.py).
25+
click "role=button label=1"
1926
# R41 (#1739): `type` executes through the bound `typeText` operation rather than the retired
20-
# interactor leaf. The typed-state screenshot below is the live evidence: run 32490373693's
21-
# artifact shows the typed digits in the calculator entry. A selector assertion on the value is
22-
# impossible today — GTK4 gnome-calculator exposes no Text-interface content through the AT-SPI
23-
# dumper (display showed "155" while a wait for value=155 timed out) — so the tree-level claim
24-
# for `type` stays at the command-contract tier until the exposure defect is fixed.
25-
type "155"
27+
# interactor leaf. The keystrokes spell a full calculation: the clicked 1 plus the typed 00+55=
28+
# can only produce a 155 result if every keystroke — digits, the shift-composed '+', and the
29+
# trailing '=' — actually landed; no calculator button is labelled 155. (Run 32487868346's
30+
# "100+55" without '=' motivated a keystroke-loss investigation, but the diagnostic evidence for
31+
# that (CI run 32503838660) turned out to show '=' delivered correctly in every multi-character
32+
# burst tested; the run's own attempt-3 hit the already-fixed mousemove --sync hang, which is the
33+
# more likely explanation for that screenshot. No keyboard-dispatch change was needed here.)
34+
type "00+55="
2635
screenshot "./test/screenshots/replays/linux-calculator-typed.png"
27-
# The session survives the typing; a wedged desktop fails here instead of silently passing.
28-
is exists "appname=gnome-calculator || windowtitle=Calculator || label=Calculator || label=0 || label=1 || label=5"
36+
# GTK4 gnome-calculator's entry widget did not expose its content to selectors: AT-SPI's
37+
# Text.get_text() called as accessible.get_text_iface().get_text(...) throws — a PyGObject
38+
# binding collision with the deprecated 1-arg Accessible.get_text() — silently swallowed as "no
39+
# text". Fixed by calling the unbound Atspi.Text.get_text(accessible, ...) form instead. 155
40+
# appears only as the computed result: no button carries that label, and deleting any keystroke
41+
# above turns this wait red.
42+
wait "value=155 || label=155 || text=155" 10000

test/integration/smoke-linux-coverage.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ test('Linux coverage exhaustively classifies the public catalog', () => {
4040
test('Linux coverage report has the expected classification counts', () => {
4141
assert.deepEqual(LINUX_PLATFORM_COVERAGE_CLASSIFICATION_SUMMARY, {
4242
capabilityDenial: 11,
43-
// focus (#1925) is live via the replay; type runs there too but GTK4 blocks a tree-level
44-
// assertion, so its claim stays contract-tier (see the manifest entry).
45-
contract: 19,
43+
// focus (#1925), click, and type are live via the replay: click resolves and lands on a
44+
// digit button, and the typed calculation's result is now selectable (see the manifest
45+
// entries for the platform defects this fixed).
46+
contract: 17,
4647
gap: 18,
47-
live: 6,
48+
live: 8,
4849
total: 54,
4950
});
5051

@@ -61,7 +62,7 @@ test('Linux live claims reference commands in the existing smoke replay', () =>
6162
parseReplayScriptDetailed(replaySource).actions.map((action) => action.command),
6263
);
6364
const liveCommands = liveCommandsForLinuxReplay();
64-
assert.deepEqual(liveCommands.length, 6);
65+
assert.deepEqual(liveCommands.length, 8);
6566
for (const command of liveCommands) {
6667
assert.equal(
6768
replayCommands.has(command),

0 commit comments

Comments
 (0)