Instead of monitoring the list of toplevels, rely
on GtkWindow updating the HIDDEN state before windows
get removed. This is better, since we still have the
object available when it happens, so we can pass it
to the ATs.
We want to use the HIDDEN state to control when
things get added and removed from the accessible
tree, so ensure that we a) set HIDDEN to true
initially for windows, and b) we update HIDDEN
when a window is shown or hidden.
The second part is handled by gtk_widget_hide
for other widgets, but hiding a window does not
always go through that code path.
When a toplevel window gets hidden (and not destroyed),
the frontend code set the HIDDEN state, and we need to
emit child notification when that happens.
We need to use gtk_accessible_should_present() whenever we
calculate accessible tree positions, to avoid inconsistencies.
While we are at it, make these helpers usable for finding
the position of accesibles that are now ignored, by not
looking at should_present for the object itself. This will
be relevant when we calculate the position of objects whose
HIDDEN state changes.
We need to translate the list model position into
an accessible tree position, since hidden toplevels
will be skipped.
While we are at it, add an api for this notification
that will be used in the next commit.
Hidden elements are not presented in the accessible
tree, so when then HIDDEN state changes, we should
emit child-added or -removed signals.
This commit does not yet handle all cases (HIDDEN
toplevels or hidden stack pages are not handled),
but it should cover the common case.
The ARIA spec is clear on this: when an element has the
HIDDEN state, it should not be presented in the accessible
tree.
This change is incomplete, we also need to emit child-added/
removed signals when the state changes, but that needs to
wait for the child added infrastructure to land.
gtk_widget_reposition_after is called both to add new children,
and to reposition existing children. We only want to emit
accessible changes in the former case (since AT-SPI doesn't
have events for reordering).
Unparent the child widget before tearing down its
stack page. This is necessary so a11y can still access
the stack page accessible to emit change notification
when it learns that the child is removed.
GtkAtSpiRoot is not a context, which means it needs to emit
ChildrenChanged events by itself whenever a toplevel is added to, or
removed from, the list of toplevels.
Show the object path of the object on the a11y bus,
this is can be useful information. While we are here,
make sure that the Inspector does not throw criticals
when used with GTK_NO_A11Y=1.
There were several places where we were confusing
GList and GSList and list->data and list->next, causing
a crash in the accessible name computation for buttons
with mnemonic labels.
Anybody who keeps their own CSS nodes around or wants to order CSS nodes
different from widgets will from now on have to do it manually all the
time.
This is outdated behavior, nobody should be doing either of those two
things.
Also, the correct case is much more common, and not doing it
automatically was causing bugs.
Fixes#3280
The stack page objects were not properly integrated
in the accessible tree - they were appearing as parent
of the pages when navigating up, but not as children
of the stack when navigating down.