Fix GTK 4 foreground matching and menu labels

This commit is contained in:
Chase Cichorz authored and Angus Kola committed 2026-11-07 13:40:23 -05:00
1 parent d0c977281d
commit 49eeae89f4
8 files changed
+254 -9

No files matched your search

+10 -5
View File
@@ -58,9 +58,11 @@ gint cthulhu_document_action_priority(AtspiAccessible *source, const gchar *name
return 0;
}
// Some toolkits expose an edit field's label only as a relation, leaving its
// accessible name empty. Follow direct targets only, with a shared query and
// output budget; never infer a label from neighbouring controls or field text.
// Some toolkits expose an edit field's or menu item's label only as a
// relation, leaving its accessible name empty. GTK 4 popover menu items point
// at an internal label whose role is invalid, so read that target's text too.
// Follow direct targets only, with a shared query and output budget; never
// infer a label from neighbouring controls or field text.
static gchar *cthulhu_text_control_label(AtspiAccessible *source) {
GArray *relations = atspi_accessible_get_relation_set(source, NULL);
if (relations == NULL) return NULL;
@@ -79,7 +81,8 @@ static gchar *cthulhu_text_control_label(AtspiAccessible *source) {
if (role != ATSPI_ROLE_PASSWORD_TEXT) {
text = atspi_accessible_get_name(target, NULL);
if ((text == NULL || *text == '\0') &&
(role == ATSPI_ROLE_LABEL || role == ATSPI_ROLE_STATIC)) {
(role == ATSPI_ROLE_LABEL || role == ATSPI_ROLE_STATIC ||
role == ATSPI_ROLE_INVALID)) {
g_free(text);
AtspiText *labelText = atspi_accessible_get_text(target);
if (labelText != NULL) {
@@ -504,7 +507,9 @@ cthulhu_snapshot cthulhu_capture_snapshot(AtspiAccessible *source, gboolean capt
}
if (!snapshot.defunct && (snapshot.name == NULL || *snapshot.name == '\0') &&
(g_strcmp0(snapshot.role, "text") == 0 || g_strcmp0(snapshot.role, "entry") == 0 ||
g_strcmp0(snapshot.role, "password text") == 0)) {
g_strcmp0(snapshot.role, "password text") == 0 || g_strcmp0(snapshot.role, "menu item") == 0 ||
g_strcmp0(snapshot.role, "check menu item") == 0 ||
g_strcmp0(snapshot.role, "radio menu item") == 0)) {
g_free(snapshot.name);
snapshot.name = cthulhu_text_control_label(source);
}