Sometimes when switching from steam to a different workspace and back only the outer window takes focus so some actions don't work. Tentative fix for that.
This commit is contained in:
1 parent
9205e7280a
commit
12c514aab0
19 files changed
+798
-30
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/atspi"
|
||||
"git.stormux.org/storm/cthulhu/internal/config"
|
||||
"git.stormux.org/storm/cthulhu/internal/input"
|
||||
"git.stormux.org/storm/cthulhu/internal/platform/xorg"
|
||||
"git.stormux.org/storm/cthulhu/internal/preferences"
|
||||
)
|
||||
@@ -80,6 +81,90 @@ func TestAutomaticTitlePolicyCoalescesAndPreservesSpeech(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestScheduledTitleInterruptedBeforeSpeechQueue(t *testing.T) {
|
||||
for _, name := range []string{"c", "Tab", "Control_L", "Escape"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
titles, queue, changed := titleControllerFixture(t)
|
||||
tracker := &input.IntentTracker{}
|
||||
titles.inputSource = tracker
|
||||
changed.Source.Name = "Scheduled status"
|
||||
titles.accessible(changed)
|
||||
tracker.Observe(input.NewKeyEvent(0, true, name))
|
||||
// A newer sample in the same burst must not undo cancellation.
|
||||
changed.Source.Name = "Latest status"
|
||||
titles.accessible(changed)
|
||||
titles.flush()
|
||||
if len(queue.requests) != 0 || titles.pending != nil {
|
||||
t.Fatal("interrupted title reached the speech queue")
|
||||
}
|
||||
// A genuinely later change still announces normally.
|
||||
changed.Source.Name = "New status"
|
||||
titles.accessible(changed)
|
||||
titles.flush()
|
||||
if len(queue.requests) != 1 || queue.requests[0].Text != "New status" {
|
||||
t.Fatalf("later title = %+v", queue.requests)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestScheduledNativeIntroductionPreservesSwitchAndRepeatInput(t *testing.T) {
|
||||
titles, queue, _ := titleControllerFixture(t)
|
||||
titles.state.owner.clear()
|
||||
tracker := &input.IntentTracker{}
|
||||
titles.inputSource = tracker
|
||||
source := &titleProbeSource{title: atspi.ForegroundTitle{Epoch: 1, Title: xorg.WindowTitle{Window: 20, TitleWindow: 20, Title: "Other window"}}}
|
||||
titles.source, titles.foreground = source, source
|
||||
// Input initiating a switch precedes discovery of its destination title.
|
||||
tracker.Observe(input.NewKeyEvent(0, true, "Tab"))
|
||||
titles.nativeChanged()
|
||||
repeat := input.NewKeyEvent(0, true, "Tab")
|
||||
repeat.Repeat = true
|
||||
tracker.Observe(repeat)
|
||||
titles.flush()
|
||||
if len(queue.requests) != 1 || queue.requests[0].Text != "Other window" {
|
||||
t.Fatalf("destination title = %+v", queue.requests)
|
||||
}
|
||||
// Fresh typing after a subsequent switch cancels its delayed introduction.
|
||||
source.title.Epoch++
|
||||
source.title.Title.Window, source.title.Title.TitleWindow = 21, 21
|
||||
source.title.Title.Title = "Next window"
|
||||
titles.nativeChanged()
|
||||
tracker.Observe(input.NewKeyEvent(0, true, "c"))
|
||||
repeat = input.NewKeyEvent(0, true, "c")
|
||||
repeat.Repeat = true
|
||||
tracker.Observe(repeat)
|
||||
titles.flush()
|
||||
if len(queue.requests) != 1 {
|
||||
t.Fatal("typing interruption was hidden by its later repeat")
|
||||
}
|
||||
// Returning to that window must introduce it again despite cancellation.
|
||||
source.title.Epoch++
|
||||
titles.nativeChanged()
|
||||
titles.flush()
|
||||
if len(queue.requests) != 2 || queue.requests[1].Text != "Next window" {
|
||||
t.Fatalf("return title = %+v", queue.requests)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScheduledTitleCannotReviveWhileWaitingForSettings(t *testing.T) {
|
||||
titles, queue, changed := titleControllerFixture(t)
|
||||
tracker := &input.IntentTracker{}
|
||||
titles.inputSource = tracker
|
||||
titles.live.onApplication = func(string) {}
|
||||
titles.application = "Example Application"
|
||||
changed.Source.Name = "Pending application title"
|
||||
titles.accessible(changed)
|
||||
titles.flush() // Requeued until the application override is committed.
|
||||
tracker.Observe(input.NewKeyEvent(0, true, "c"))
|
||||
application := titles.application
|
||||
titles.live.application.Store(&application)
|
||||
titles.flush()
|
||||
if len(queue.requests) != 0 || titles.pending != nil {
|
||||
t.Fatal("settings retry revived an interrupted title")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutomaticTitleUsesBrailleMessagePathAndKeepsFocus(t *testing.T) {
|
||||
titles, queue, changed := titleControllerFixture(t)
|
||||
display := &flashRecorder{}
|
||||
|
||||
Reference in new issue
Block a user