Fix GTK 4 foreground matching and menu labels
This commit is contained in:
1 parent
d0c977281d
commit
49eeae89f4
8 files changed
+254
-9
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user