diff options
author | Lukáš Tyrychtr <lukastyrychtr@gmail.com> | 2022-09-09 17:02:34 +0200 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2023-02-03 11:49:17 +0100 |
commit | a80af681b840e123743eaba00ff2a23845301d6c (patch) | |
tree | 33a93f810843a6114147cd14cb47e08d886076cc /gtk/a11y | |
parent | 94695bb2768249d2a6ad10c033983353ffc391ef (diff) | |
download | gtk+-a80af681b840e123743eaba00ff2a23845301d6c.tar.gz |
a11y: Skip non-presentable objects
Don't get confused with non-presentable objects when iterating the list
of children.
Diffstat (limited to 'gtk/a11y')
-rw-r--r-- | gtk/a11y/gtkatspicontext.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 034dbdc05a..adddbd5851 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -332,24 +332,27 @@ static int get_index_in (GtkAccessible *parent, GtkAccessible *child) { GtkAccessible *candidate; + int res; int idx; if (parent == NULL) return -1; idx = 0; + res = 0; while (true) { candidate = gtk_accessible_get_child_at_index (parent, idx); if (!candidate) break; if (candidate == child) - return idx; + return res; + idx++; if (!gtk_accessible_should_present (candidate)) continue; - idx++; + res++; } return -1; @@ -489,7 +492,7 @@ handle_accessible_method (GDBusConnection *connection, { GtkATContext *context = NULL; GtkAccessible *accessible; - int idx, real_idx = 0; + int idx, presentable_idx, child_idx; g_variant_get (parameters, "(i)", &idx); @@ -497,17 +500,19 @@ handle_accessible_method (GDBusConnection *connection, GtkAccessible *child; - real_idx = 0; + presentable_idx = 0; + child_idx = 0; do { - child = gtk_accessible_get_child_at_index (accessible, real_idx); + child = gtk_accessible_get_child_at_index (accessible, child_idx); + child_idx += 1; if (!gtk_accessible_should_present (child)) continue; - if (real_idx == idx) + if (presentable_idx == idx) break; + presentable_idx++; - real_idx += 1; } while (child != NULL); @@ -1718,15 +1723,16 @@ gtk_at_spi_context_get_child_count (GtkAtSpiContext *self) GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self)); int n_children = 0; + int idx = 0; GtkAccessible *child; - while (true) { - child = gtk_accessible_get_child_at_index (accessible, n_children); + child = gtk_accessible_get_child_at_index (accessible, idx); if (!child) break; + idx++; if (!gtk_accessible_should_present (child)) continue; |