Another problem exposed and fixed on Slint.
This commit is contained in:
1 parent
92d6ad3cc4
commit
6df27c88de
3 files changed
+21
-10
No files matched your search
@@ -229,6 +229,22 @@ func (adapter *Adapter) captureNativeEventSnapshot(event *C.AtspiEvent, target *
|
|||||||
return snapshot, popupFor
|
return snapshot, popupFor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nativeWindowDescription runs on the GLib owner for both toolkit events and
|
||||||
|
// foreground recovery. A table can acquire focus before its frame cache is ready.
|
||||||
|
func nativeWindowDescription(window *C.AtspiAccessible, eventType, role string) string {
|
||||||
|
description := C.atspi_accessible_get_description(window, nil)
|
||||||
|
if (description == nil || C.GoString(description) == "") &&
|
||||||
|
(role == "table" || role == "table cell") &&
|
||||||
|
(eventType == WindowActivatedEvent || eventType == FocusEvent || eventType == FocusedStateEvent) {
|
||||||
|
C.g_free(C.gpointer(description))
|
||||||
|
C.atspi_accessible_clear_cache_single(window)
|
||||||
|
description = C.atspi_accessible_get_description(window, nil)
|
||||||
|
}
|
||||||
|
result := sanitizeSnapshotField(C.GoString(description))
|
||||||
|
C.g_free(C.gpointer(description))
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// enrichNativeWindowEvent queries and releases the window on the GLib owner.
|
// enrichNativeWindowEvent queries and releases the window on the GLib owner.
|
||||||
// It applies foreground, tab/document, table, and prompt state in query order.
|
// It applies foreground, tab/document, table, and prompt state in query order.
|
||||||
func (adapter *Adapter) enrichNativeWindowEvent(event *C.AtspiEvent, target *C.AtspiAccessible, eventType string, snapshot Snapshot, focusEvent *Event) {
|
func (adapter *Adapter) enrichNativeWindowEvent(event *C.AtspiEvent, target *C.AtspiAccessible, eventType string, snapshot Snapshot, focusEvent *Event) {
|
||||||
@@ -271,16 +287,7 @@ func (adapter *Adapter) enrichNativeWindowEvent(event *C.AtspiEvent, target *C.A
|
|||||||
}
|
}
|
||||||
if !focusEvent.ForegroundMismatch && window != nil &&
|
if !focusEvent.ForegroundMismatch && window != nil &&
|
||||||
(eventType == WindowActivatedEvent || snapshot.Role == "table" || snapshot.Role == "table cell") {
|
(eventType == WindowActivatedEvent || snapshot.Role == "table" || snapshot.Role == "table cell") {
|
||||||
description := C.atspi_accessible_get_description(window, nil)
|
focusEvent.WindowDescription = nativeWindowDescription(window, eventType, snapshot.Role)
|
||||||
if (description == nil || C.GoString(description) == "") &&
|
|
||||||
(snapshot.Role == "table" || snapshot.Role == "table cell") &&
|
|
||||||
(eventType == WindowActivatedEvent || eventType == FocusEvent || eventType == FocusedStateEvent) {
|
|
||||||
C.g_free(C.gpointer(description))
|
|
||||||
C.atspi_accessible_clear_cache_single(window)
|
|
||||||
description = C.atspi_accessible_get_description(window, nil)
|
|
||||||
}
|
|
||||||
focusEvent.WindowDescription = sanitizeSnapshotField(C.GoString(description))
|
|
||||||
C.g_free(C.gpointer(description))
|
|
||||||
}
|
}
|
||||||
if !focusEvent.ForegroundMismatch &&
|
if !focusEvent.ForegroundMismatch &&
|
||||||
(eventType == WindowActivatedEvent || eventType == FocusEvent || eventType == FocusedStateEvent ||
|
(eventType == WindowActivatedEvent || eventType == FocusEvent || eventType == FocusedStateEvent ||
|
||||||
|
|||||||
@@ -341,6 +341,7 @@ func (adapter *Adapter) recoverForeground() {
|
|||||||
name := C.atspi_accessible_get_name(window, nil)
|
name := C.atspi_accessible_get_name(window, nil)
|
||||||
event.WindowTitle = sanitizeSnapshotField(C.GoString(name))
|
event.WindowTitle = sanitizeSnapshotField(C.GoString(name))
|
||||||
C.g_free(C.gpointer(name))
|
C.g_free(C.gpointer(name))
|
||||||
|
event.WindowDescription = nativeWindowDescription(window, event.Type, snapshot.Role)
|
||||||
if snapshot.Role == "tree table" || snapshot.Role == "table cell" {
|
if snapshot.Role == "tree table" || snapshot.Role == "table cell" {
|
||||||
if labels := C.cthulhu_collect_simple_prompt_text(window); labels != nil {
|
if labels := C.cthulhu_collect_simple_prompt_text(window); labels != nil {
|
||||||
event.WindowMessage = sanitizeSnapshotField(C.GoString(labels))
|
event.WindowMessage = sanitizeSnapshotField(C.GoString(labels))
|
||||||
|
|||||||
@@ -845,6 +845,9 @@ locked:
|
|||||||
if event.Source.Name != "Alpha" {
|
if event.Source.Name != "Alpha" {
|
||||||
t.Fatalf("unlock focus = %q, want Alpha", event.Source.Name)
|
t.Fatalf("unlock focus = %q, want Alpha", event.Source.Name)
|
||||||
}
|
}
|
||||||
|
if event.WindowDescription != "Select an item and press Enter to open it." {
|
||||||
|
t.Fatalf("recovered window description = %q", event.WindowDescription)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|||||||
Reference in new issue
Block a user