Say Blank and window titles while exploring by touch
Silence over empty space sounded like a broken screen reader to testers, so exploring empty space, an unnamed container with no text, or no window at all now says "Blank" once, until the finger reaches something again. A finger that slides off one application into another, or onto the desktop, had no way to know it had left. Crossing into another window now says that window's title first, once per crossing. The title comes from the nearest titled ancestor, because the window under a point can be an untitled inner window; the native window locator test checks this with xterm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e68d2fa440
commit
e4ba4d9882
7 files changed
+182
-16
No files matched your search
@@ -52,7 +52,10 @@ own rotor position.
|
|||||||
Shared by every mode:
|
Shared by every mode:
|
||||||
|
|
||||||
- One finger rest or drag: speak what is under the finger (line of text over
|
- One finger rest or drag: speak what is under the finger (line of text over
|
||||||
unnamed containers). Lifting moves object review there.
|
unnamed containers). Lifting moves object review there. Empty space says
|
||||||
|
"Blank" once until the finger reaches something; testers found silence
|
||||||
|
sounded broken. Crossing into another window, or off every window, says
|
||||||
|
that window's title (or "Desktop") first, once per crossing.
|
||||||
- One finger tap: speak it again. Double tap: activate what was last moved
|
- One finger tap: speak it again. Double tap: activate what was last moved
|
||||||
(click an explored point, `object-activate` after an object move or Tab,
|
(click an explored point, `object-activate` after an object move or Tab,
|
||||||
`document-activate` after a browse move). In speech settings mode, double
|
`document-activate` after a browse move). In speech settings mode, double
|
||||||
@@ -217,3 +220,6 @@ test stopped. Chromium stopped at tables, so cells were never reached.
|
|||||||
test settings file is now kept.
|
test settings file is now kept.
|
||||||
- 2026-11-24: Browse mode flicks swapped at the tester's request: right and
|
- 2026-11-24: Browse mode flicks swapped at the tester's request: right and
|
||||||
left read in page order, down and up follow the rotor.
|
left read in page order, down and up follow the rotor.
|
||||||
|
- 2026-11-24: MATE testing: the 24 pixel panels were too thin to find by
|
||||||
|
touch (the tester's MATE panels were raised to 64). Explore now says
|
||||||
|
"Blank" over empty space and names the window a finger crosses into.
|
||||||
+59
-11
@@ -98,6 +98,34 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
|||||||
var state mouseReviewState
|
var state mouseReviewState
|
||||||
state.clearItem(xorg.PointerPosition{})
|
state.clearItem(xorg.PointerPosition{})
|
||||||
lastName := ""
|
lastName := ""
|
||||||
|
// Silence over empty space sounds like a broken screen reader, so empty
|
||||||
|
// space says "Blank" once, until the finger reaches something again.
|
||||||
|
blank := false
|
||||||
|
// Crossing into another window says its title first, so a finger that
|
||||||
|
// slides off one app always knows where it landed.
|
||||||
|
var lastWindow uint64
|
||||||
|
windowKnown := false
|
||||||
|
entered := ""
|
||||||
|
withWindow := func(text string) string {
|
||||||
|
if entered == "" {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
text, entered = entered+", "+text, ""
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
sayBlank := func(reason string, point touchPoint) {
|
||||||
|
reviewer.logger.Debug("touch review blank", "reason", reason, "x", point.x, "y", point.y)
|
||||||
|
state.clearItem(xorg.PointerPosition{})
|
||||||
|
lastName = ""
|
||||||
|
if blank && !point.force && entered == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
blank = true
|
||||||
|
text := withWindow("Blank")
|
||||||
|
reviewer.speech.Interrupt()
|
||||||
|
reviewer.speech.Enqueue(speechRequest{Text: text, Role: "system", Cause: "touch-review"})
|
||||||
|
reviewer.braille.EnqueueMessage(text)
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
var point touchPoint
|
var point touchPoint
|
||||||
select {
|
select {
|
||||||
@@ -105,11 +133,24 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
case point = <-reviewer.points:
|
case point = <-reviewer.points:
|
||||||
}
|
}
|
||||||
pid, _ := locator.WindowAt(point.x, point.y)
|
pid, window := locator.WindowAt(point.x, point.y)
|
||||||
if pid <= 0 {
|
if !windowKnown || window != lastWindow {
|
||||||
reviewer.logger.Debug("touch review silent", "reason", "no window", "x", point.x, "y", point.y)
|
title := "Desktop"
|
||||||
|
if window != 0 {
|
||||||
|
if title = locator.WindowTitle(window); title == "" {
|
||||||
|
title = "Window"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The first touch after starting has no window to leave.
|
||||||
|
if windowKnown {
|
||||||
|
entered = title
|
||||||
|
}
|
||||||
|
lastWindow, windowKnown = window, true
|
||||||
state.clearItem(xorg.PointerPosition{})
|
state.clearItem(xorg.PointerPosition{})
|
||||||
lastName = ""
|
lastName = ""
|
||||||
|
}
|
||||||
|
if pid <= 0 {
|
||||||
|
sayBlank("no window", point)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if point.force {
|
if point.force {
|
||||||
@@ -140,9 +181,7 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
snapshot := hit.Snapshot
|
snapshot := hit.Snapshot
|
||||||
if !snapshot.ID().Valid() {
|
if !snapshot.ID().Valid() {
|
||||||
reviewer.logger.Debug("touch review silent", "reason", "no object", "pid", pid, "x", point.x, "y", point.y)
|
sayBlank("no object", point)
|
||||||
state.clearItem(xorg.PointerPosition{})
|
|
||||||
lastName = ""
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if review.ItemSkips(snapshot) {
|
if review.ItemSkips(snapshot) {
|
||||||
@@ -150,15 +189,19 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
|||||||
// finger does: exploring is for reading what is there.
|
// finger does: exploring is for reading what is there.
|
||||||
if line := strings.TrimSpace(hit.Line); line != "" && line != state.spoken {
|
if line := strings.TrimSpace(hit.Line); line != "" && line != state.spoken {
|
||||||
state.spoken, state.last = line, hit
|
state.spoken, state.last = line, hit
|
||||||
|
text := withWindow(line)
|
||||||
reviewer.speech.Interrupt()
|
reviewer.speech.Interrupt()
|
||||||
reviewer.speech.Enqueue(speechRequest{Text: line, Cause: "touch-review"})
|
reviewer.speech.Enqueue(speechRequest{Text: text, Cause: "touch-review"})
|
||||||
reviewer.braille.EnqueueMessage(line)
|
reviewer.braille.EnqueueMessage(text)
|
||||||
|
blank = false
|
||||||
reviewer.logger.Debug("touch review line", "role", snapshot.Role, "x", point.x, "y", point.y, "speech", line)
|
reviewer.logger.Debug("touch review line", "role", snapshot.Role, "x", point.x, "y", point.y, "speech", line)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if strings.TrimSpace(hit.Line) == "" {
|
||||||
|
sayBlank("empty "+snapshot.Role, point)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if !point.force {
|
if !point.force {
|
||||||
reviewer.logger.Debug("touch review silent", "reason", "container", "role", snapshot.Role,
|
|
||||||
"x", point.x, "y", point.y)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else if point.commit && reviewer.review != nil {
|
} else if point.commit && reviewer.review != nil {
|
||||||
@@ -181,8 +224,13 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
|||||||
if name != "" {
|
if name != "" {
|
||||||
lastName = name
|
lastName = name
|
||||||
}
|
}
|
||||||
|
blank = false
|
||||||
|
chunks := spoken.Chunks
|
||||||
|
if entered != "" {
|
||||||
|
spoken.Text, chunks = withWindow(spoken.Text), nil
|
||||||
|
}
|
||||||
reviewer.speech.Interrupt()
|
reviewer.speech.Interrupt()
|
||||||
reviewer.speech.Enqueue(speechRequest{Text: spoken.Text, Chunks: spoken.Chunks,
|
reviewer.speech.Enqueue(speechRequest{Text: spoken.Text, Chunks: chunks,
|
||||||
Role: snapshot.Role, Cause: "touch-review"})
|
Role: snapshot.Role, Cause: "touch-review"})
|
||||||
reviewer.braille.EnqueueMessage(spoken.Text)
|
reviewer.braille.EnqueueMessage(spoken.Text)
|
||||||
reviewer.logger.Debug("touch review presentation", "bus", snapshot.BusName,
|
reviewer.logger.Debug("touch review presentation", "bus", snapshot.BusName,
|
||||||
|
|||||||
@@ -4,8 +4,12 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.stormux.org/storm/cthulhu/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBehaviorTouchActivityQuietsMouseReviewBriefly(t *testing.T) {
|
func TestBehaviorTouchActivityQuietsMouseReviewBriefly(t *testing.T) {
|
||||||
@@ -26,3 +30,49 @@ func TestBehaviorTouchActivityQuietsMouseReviewBriefly(t *testing.T) {
|
|||||||
t.Fatal("nil activity must never quiet mouse review")
|
t.Fatal("nil activity must never quiet mouse review")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type blankSpeech struct{ said chan string }
|
||||||
|
|
||||||
|
func (speech blankSpeech) Enqueue(request speechRequest) { speech.said <- request.Text }
|
||||||
|
func (blankSpeech) Interrupt() {}
|
||||||
|
|
||||||
|
type blankBraille struct{}
|
||||||
|
|
||||||
|
func (blankBraille) EnqueueMessage(string) bool { return true }
|
||||||
|
|
||||||
|
func TestBehaviorEmptySpaceSaysBlankOnce(t *testing.T) {
|
||||||
|
t.Setenv("DISPLAY", "") // no X display: every point has no window under it
|
||||||
|
settings := config.DefaultSettings()
|
||||||
|
settings.Reading.EnableTouchScreen = true
|
||||||
|
live := &liveSettings{}
|
||||||
|
live.Store(settings)
|
||||||
|
speech := blankSpeech{said: make(chan string, 8)}
|
||||||
|
reviewer := &touchReviewer{logger: slog.New(slog.DiscardHandler), speech: speech, braille: blankBraille{},
|
||||||
|
live: live, gate: &focusGate{}, points: make(chan touchPoint, 1)}
|
||||||
|
ctx, cancel := context.WithCancel(t.Context())
|
||||||
|
defer cancel()
|
||||||
|
go reviewer.run(ctx)
|
||||||
|
expect := func(want string) {
|
||||||
|
t.Helper()
|
||||||
|
select {
|
||||||
|
case got := <-speech.said:
|
||||||
|
if got != want {
|
||||||
|
t.Fatalf("said %q, want %q", got, want)
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
if want != "" {
|
||||||
|
t.Fatalf("said nothing, want %q", want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reviewer.request(touchPoint{x: 10, y: 10})
|
||||||
|
expect("Blank")
|
||||||
|
reviewer.request(touchPoint{x: 20, y: 20})
|
||||||
|
select {
|
||||||
|
case got := <-speech.said:
|
||||||
|
t.Fatalf("moving over more empty space must stay quiet, said %q", got)
|
||||||
|
case <-time.After(200 * time.Millisecond):
|
||||||
|
}
|
||||||
|
reviewer.request(touchPoint{x: 20, y: 20, force: true})
|
||||||
|
expect("Blank")
|
||||||
|
}
|
||||||
@@ -46,6 +46,18 @@ func (locator *WindowLocator) WindowAt(x, y int) (pid int, window uint64) {
|
|||||||
return pid, uint64(native)
|
return pid, uint64(native)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WindowTitle reports a window's title, or "" when it has none.
|
||||||
|
func (locator *WindowLocator) WindowTitle(window uint64) string {
|
||||||
|
if locator == nil || locator.display == nil || window == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var title [512]C.char
|
||||||
|
if C.cthulhu_window_title(locator.display, C.ulong(window), &title[0], C.int(len(title))) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return C.GoString(&title[0])
|
||||||
|
}
|
||||||
|
|
||||||
// Click presses and releases a mouse button (1 left, 3 right, 4 and 5 the
|
// Click presses and releases a mouse button (1 left, 3 right, 4 and 5 the
|
||||||
// wheel) at a point and returns the pointer to where it was.
|
// wheel) at a point and returns the pointer to where it was.
|
||||||
func (locator *WindowLocator) Click(x, y, button int) bool {
|
func (locator *WindowLocator) Click(x, y, button int) bool {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
Display *cthulhu_window_locator_open(void) { return XOpenDisplay(NULL); }
|
Display *cthulhu_window_locator_open(void) { return XOpenDisplay(NULL); }
|
||||||
|
|
||||||
@@ -57,6 +58,45 @@ int cthulhu_window_locator_pid(Display *display, int xres, int x, int y, unsigne
|
|||||||
return pid > 0 ? pid : 0;
|
return pid > 0 ? pid : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cthulhu_window_title_once(Display *display, Window window, char *title, int size) {
|
||||||
|
Atom netName = XInternAtom(display, "_NET_WM_NAME", False);
|
||||||
|
Atom utf8 = XInternAtom(display, "UTF8_STRING", False);
|
||||||
|
Atom type = None; int format = 0; unsigned long items = 0, after = 0;
|
||||||
|
unsigned char *data = NULL;
|
||||||
|
if (XGetWindowProperty(display, window, netName, 0, 256, False, utf8, &type, &format,
|
||||||
|
&items, &after, &data) == Success && data && type == utf8 && format == 8) {
|
||||||
|
snprintf(title, size, "%s", (char *)data);
|
||||||
|
}
|
||||||
|
if (data) XFree(data);
|
||||||
|
if (!title[0]) {
|
||||||
|
char *name = NULL;
|
||||||
|
if (XFetchName(display, window, &name) && name) {
|
||||||
|
snprintf(title, size, "%s", name);
|
||||||
|
XFree(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return title[0] != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy a window's title into title, preferring the UTF-8 _NET_WM_NAME. An
|
||||||
|
// inner window without a title takes the nearest titled ancestor's.
|
||||||
|
int cthulhu_window_title(Display *display, unsigned long window, char *title, int size) {
|
||||||
|
if (!window || size < 1) return 0;
|
||||||
|
title[0] = 0;
|
||||||
|
Window root = DefaultRootWindow(display), current = (Window)window;
|
||||||
|
cthulhu_x11_begin_read(display);
|
||||||
|
for (int depth = 0; depth < 16 && current != None && current != root; depth++) {
|
||||||
|
if (cthulhu_window_title_once(display, current, title, size)) break;
|
||||||
|
Window queryRoot, parent = None, *children = NULL;
|
||||||
|
unsigned int count = 0;
|
||||||
|
if (!XQueryTree(display, current, &queryRoot, &parent, &children, &count)) break;
|
||||||
|
if (children) XFree(children);
|
||||||
|
current = parent;
|
||||||
|
}
|
||||||
|
if (cthulhu_x11_end_read(display)) title[0] = 0;
|
||||||
|
return title[0] != 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Press and release one key, optionally with Shift, for touch desktop
|
// Press and release one key, optionally with Shift, for touch desktop
|
||||||
// gestures such as Tab and Escape.
|
// gestures such as Tab and Escape.
|
||||||
int cthulhu_touch_key(Display *display, unsigned long keysym, int shift) {
|
int cthulhu_touch_key(Display *display, unsigned long keysym, int shift) {
|
||||||
|
|||||||
@@ -14,4 +14,7 @@ int cthulhu_touch_click(Display *display, int x, int y, int button);
|
|||||||
// Takes and releases the X11 guard; the caller must not hold it.
|
// Takes and releases the X11 guard; the caller must not hold it.
|
||||||
int cthulhu_touch_key(Display *display, unsigned long keysym, int shift);
|
int cthulhu_touch_key(Display *display, unsigned long keysym, int shift);
|
||||||
|
|
||||||
|
// Takes and releases the X11 guard; the caller must not hold it.
|
||||||
|
int cthulhu_window_title(Display *display, unsigned long window, char *title, int size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -50,20 +50,27 @@ func TestNativeWindowLocatorFallbackReleasesGuard(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer pointer.Close()
|
defer pointer.Close()
|
||||||
|
|
||||||
type result struct{ pid int }
|
type result struct {
|
||||||
|
pid int
|
||||||
|
title string
|
||||||
|
}
|
||||||
done := make(chan result, 1)
|
done := make(chan result, 1)
|
||||||
go func() {
|
go func() {
|
||||||
pid, _ := locator.WindowAt(140, 130)
|
pid, window := locator.WindowAt(140, 130)
|
||||||
|
title := locator.WindowTitle(window)
|
||||||
// Another guarded reader must still get the guard afterwards.
|
// Another guarded reader must still get the guard afterwards.
|
||||||
pointer.Read()
|
pointer.Read()
|
||||||
done <- result{pid}
|
done <- result{pid, title}
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
case got := <-done:
|
case got := <-done:
|
||||||
if locator.xres != 0 && got.pid != client.Process.Pid {
|
if locator.xres != 0 && got.pid != client.Process.Pid {
|
||||||
t.Fatalf("XRes fallback found pid %d, want xterm %d", got.pid, client.Process.Pid)
|
t.Fatalf("XRes fallback found pid %d, want xterm %d", got.pid, client.Process.Pid)
|
||||||
}
|
}
|
||||||
t.Logf("xres=%d pid=%s", locator.xres, strconv.Itoa(got.pid))
|
if got.title == "" {
|
||||||
|
t.Fatal("the window under the point has no title; the nearest titled ancestor was not found")
|
||||||
|
}
|
||||||
|
t.Logf("xres=%d pid=%s title=%q", locator.xres, strconv.Itoa(got.pid), got.title)
|
||||||
case <-time.After(3 * time.Second):
|
case <-time.After(3 * time.Second):
|
||||||
t.Fatal("window lookup left the X11 guard held")
|
t.Fatal("window lookup left the X11 guard held")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user