Harden touch device recovery and input lifecycle
This commit is contained in:
1 parent
e4ba4d9882
commit
03066b2abe
16 files changed
+323
-66
No files matched your search
+41
-3
@@ -5,7 +5,7 @@ only input, the way TalkBack, VoiceOver and NVDA touch work. Touch is its own
|
||||
subsystem with its own gestures, bindings and modes. It shares only the
|
||||
"what is at this point" hit test with mouse review.
|
||||
|
||||
Branch: `touch-support`, based on `testing`. Requested by Storm Dragon.
|
||||
Integrated into `testing` from Chase Cichorz's three-commit touch patch.
|
||||
|
||||
## Design
|
||||
|
||||
@@ -138,10 +138,10 @@ test stopped. Chromium stopped at tables, so cells were never reached.
|
||||
|
||||
## Testing
|
||||
|
||||
- Automated: `dbus-run-session -- go test ./internal/touch ./internal/platform/evdev ./internal/i3command ./internal/review ./internal/app ./internal/config ./internal/preferences ./internal/platform/xorg -count=1`.
|
||||
- Automated: `python3 tests/native_test_session.py go test ./internal/touch ./internal/platform/evdev ./internal/i3command ./internal/review ./internal/app ./internal/config ./internal/preferences ./internal/platform/xorg -count=1`.
|
||||
`internal/app` tests read the real session bus, so run them under
|
||||
`dbus-run-session` or they fail while a screen lock is active.
|
||||
- Native X11: `CTHULHU_NATIVE_X11=1 xvfb-run -a -s "-screen 0 1280x800x24" go test ./internal/platform/xorg -run TestNativeWindowLocator`
|
||||
- Native X11: `python3 tests/native_test_session.py env CTHULHU_NATIVE_X11=1 go test ./internal/platform/xorg -run "TestNativeWindowLocator|TestNativeTouchKey" -count=1`
|
||||
(needs xterm, xdotool and xprop). Real touch device discovery:
|
||||
`CTHULHU_NATIVE_EVDEV=1 go test ./internal/platform/evdev -run TestNativeFindTouchScreens`.
|
||||
- Live: run `build/cthulhu --replace --config <copy of your settings> --debug-file <log>`
|
||||
@@ -223,3 +223,41 @@ test stopped. Chromium stopped at tables, so cells were never reached.
|
||||
- 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.
|
||||
|
||||
## Integration review and acceptance
|
||||
|
||||
The integration fixes device retry starvation; uses scalar EVIOCGRAB arguments
|
||||
for acquisition and release; decodes native input-event sizes and byte order;
|
||||
rejects unsupported descriptors and slots; and cancels lost input instead of
|
||||
turning it into a tap. After overflow the service releases and reopens the
|
||||
device after five seconds to discard unknown slot state. Disable, lock and
|
||||
device loss clear the activation point and retire pending exploration results.
|
||||
Wayland sessions never grab a device. Synthesized keys preserve keys already
|
||||
held by the user. Item traversal has an explicit ascent limit. Empty i3 replies
|
||||
are failures and cancellation closes an outstanding command connection.
|
||||
|
||||
Before pushing, build from testing and check on the touchscreen:
|
||||
|
||||
1. Toggle with Cthulhu+Ctrl+Alt+T; explore, tap, double tap, rotate, and flick
|
||||
through each mode. Check speech and Braille, including window boundaries.
|
||||
2. Unplug/reconnect or enable before connecting the device. It should become
|
||||
available after the retry interval. Toggle off/on; a double tap must not
|
||||
activate an old point. Lock/unlock using the keyboard and repeat.
|
||||
3. Hold either physical Shift while issuing touch Shift+Tab. Shift must remain
|
||||
held until physically released; normal keyboard navigation must still work.
|
||||
4. Check mouse review, GTK notebook pages, browser tables, browse navigation,
|
||||
object navigation, and activation. Keep the reader responsive while moving
|
||||
a finger rapidly over a large page.
|
||||
5. Tab and Shift+Tab through the touch preferences checkbox, Apply, reopen,
|
||||
and restart using the saved test configuration to verify persistence.
|
||||
|
||||
Private automated tests do not establish physical touch, audible speech,
|
||||
Braille, or preferences keyboard acceptance. The original contributor's live
|
||||
results above are historical evidence, not verification of these review fixes.
|
||||
|
||||
Validation for this integration: the full Go suite passed in a private
|
||||
Xvfb/D-Bus session; focused touch/review/app race checks and focused go vet
|
||||
passed; native mouse hit testing, XRes window lookup, and held-key preservation
|
||||
passed. The reader, input helper, and BrlAPI-tagged Braille helper built.
|
||||
Translation catalog checks and git diff whitespace checks passed. No running
|
||||
reader was replaced and no physical touchscreen acceptance was performed.
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/atspi"
|
||||
"git.stormux.org/storm/cthulhu/internal/i18n"
|
||||
"git.stormux.org/storm/cthulhu/internal/review"
|
||||
)
|
||||
|
||||
@@ -36,12 +37,12 @@ func chooseDefaultAction(actions []atspi.AccessibleAction) (string, bool) {
|
||||
// review, or focus when nothing is under explicit review. It runs off the
|
||||
// command loop so a slow provider never delays other commands.
|
||||
func activateObjectOfInterest(ctx context.Context, logger *slog.Logger, worker *review.Worker,
|
||||
source accessibleActionSource, speech speechEnqueuer) {
|
||||
source accessibleActionSource, speech speechEnqueuer, gate *focusGate) {
|
||||
say := func(text string) {
|
||||
speech.Enqueue(speechRequest{Text: text, Role: "system", Cause: "object-activate"})
|
||||
}
|
||||
if worker == nil || source == nil {
|
||||
say("Activation unavailable.")
|
||||
say(i18n.T("Activation unavailable."))
|
||||
return
|
||||
}
|
||||
lookup, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||
@@ -55,14 +56,17 @@ func activateObjectOfInterest(ctx context.Context, logger *slog.Logger, worker *
|
||||
if err != nil || !ok {
|
||||
if ctx.Err() == nil {
|
||||
logger.Debug("object activation unavailable", "error", err)
|
||||
say("No action available.")
|
||||
say(i18n.T("No action available."))
|
||||
}
|
||||
return
|
||||
}
|
||||
if ctx.Err() != nil || (gate != nil && gate.Locked()) {
|
||||
return
|
||||
}
|
||||
if err := source.PerformAccessibleAction(lookup, actions.Target, name); err != nil {
|
||||
if ctx.Err() == nil {
|
||||
logger.Warn("object activation failed", "action", name, "error", err)
|
||||
say("Could not activate.")
|
||||
say(i18n.T("Could not activate."))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ func (worker commandRuntime) run(ctx context.Context) error {
|
||||
case input.ObjectPreviousItem:
|
||||
queueObjectReviewMove(logger, objectReview, review.PreviousItem)
|
||||
case input.ObjectActivate:
|
||||
go activateObjectOfInterest(ctx, logger, objectReview, worker.actionSource, speechOutput)
|
||||
go activateObjectOfInterest(ctx, logger, objectReview, worker.actionSource, speechOutput, focusGate)
|
||||
case input.DocumentActivate:
|
||||
if objectReview != nil {
|
||||
if err := objectReview.ActivateDocumentCaret(); err != nil {
|
||||
|
||||
+48
-19
@@ -10,10 +10,12 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/i18n"
|
||||
"git.stormux.org/storm/cthulhu/internal/i3command"
|
||||
"git.stormux.org/storm/cthulhu/internal/input"
|
||||
"git.stormux.org/storm/cthulhu/internal/lifecycle"
|
||||
"git.stormux.org/storm/cthulhu/internal/platform/evdev"
|
||||
"git.stormux.org/storm/cthulhu/internal/platform/session"
|
||||
"git.stormux.org/storm/cthulhu/internal/platform/xorg"
|
||||
"git.stormux.org/storm/cthulhu/internal/review"
|
||||
"git.stormux.org/storm/cthulhu/internal/touch"
|
||||
@@ -54,6 +56,7 @@ func (activity *touchActivity) recent(window time.Duration) bool {
|
||||
type touchPoint struct {
|
||||
x, y int
|
||||
force, commit bool
|
||||
generation uint64
|
||||
}
|
||||
|
||||
// touchReviewer speaks what is under the finger. It owns its own last spoken
|
||||
@@ -69,11 +72,13 @@ type touchReviewer struct {
|
||||
gate *focusGate
|
||||
review *review.Worker
|
||||
// browsing reports whether browse mode is active on a web page.
|
||||
browsing func() bool
|
||||
points chan touchPoint
|
||||
browsing func() bool
|
||||
points chan touchPoint
|
||||
generation atomic.Uint64
|
||||
}
|
||||
|
||||
func (reviewer *touchReviewer) request(point touchPoint) {
|
||||
point.generation = reviewer.generation.Load()
|
||||
for {
|
||||
select {
|
||||
case reviewer.points <- point:
|
||||
@@ -82,8 +87,10 @@ func (reviewer *touchReviewer) request(point touchPoint) {
|
||||
}
|
||||
select {
|
||||
case old := <-reviewer.points:
|
||||
point.force = point.force || old.force
|
||||
point.commit = point.commit || old.commit
|
||||
if old.generation == point.generation {
|
||||
point.force = point.force || old.force
|
||||
point.commit = point.commit || old.commit
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -105,6 +112,7 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
||||
// slides off one app always knows where it landed.
|
||||
var lastWindow uint64
|
||||
windowKnown := false
|
||||
var lastGeneration uint64
|
||||
entered := ""
|
||||
withWindow := func(text string) string {
|
||||
if entered == "" {
|
||||
@@ -114,6 +122,9 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
||||
return text
|
||||
}
|
||||
sayBlank := func(reason string, point touchPoint) {
|
||||
if ctx.Err() != nil || point.generation != reviewer.generation.Load() || !reviewer.live.Load().Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
return
|
||||
}
|
||||
reviewer.logger.Debug("touch review blank", "reason", reason, "x", point.x, "y", point.y)
|
||||
state.clearItem(xorg.PointerPosition{})
|
||||
lastName = ""
|
||||
@@ -121,7 +132,7 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
blank = true
|
||||
text := withWindow("Blank")
|
||||
text := withWindow(i18n.T("Blank"))
|
||||
reviewer.speech.Interrupt()
|
||||
reviewer.speech.Enqueue(speechRequest{Text: text, Role: "system", Cause: "touch-review"})
|
||||
reviewer.braille.EnqueueMessage(text)
|
||||
@@ -133,12 +144,20 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
||||
return
|
||||
case point = <-reviewer.points:
|
||||
}
|
||||
if point.generation != reviewer.generation.Load() || ctx.Err() != nil || !reviewer.live.Load().Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
continue
|
||||
}
|
||||
if point.generation != lastGeneration {
|
||||
state.clearItem(xorg.PointerPosition{})
|
||||
lastName, entered, blank, windowKnown = "", "", false, false
|
||||
lastGeneration = point.generation
|
||||
}
|
||||
pid, window := locator.WindowAt(point.x, point.y)
|
||||
if !windowKnown || window != lastWindow {
|
||||
title := "Desktop"
|
||||
title := i18n.T("Desktop")
|
||||
if window != 0 {
|
||||
if title = locator.WindowTitle(window); title == "" {
|
||||
title = "Window"
|
||||
title = i18n.T("Window")
|
||||
}
|
||||
}
|
||||
// The first touch after starting has no window to leave.
|
||||
@@ -176,7 +195,7 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
settings := reviewer.live.Load()
|
||||
if !settings.Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
if point.generation != reviewer.generation.Load() || ctx.Err() != nil || !settings.Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
continue
|
||||
}
|
||||
snapshot := hit.Snapshot
|
||||
@@ -238,7 +257,7 @@ func (reviewer *touchReviewer) run(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// touchService owns the XInput2 touch grab while the touch screen setting is
|
||||
// touchService owns the evdev touch grab while the touch screen setting is
|
||||
// on and the session is not locked. When it is off, touches go to applications.
|
||||
func touchService(logger *slog.Logger, adapter pointReviewAdapter, speech speechEnqueuer,
|
||||
braille interface{ EnqueueMessage(string) bool }, live *liveSettings, gate *focusGate,
|
||||
@@ -287,6 +306,10 @@ func touchService(logger *slog.Logger, adapter pointReviewAdapter, speech speech
|
||||
// arriving. Activation clicks use this loop's own X connection.
|
||||
func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchReviewer,
|
||||
speech speechEnqueuer, activity *touchActivity, commands chan<- input.CommandEvent) {
|
||||
if session.Wayland() {
|
||||
logger.Info("touch screen requires an X11 session")
|
||||
return
|
||||
}
|
||||
var screen *evdev.TouchScreen
|
||||
var locator *xorg.WindowLocator
|
||||
defer func() {
|
||||
@@ -314,12 +337,16 @@ func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchRev
|
||||
var sentAt time.Time
|
||||
|
||||
release := func() {
|
||||
reviewer.generation.Add(1)
|
||||
if screen != nil {
|
||||
screen.Close()
|
||||
screen = nil
|
||||
logger.Info("touch screen released")
|
||||
}
|
||||
exploreWaiting = false
|
||||
haveExplored = false
|
||||
nav = newTouchNavigation()
|
||||
sentAt = time.Time{}
|
||||
if recognizer != nil {
|
||||
recognizer.Reset()
|
||||
}
|
||||
@@ -345,8 +372,7 @@ func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchRev
|
||||
if denied && !toldDenied {
|
||||
toldDenied = true
|
||||
logger.Warn("touch screen unreadable: add the user to the input group")
|
||||
speech.Enqueue(speechRequest{Text: "Touch screen needs input group access. " +
|
||||
"Add your user to the input group and log in again.", Cause: "touch-screen"})
|
||||
speech.Enqueue(speechRequest{Text: i18n.T("Touch screen needs input group access. Add your user to the input group and log in again."), Cause: "touch-screen"})
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -360,17 +386,14 @@ func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchRev
|
||||
return false
|
||||
}
|
||||
screen = opened
|
||||
if recognizer == nil {
|
||||
recognizer = touch.New(touch.DefaultConfig(width))
|
||||
}
|
||||
recognizer.Reset()
|
||||
recognizer = touch.New(touch.DefaultConfig(width))
|
||||
logger.Info("touch screen grabbed", "device", screen.Device.Path, "name", screen.Device.Name,
|
||||
"slots", screen.Device.Slots, "width", width, "height", height)
|
||||
return true
|
||||
}
|
||||
for ctx.Err() == nil {
|
||||
settings := reviewer.live.Load()
|
||||
if !settings.Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
if ctx.Err() != nil || !settings.Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
release()
|
||||
if !idle() {
|
||||
return
|
||||
@@ -378,10 +401,12 @@ func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchRev
|
||||
continue
|
||||
}
|
||||
if screen == nil {
|
||||
if time.Now().Before(retryAt) || !open() {
|
||||
if screen == nil {
|
||||
if !time.Now().Before(retryAt) {
|
||||
if !open() {
|
||||
retryAt = time.Now().Add(touchRetryInterval)
|
||||
}
|
||||
}
|
||||
if screen == nil {
|
||||
if !idle() {
|
||||
return
|
||||
}
|
||||
@@ -396,6 +421,10 @@ func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchRev
|
||||
retryAt = time.Now().Add(touchRetryInterval)
|
||||
continue
|
||||
}
|
||||
if ctx.Err() != nil || !reviewer.live.Load().Reading.EnableTouchScreen || reviewer.gate.Locked() {
|
||||
release()
|
||||
continue
|
||||
}
|
||||
now := time.Since(epoch)
|
||||
var outputs []touch.Output
|
||||
if ok {
|
||||
@@ -457,7 +486,7 @@ func runTouchScreen(ctx context.Context, logger *slog.Logger, reviewer *touchRev
|
||||
defer cancel()
|
||||
if err := i3command.Run(runCtx, xorg.I3Socket(), name); err != nil && ctx.Err() == nil {
|
||||
logger.Debug("touch desktop command", "command", name, "error", err)
|
||||
speech.Enqueue(speechRequest{Text: "Not available", Role: "system", Cause: "touch-mode"})
|
||||
speech.Enqueue(speechRequest{Text: i18n.T("Not available"), Role: "system", Cause: "touch-mode"})
|
||||
}
|
||||
}(action.i3)
|
||||
case action.command != "":
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"git.stormux.org/storm/cthulhu/internal/i18n"
|
||||
"git.stormux.org/storm/cthulhu/internal/input"
|
||||
"git.stormux.org/storm/cthulhu/internal/touch"
|
||||
)
|
||||
@@ -38,8 +39,8 @@ const (
|
||||
)
|
||||
|
||||
func (mode touchMode) label() string {
|
||||
return [...]string{"Navigation mode", "Text mode", "Browse mode", "Object mode",
|
||||
"Speech settings mode"}[mode]
|
||||
return i18n.T([...]string{"Navigation mode", "Text mode", "Browse mode", "Object mode",
|
||||
"Speech settings mode"}[mode])
|
||||
}
|
||||
|
||||
// touchFlick names one flick.
|
||||
@@ -225,14 +226,14 @@ func (nav *touchNavigation) turn(clockwise bool) touchAction {
|
||||
}
|
||||
rotor := touchModes[nav.mode].rotor
|
||||
if len(rotor) == 0 {
|
||||
return touchAction{announce: nav.mode.label() + " has no rotor"}
|
||||
return touchAction{announce: i18n.Format("{0} has no rotor", nav.mode.label())}
|
||||
}
|
||||
step := 1
|
||||
if !clockwise {
|
||||
step = len(rotor) - 1
|
||||
}
|
||||
nav.rotor[nav.mode] = (nav.rotor[nav.mode] + step) % len(rotor)
|
||||
return touchAction{announce: rotor[nav.rotor[nav.mode]].label}
|
||||
return touchAction{announce: i18n.T(rotor[nav.rotor[nav.mode]].label)}
|
||||
}
|
||||
|
||||
// flick finds a flick in the current rotor unit, then in the mode itself.
|
||||
@@ -278,7 +279,7 @@ func (nav *touchNavigation) gesture(gesture touch.Gesture, browsing bool) touchA
|
||||
case touchLastObject:
|
||||
return touchCmd(input.ObjectActivate)
|
||||
}
|
||||
return touchAction{announce: "Nothing to activate"}
|
||||
return touchAction{announce: i18n.T("Nothing to activate")}
|
||||
case touch.DoubleTapHold:
|
||||
if nav.last == touchLastPoint {
|
||||
return touchAction{rightClickPoint: true}
|
||||
|
||||
@@ -76,3 +76,46 @@ func TestBehaviorEmptySpaceSaysBlankOnce(t *testing.T) {
|
||||
reviewer.request(touchPoint{x: 20, y: 20, force: true})
|
||||
expect("Blank")
|
||||
}
|
||||
|
||||
func TestTouchReviewerDropsDisabledAndRetiredRequests(t *testing.T) {
|
||||
t.Setenv("DISPLAY", "")
|
||||
settings := config.DefaultSettings()
|
||||
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())
|
||||
done := make(chan struct{})
|
||||
go func() { defer close(done); reviewer.run(ctx) }()
|
||||
defer func() { cancel(); <-done }()
|
||||
reviewer.request(touchPoint{force: true})
|
||||
select {
|
||||
case got := <-speech.said:
|
||||
t.Fatalf("disabled touch said %q", got)
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
}
|
||||
settings.Reading.EnableTouchScreen = true
|
||||
live.Store(settings)
|
||||
reviewer.generation.Add(1)
|
||||
reviewer.points <- touchPoint{force: true, generation: 0}
|
||||
select {
|
||||
case got := <-speech.said:
|
||||
t.Fatalf("retired touch said %q", got)
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
}
|
||||
reviewer.request(touchPoint{force: true})
|
||||
select {
|
||||
case got := <-speech.said:
|
||||
if got != "Blank" {
|
||||
t.Fatalf("fresh touch said %q", got)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("fresh touch was lost")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaylandDoesNotOpenTouchDevice(t *testing.T) {
|
||||
t.Setenv("XDG_SESSION_TYPE", "wayland")
|
||||
// No reader dependencies: unsupported sessions must return before opening hardware.
|
||||
runTouchScreen(t.Context(), slog.New(slog.DiscardHandler), nil, nil, nil, nil)
|
||||
}
|
||||
@@ -33,6 +33,7 @@ func TestStoreSaveAndLoadRoundTrip(t *testing.T) {
|
||||
settings.Reading.SayAllContextPanel = false
|
||||
settings.Reading.PresentTooltips = true
|
||||
settings.Reading.EnableMouseReview = true
|
||||
settings.Reading.EnableTouchScreen = true
|
||||
settings.EnableBraille = true
|
||||
settings.EnableContractedBraille = true
|
||||
settings.BrailleContractionTable = "en-us-g2.ctb"
|
||||
|
||||
@@ -13,14 +13,30 @@ msgstr ""
|
||||
msgid "1 character"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/object_activate.go:45
|
||||
msgid "Activation unavailable."
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch.go:135
|
||||
msgid "Blank"
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui
|
||||
msgid "Copy and cut are unavailable for password fields"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/object_activate.go:69
|
||||
msgid "Could not activate."
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui
|
||||
msgid "Deleted {0}"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch.go:157
|
||||
msgid "Desktop"
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui
|
||||
msgid "End of text"
|
||||
msgstr ""
|
||||
@@ -37,10 +53,22 @@ msgstr ""
|
||||
msgid "Invalid text"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/object_activate.go:59
|
||||
msgid "No action available."
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui
|
||||
msgid "No matches"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch.go:489
|
||||
msgid "Not available"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch_navigation.go:282
|
||||
msgid "Nothing to activate"
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui
|
||||
msgid "Only single-line text is accepted"
|
||||
msgstr ""
|
||||
@@ -65,6 +93,14 @@ msgstr ""
|
||||
msgid "Text limit reached"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch.go:375
|
||||
msgid "Touch screen needs input group access. Add your user to the input group and log in again."
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch.go:160
|
||||
msgid "Window"
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui screenreader-common/quicksettings/menu.go
|
||||
msgid "checked"
|
||||
msgstr ""
|
||||
@@ -101,6 +137,10 @@ msgstr ""
|
||||
msgid "{0} grid. {1}"
|
||||
msgstr ""
|
||||
|
||||
#: internal/app/touch_navigation.go:229
|
||||
msgid "{0} has no rotor"
|
||||
msgstr ""
|
||||
|
||||
#: screenreader-common/internalui
|
||||
msgid "{0} is required"
|
||||
msgstr ""
|
||||
|
||||
@@ -35,6 +35,8 @@ func Run(ctx context.Context, path, command string) error {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
stop := context.AfterFunc(ctx, func() { conn.Close() })
|
||||
defer stop()
|
||||
deadline := time.Now().Add(timeout)
|
||||
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
|
||||
deadline = d
|
||||
@@ -59,6 +61,9 @@ func Run(ctx context.Context, path, command string) error {
|
||||
if err := json.Unmarshal(body, &replies); err != nil {
|
||||
return fmt.Errorf("i3 reply: %w", err)
|
||||
}
|
||||
if len(replies) == 0 {
|
||||
return errors.New("empty i3 command reply")
|
||||
}
|
||||
for _, reply := range replies {
|
||||
if !reply.Success {
|
||||
return fmt.Errorf("i3 %q: %s", command, reply.Error)
|
||||
|
||||
@@ -65,3 +65,10 @@ func TestBehaviorRunReportsI3Failure(t *testing.T) {
|
||||
t.Fatal("a missing socket must return an error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyReplyIsNotSuccess(t *testing.T) {
|
||||
path, _ := fakeI3(t, `[]`)
|
||||
if err := Run(t.Context(), path, "workspace next"); err == nil {
|
||||
t.Fatal("empty reply accepted")
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ const (
|
||||
Begin = 0
|
||||
Update = 1
|
||||
End = 2
|
||||
Cancel = 3 // Lost events invalidate the whole gesture.
|
||||
)
|
||||
|
||||
// Contact is one finger change in screen pixels.
|
||||
@@ -157,15 +158,16 @@ func Open(device Device, screenWidth, screenHeight int) (*TouchScreen, error) {
|
||||
return nil, err
|
||||
}
|
||||
fd := int(file.Fd())
|
||||
one := int32(1)
|
||||
if err := ioctl(fd, ioc(iocWrite, 0x90, 4), unsafe.Pointer(&one)); err != nil {
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), ioc(iocWrite, 0x90, 4), 1); err != 0 {
|
||||
file.Close()
|
||||
return nil, fmt.Errorf("grab %s: %w", device.Path, err)
|
||||
}
|
||||
return &TouchScreen{Device: device, file: file, fd: fd,
|
||||
tracker: NewTracker(device, screenWidth, screenHeight), buffer: make([]byte, 24*64)}, nil
|
||||
tracker: NewTracker(device, screenWidth, screenHeight), buffer: make([]byte, inputEventSize*64)}, nil
|
||||
}
|
||||
|
||||
const inputEventSize = int(unsafe.Sizeof(syscall.Timeval{})) + 8
|
||||
|
||||
// Next waits up to timeout for one contact change. failed reports that the
|
||||
// device went away, for example when it was unplugged.
|
||||
func (screen *TouchScreen) Next(timeout time.Duration) (contact Contact, ok, failed bool) {
|
||||
@@ -174,7 +176,11 @@ func (screen *TouchScreen) Next(timeout time.Duration) (contact Contact, ok, fai
|
||||
return contact, true, false
|
||||
}
|
||||
var set syscall.FdSet
|
||||
set.Bits[screen.fd/64] |= 1 << (uint(screen.fd) % 64)
|
||||
bits := int(unsafe.Sizeof(set.Bits[0])) * 8
|
||||
if screen.fd < 0 || screen.fd >= len(set.Bits)*bits {
|
||||
return Contact{}, false, true
|
||||
}
|
||||
set.Bits[screen.fd/bits] |= 1 << (uint(screen.fd) % uint(bits))
|
||||
tv := syscall.NsecToTimeval(timeout.Nanoseconds())
|
||||
n, err := syscall.Select(screen.fd+1, &set, nil, nil, &tv)
|
||||
if err != nil {
|
||||
@@ -196,10 +202,17 @@ func (screen *TouchScreen) Next(timeout time.Duration) (contact Contact, ok, fai
|
||||
if count == 0 {
|
||||
return Contact{}, false, true
|
||||
}
|
||||
for offset := 0; offset+24 <= count; offset += 24 {
|
||||
record := screen.buffer[offset : offset+24]
|
||||
screen.pending = screen.tracker.Event(binary.LittleEndian.Uint16(record[16:]),
|
||||
binary.LittleEndian.Uint16(record[18:]), int32(binary.LittleEndian.Uint32(record[20:])), screen.pending)
|
||||
for offset := 0; offset+inputEventSize <= count; offset += inputEventSize {
|
||||
record := screen.buffer[offset+inputEventSize-8 : offset+inputEventSize]
|
||||
screen.pending = screen.tracker.Event(binary.NativeEndian.Uint16(record),
|
||||
binary.NativeEndian.Uint16(record[2:]), int32(binary.NativeEndian.Uint32(record[4:])), screen.pending)
|
||||
}
|
||||
for _, event := range screen.pending {
|
||||
if event.Phase == Cancel {
|
||||
// Reopen after overflow to discard unknown kernel slot state.
|
||||
screen.pending = nil
|
||||
return Contact{}, false, true
|
||||
}
|
||||
}
|
||||
if len(screen.pending) == 0 {
|
||||
return Contact{}, false, false
|
||||
@@ -213,8 +226,7 @@ func (screen *TouchScreen) Close() {
|
||||
if screen == nil || screen.file == nil {
|
||||
return
|
||||
}
|
||||
zero := int32(0)
|
||||
_ = ioctl(screen.fd, ioc(iocWrite, 0x90, 4), unsafe.Pointer(&zero))
|
||||
_, _, _ = syscall.Syscall(syscall.SYS_IOCTL, uintptr(screen.fd), ioc(iocWrite, 0x90, 4), 0)
|
||||
screen.file.Close()
|
||||
screen.file = nil
|
||||
}
|
||||
@@ -225,6 +237,7 @@ type Tracker struct {
|
||||
device Device
|
||||
width, height float64
|
||||
slot int
|
||||
dropped bool
|
||||
slots []slotState
|
||||
}
|
||||
|
||||
@@ -253,12 +266,19 @@ func (tracker *Tracker) screen(x, y int32) (float64, float64) {
|
||||
// Event handles one input event and appends finished contact changes, which
|
||||
// are only emitted at SYN_REPORT so each frame is consistent.
|
||||
func (tracker *Tracker) Event(kind, code uint16, value int32, out []Contact) []Contact {
|
||||
if tracker.dropped {
|
||||
if kind == evSyn && code == synReport {
|
||||
tracker.dropped = false
|
||||
}
|
||||
return out
|
||||
}
|
||||
switch kind {
|
||||
case evAbs:
|
||||
if code == absMTSlot {
|
||||
if value >= 0 && int(value) < len(tracker.slots) {
|
||||
tracker.slot = int(value)
|
||||
}
|
||||
tracker.slot = int(value)
|
||||
return out
|
||||
}
|
||||
if tracker.slot < 0 || tracker.slot >= len(tracker.slots) {
|
||||
return out
|
||||
}
|
||||
state := &tracker.slots[tracker.slot]
|
||||
@@ -286,15 +306,10 @@ func (tracker *Tracker) Event(kind, code uint16, value int32, out []Contact) []C
|
||||
case synReport:
|
||||
out = tracker.flush(out)
|
||||
case synDropped:
|
||||
// Events were lost. End every contact; the recognizer resets cleanly.
|
||||
for index := range tracker.slots {
|
||||
state := &tracker.slots[index]
|
||||
if state.active {
|
||||
x, y := tracker.screen(state.x, state.y)
|
||||
out = append(out, Contact{Phase: End, ID: state.id, X: x, Y: y})
|
||||
}
|
||||
*state = slotState{}
|
||||
}
|
||||
// Never turn incomplete input into taps or activation.
|
||||
clear(tracker.slots)
|
||||
tracker.slot, tracker.dropped = 0, true
|
||||
out = append(out, Contact{Phase: Cancel})
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestBehaviorTouchWithinOneFrameIsNotReported(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBehaviorDroppedEventsEndEveryContact(t *testing.T) {
|
||||
func TestBehaviorDroppedEventsCancelEveryContact(t *testing.T) {
|
||||
tracker := NewTracker(testDevice, 1920, 1200)
|
||||
var out []Contact
|
||||
for _, e := range [][3]int32{abs(absMTSlot, 0), abs(absMTTrackingID, 1), abs(absMTSlot, 1), abs(absMTTrackingID, 2)} {
|
||||
@@ -93,8 +93,8 @@ func TestBehaviorDroppedEventsEndEveryContact(t *testing.T) {
|
||||
}
|
||||
out = tracker.Event(evSyn, synReport, 0, out)
|
||||
out = tracker.Event(evSyn, synDropped, 0, out[:0])
|
||||
if len(out) != 2 || out[0].Phase != End || out[1].Phase != End {
|
||||
t.Fatalf("want both contacts ended, got %+v", out)
|
||||
if len(out) != 1 || out[0].Phase != Cancel {
|
||||
t.Fatalf("want gesture cancelled, got %+v", out)
|
||||
}
|
||||
out = tracker.Event(evSyn, synReport, 0, out[:0])
|
||||
if len(out) != 0 {
|
||||
@@ -122,3 +122,31 @@ func TestNativeFindTouchScreens(t *testing.T) {
|
||||
t.Fatal("no touch screen found")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroppedFrameIgnoresEventsUntilReport(t *testing.T) {
|
||||
tracker := NewTracker(testDevice, 1920, 1200)
|
||||
tracker.Event(evSyn, synDropped, 0, nil)
|
||||
tracker.Event(evAbs, absMTTrackingID, 42, nil)
|
||||
if got := tracker.Event(evSyn, synReport, 0, nil); len(got) != 0 {
|
||||
t.Fatalf("incomplete frame emitted %+v", got)
|
||||
}
|
||||
tracker.Event(evAbs, absMTTrackingID, 43, nil)
|
||||
if got := tracker.Event(evSyn, synReport, 0, nil); len(got) != 1 || got[0].ID != 43 {
|
||||
t.Fatalf("fresh frame = %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidSlotDoesNotModifyPreviousFinger(t *testing.T) {
|
||||
got := run(t, frame{[][3]int32{abs(absMTTrackingID, 7), abs(absMTPositionX, 200)}},
|
||||
frame{[][3]int32{abs(absMTSlot, 100), abs(absMTTrackingID, -1), abs(absMTPositionX, 3000)}})
|
||||
if len(got) != 1 || got[0].Phase != Begin {
|
||||
t.Fatalf("invalid slot changed valid finger: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHighDescriptorFailsWithoutPanic(t *testing.T) {
|
||||
screen := &TouchScreen{fd: 100000}
|
||||
if _, _, failed := screen.Next(0); !failed {
|
||||
t.Fatal("unsupported descriptor must fail")
|
||||
}
|
||||
}
|
||||
@@ -106,13 +106,24 @@ int cthulhu_touch_key(Display *display, unsigned long keysym, int shift) {
|
||||
KeyCode shiftCode = XKeysymToKeycode(display, XK_Shift_L);
|
||||
if (!code || (shift && !shiftCode)) return 0;
|
||||
cthulhu_x11_begin_read(display);
|
||||
int ok = 1;
|
||||
if (shift) ok = XTestFakeKeyEvent(display, shiftCode, True, CurrentTime);
|
||||
if (ok) {
|
||||
ok = XTestFakeKeyEvent(display, code, True, CurrentTime) &&
|
||||
XTestFakeKeyEvent(display, code, False, CurrentTime);
|
||||
char keys[32];
|
||||
XQueryKeymap(display, keys);
|
||||
// Do not release a physical key or modifier the user is already holding.
|
||||
if (keys[code / 8] & (1 << (code % 8))) {
|
||||
cthulhu_x11_end_read(display);
|
||||
return 0;
|
||||
}
|
||||
if (shift) XTestFakeKeyEvent(display, shiftCode, False, CurrentTime);
|
||||
KeyCode rightShift = XKeysymToKeycode(display, XK_Shift_R);
|
||||
int ownShift = shift && !(keys[shiftCode / 8] & (1 << (shiftCode % 8))) &&
|
||||
!(rightShift && (keys[rightShift / 8] & (1 << (rightShift % 8))));
|
||||
int ok = 1;
|
||||
if (ownShift) ok = XTestFakeKeyEvent(display, shiftCode, True, CurrentTime);
|
||||
if (ok) {
|
||||
int pressed = XTestFakeKeyEvent(display, code, True, CurrentTime);
|
||||
int released = XTestFakeKeyEvent(display, code, False, CurrentTime);
|
||||
ok = pressed && released;
|
||||
}
|
||||
if (ownShift) XTestFakeKeyEvent(display, shiftCode, False, CurrentTime);
|
||||
XSync(display, False);
|
||||
if (cthulhu_x11_end_read(display)) ok = 0;
|
||||
return ok;
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestNativeWindowLocatorFallbackReleasesGuard(t *testing.T) {
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
client := exec.CommandContext(ctx, "xterm", "-geometry", "40x10+100+100", "-class", "CthulhuTouchFixture")
|
||||
client := exec.CommandContext(ctx, "xterm", "-T", "Touch fixture", "-geometry", "40x10+100+100", "-class", "CthulhuTouchFixture")
|
||||
if err := client.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -75,3 +75,37 @@ func TestNativeWindowLocatorFallbackReleasesGuard(t *testing.T) {
|
||||
t.Fatal("window lookup left the X11 guard held")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNativeTouchKeyPreservesHeldKeys(t *testing.T) {
|
||||
if os.Getenv("CTHULHU_NATIVE_X11") != "1" {
|
||||
t.Skip("requires isolated X11 display")
|
||||
}
|
||||
target, err := openRemoteKeyTarget()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer target.close()
|
||||
locator := OpenWindowLocator()
|
||||
if locator == nil {
|
||||
t.Fatal("no locator")
|
||||
}
|
||||
defer locator.Close()
|
||||
for _, name := range []string{"Shift_L", "Shift_R", "Tab"} {
|
||||
code, err := target.backend.Resolve(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := target.backend.Set(code, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ok := locator.Key(KeyTab, true)
|
||||
held, err := target.backend.Held(code)
|
||||
target.backend.Set(code, false)
|
||||
if err != nil || !held {
|
||||
t.Fatalf("touch released held %s: %v", name, err)
|
||||
}
|
||||
if ok == (name == "Tab") {
|
||||
t.Fatalf("key result for held %s = %v", name, ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (cursor *Cursor) adjacentLocked(reference atspi.ObjectReference, forward bo
|
||||
if child, ok, err := tree.FirstChild(reference); err != nil || ok {
|
||||
return child, ok, err
|
||||
}
|
||||
for node := reference; ; {
|
||||
for node, depth := reference, 0; depth < maxItemSteps; depth++ {
|
||||
top, err := cursor.topLevelLocked(node)
|
||||
if err != nil || top {
|
||||
return atspi.ObjectReference{}, false, err
|
||||
@@ -64,6 +64,7 @@ func (cursor *Cursor) adjacentLocked(reference atspi.ObjectReference, forward bo
|
||||
}
|
||||
node = parent
|
||||
}
|
||||
return atspi.ObjectReference{}, false, nil
|
||||
}
|
||||
top, err := cursor.topLevelLocked(reference)
|
||||
if err != nil || top {
|
||||
|
||||
@@ -21,7 +21,7 @@ import "strings"
|
||||
|
||||
const Name = "Cthulhu"
|
||||
|
||||
const Version = "2026.11.19"
|
||||
const Version = "2026.11.24"
|
||||
const Channel = "testing"
|
||||
|
||||
var Build = Version
|
||||
|
||||
Reference in new issue
Block a user