Commit Graph

933 Commits

Author SHA1 Message Date
Emmanuele Bassi
e600a07237 a11y: Skip atspi.Cache signals for hidden elements
If the accessible object is hidden, we can skip the emission of the
AddAccessible and RemoveAccessible signals on the cache, as those
objects won't be visible in the accessibility tree.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
d436c2e839 a11y: Remove weak ref from atspi.Cache
The GtkAtSpiContext is responsible for removing itself from the root,
which will remove itself from the cache. Any code path that leads to the
GtkAtSpiContext instance being collected passes through the
unrealization phase, which will also unregister the context from the
accessibility bus and from the cache.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
b37634dcd5 a11y: Add a fallback for the root base path
In case g_get_prgname() returns NULL, which seems to be the case for the
GTK tests.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
2d636fdda0 a11y: Reuse the generated AT-SPI interface name
We already have the name available.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
28095641c5 a11y: Use the appropriate GVariant for cache signals
We need to wrap the argument for AddAccessible and RemoveAccessible into
a tuple, as that's what GDBus expects.
2020-11-19 12:14:55 +00:00
Emmanuele Bassi
bb1463871c a11y: Ensure valid object paths in the fallback code
When falling back to using the program name to create a unique base path
for the objects on the accessibility bus we need to ensure that the name
is a valid DBus object path.
2020-11-16 17:47:15 +00:00
Emmanuele Bassi
9de2b4b0e1 a11y: Implement atspi.Cache
The AT-SPI cache interface is used to quickly populate the accessible
objects tree.

The tricky bit is ensuring that we emit change notifications on the
cache only when the cache is available, which means waiting until the
root is asynchronously registered.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
ee056fd8bd a11y: Update the Cache interface introspection
The type for cached items is, unsurprisingly, wrong when compared to the
implementation inside atk-spi2-atk.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
bc4f71a107 a11y: Add getters for GtkAtSpiContext
We are going to use them in order to implement atspi.Cache.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
eec92b40ea a11y: Compute the base path in the root object
The root path is shared by all AtSpiContext instances, so we should
compute it once, instead of every time we instantiate a new context.

This allows us to defer the path creation at realization time and ensure
that we have a registered application.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
d392f6f2a4 a11y: Resync the AT-SPI XML
Mostly just changes in the annotations coming from at-spi2-core, but
it's good to try and keep the XML in sync.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
abc9b403f8 a11y: Implement atspi.Text.ScrollSubstringTo for GtkTextView
We reuse the existing implementation in GTK3.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
61e980bfb6 a11y: Add accessible actions to GtkSearchEntry
Just like GtkPasswordEntry, GtkSearchEntry should have its set of
accessible actions.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
429c7fc039 a11y: Add role exception for GtkScrolledWindow
ARIA does not have a "scroll pane" role, but AT-SPI does.
2020-11-12 21:46:05 +00:00
Emmanuele Bassi
2285382074 a11y: Create AtSpiRoot on realization
There's no need to do a lot of work on construction, if we're delaying
all remote work after the GtkATContext is realized.

The GtkAtSpiContext should also keep a reference on the root, and drop
it at unrealize time.
2020-11-11 18:46:44 +00:00
Emmanuele Bassi
033791b374 a11y: Translate ARIA windows to AT-SPI frames
For backward compatibility with GTK3.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
95ee5ff424 a11y: Add more ARIA/AT-SPI role translations 2020-11-11 18:33:15 +00:00
Emmanuele Bassi
65d29e00c7 a11y: Realize parent ATContext for the stack page
Just like for popovers, the stack page is not directly connected on the
widget's DOM, so we need to realize the parent ATContext ourselves.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
3b2cd972d5 a11y: Implement missing atspi.Component getters
Some of them are entirely innocuous, and we can easily provide values
that match what GTK3 provides.
2020-11-11 18:33:15 +00:00
Matthias Clasen
5379a4bf34 a11y: Clean up properly in unregister_object
Things that are set up in register_object should
be cleaned up in unregister_object.
2020-11-09 18:48:10 -05:00
Emmanuele Bassi
7dfa41bbc4 a11y: ARIA's "presentation" role maps to ATSPI_ROLE_SECTION
See the mapping role table in the Core-AAM normative document:

https://w3c.github.io/core-aam/#mapping_role_table
2020-11-05 13:14:08 +00:00
Emmanuele Bassi
66bba1493e a11y: Remove stray g_printerr() 2020-11-04 19:39:08 +00:00
Emmanuele Bassi
ba63aa76ca a11y: Move parent context ref getter to its own function
Keeps the body of handle_accessible_get_property() readable.
2020-11-04 17:16:24 +00:00
Emmanuele Bassi
30210c7087 a11y: Move ATContext to an explicit realization model
We are doing too much work during the construction phase of the
AT-SPI backend for GtkATContext. Instead of having the AtSpiContext
register itself at construction time, let's add explicit realize
and unrealize operations, and connect the ATContext realization to the
rooting operation of a GtkWidget.
2020-11-04 15:02:44 +00:00
Matthias Clasen
d5b9489408 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #3282

See merge request GNOME/gtk!2755
2020-10-27 22:38:58 +00:00
Matthias Clasen
8df883ed71 Merge branch 'matthiasc/atspi-child' into 'master'
Emit ChildrenChanged signal on hierarchy updates

See merge request GNOME/gtk!2752
2020-10-27 18:24:43 +00:00
Matthias Clasen
adb7676fc1 a11y: More State<>Change confusion
We should really avoid this needless duplication
- the 'state' is never stored anywhere.
2020-10-24 23:12:36 -04:00
Matthias Clasen
8ffb398517 a11y: Handle all cases for state change
Make state_change handle state changes for non-widgets,
and handle the cases for HIDDEN involving stack pages.
2020-10-24 22:05:17 -04:00
Matthias Clasen
7c106578ed Cosmetics
Make gtk_at_spi_root_child_changed take a
GtkAccessible for the child.
2020-10-24 21:35:35 -04:00
Matthias Clasen
2546b88661 a11y: Redo child-added/-removed for toplevels
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.
2020-10-24 15:26:12 -04:00
Matthias Clasen
274f9ad919 a11y: Emit child notification when toplevels get hidden
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.
2020-10-24 13:17:20 -04:00
Matthias Clasen
89a8c89663 a11y: Improve child index helpers
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.
2020-10-24 13:14:44 -04:00
Matthias Clasen
e7b290debb a11y: Improve child notification for toplevels
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.
2020-10-24 13:13:07 -04:00
Matthias Clasen
46e754a17d a11y: Skip non-presented children when required
Whenever we determine the index of a child, we need
to skip its non-presented siblings.
2020-10-24 11:22:09 -04:00
Matthias Clasen
b12992c1cb a11y: Handle HIDDEN state changes
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.
2020-10-24 11:17:56 -04:00
Timm Bäder
6dcdb4a601 atspitextbuffer: Explicitly cast between pango and gtk enums 2020-10-22 17:46:34 +02:00
Timm Bäder
41ef1d87ef atspicontext: Add a few missing break statements 2020-10-22 17:46:34 +02:00
Matthias Clasen
a11ab6c995 a11y: Handle stack case for addition/removal
Since we interpose stack pages as non-widget accessibles,
we need to tweak the signals we emit when their corresponding
widgets get added or removed.
2020-10-22 10:06:06 -04:00
Matthias Clasen
ba290eb9b0 a11y: Add actions for color swatches
Add the same actions that we exported in GTK 3.
2020-10-21 23:36:22 -04:00
Matthias Clasen
88eb3a9c34 atspi: Give model buttons a click action too
GtkModelButton is no longer derived from GtkButton,
but can still treat it like a button for the purposes
of having a click action. This lets ATs activate
menu items again.
2020-10-21 21:27:38 -04:00
Emmanuele Bassi
e45dd771db a11y: Emit ChildrenChanged for toplevel list changes
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.
2020-10-21 15:37:57 +01:00
Emmanuele Bassi
698cbee1fb a11y: Move ChildrenChanged emitter to ATSPI utilities
We are going to use it from GtkAtSpiRoot, which is not a
GtkAtSpiContext.
2020-10-21 15:18:23 +01:00
Emmanuele Bassi
f1e14c4858 a11y: Implement ChildrenChanged atspi.Event 2020-10-21 14:33:20 +01:00
Matthias Clasen
e20a3339bf atsi: Fix emission of text selection changes
We were not emitting text-selection-changed and
text-caret-moved as expected.
2020-10-20 21:31:23 -04:00
Matthias Clasen
eeae1b1ea7 a11y: Fix accessible tree inconsistency
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.
2020-10-19 21:15:44 -04:00
Emmanuele Bassi
51f5690ae3 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2720
2020-10-19 20:26:57 +00:00
Matthias Clasen
e58e6a0fbe Merge branch 'a11y/editable' into 'master'
Improve the accessible support for editables

See merge request GNOME/gtk!2719
2020-10-19 20:16:21 +00:00
Matthias Clasen
77d1026c5a atspi: Use name and description as provided
GtkATContext already does fallbacks to derive values
for these, so no need for the atspi implementation to
do its own fallback on top of that.
2020-10-19 14:57:43 -04:00
Matthias Clasen
63421b1876 a11y: Rename some methods
Our EditableText implementation works fine for any
editable, so don't name the functions in a way that
looks like they are only for entries.
2020-10-19 12:58:29 -04:00
Emmanuele Bassi
7c7dabae8c a11y: Rework accessible name/description computation
The ARIA spec determines the name and description of accessible elements
in a more complex way that simply mapping to a single property; instead,
it will chain up multiple definitions (if it finds them). For instance,
let's assume we have a button that saves a file selected from a file
selection widget; the widgets have the following attributes:

 - the file selection widget has a "label" attribute set to the
   selected file, e.g. "Final paper.pdf"
 - the "download" button has a "label" attribute set to the
   "Download" string
 - the "download" button has a "labelled-by" attribute set to
   reference the file selection widget

The ARIA spec says that the accessible name of the "Download" button
should be computed as "Download Final paper.pdf".

The algorithm defined in section 4.3 of the WAI-ARIA specification
applies to both accessible names (using the "label" and "labelled-by"
attributes), and to accessible descriptions (using the "description" and
"described-by" attributes).
2020-10-19 17:54:14 +01:00
Matthias Clasen
9f9e7dffef atspi: Implement Text for more editables
Our Text implementation requires that we have
a GtkEditable with a delegate that is a GtkText
widget.

This change make the Text implementation work for
the custom widget in the tagged entry demo.
2020-10-19 12:44:50 -04:00
Matthias Clasen
04a51837f7 atspi: Emit bounds-changed
This is using the new bounds_change vfunc in GtkATContext.
2020-10-19 12:19:55 -04:00
Matthias Clasen
8e4f8a45a9 atspi: Implement Component
Implement the non-questionable parts of the Component interface
for accessibles which are widgets.

This does not include:
 - global coordinates
 - setters
 - scrolling
 - alpha, layers, zorder, and the like
2020-10-19 12:19:55 -04:00
Matthias Clasen
3ad03b1706 a11y: Add a separate vfunc for platform changes
The state_change vfunc is becoming unwieldy. Lets move
the platform changes to their own vfunc, as a start.
2020-10-19 12:09:08 -04:00
Matthias Clasen
dfe00c4ac4 atspi: Be more careful
We have non-widget accessibles now, so guard against
change notification being emitted on them.
2020-10-19 12:09:08 -04:00
Matthias Clasen
5bb656af4c Cosmetics
Add some more fold markers.
2020-10-19 12:08:47 -04:00
Matthias Clasen
469b913cdf Cosmetics 2020-10-19 12:00:53 -04:00
Matthias Clasen
ab61b7b9ae atspi: Properly filter out parent actions
We only want to show relevant, local actions for
widgets, but _gtk_widget_get_action_muxer() will
return the muxer of a parent widget (all the way
up to the toplevel), if the widget does not have
any actions of its own. To detect this situation,
compare what _gtk_widget_get_action_muxer() returns
for the parent widget, and act accordingly.
2020-10-15 21:32:11 -04:00
Matthias Clasen
3eae91255d atspi: Fix a thinko in action filtering
get_action_at_index() was trying hard to find out
which actions are valid, only to then return the
invalid ones anyway.
2020-10-15 21:31:58 -04:00
Emmanuele Bassi
cfb327974b a11y: Add atspi.Action for GtkPasswordEntry 2020-10-16 00:34:01 +01:00
Emmanuele Bassi
f67345eb55 a11y: Add atspi.Action for GtkEntry
We need to handle the activation on the entry widget, as well as the
activation of the primary and secondary icons.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
9ae08fc0f0 a11y: Add atspi.Action for GtkExpander 2020-10-16 00:34:01 +01:00
Emmanuele Bassi
5f1128899c a11y: De-duplicate some action code
The widgets with hard coded actions should share more code, instead of
copy-pasting it.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
e44f27a7ed a11y: Special case buttons and switches
These widgets have specific actions.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
374bd21340 Initial ATSPI Action implementation for widget
Use the actions from the GtkActionMuxer of each widget to populate the
list of actions available.
2020-10-16 00:34:01 +01:00
Matthias Clasen
8a14f019d0 atspi: Add fold markers
This makes it much easier to navigate in these
multi-implementation files.
2020-10-15 13:14:56 -04:00
Matthias Clasen
8701e65635 atspi: Implement Selection more correctly
The Selection interface is defined in terms of child
positions, so we need to always translate from that
to model positions if we want to use the selection
model apis.
2020-10-15 12:46:52 -04:00
Matthias Clasen
5f22ad8848 Remove debug spew 2020-10-15 12:19:58 -04:00
Matthias Clasen
8737692b2b atspi: Implement Selection for list views
This implementation works for both GtkListView and
GtkGridView, and by extension, also for GtkColumnView
and GtkDropDown, since those just use a list view
internally.
2020-10-15 08:35:06 -04:00
Matthias Clasen
f4f732694a atspi: Add some docs
Add a comment that explains a few of the more subtle
points of the Atspi context tree contstruction.
2020-10-14 21:04:25 -04:00
Matthias Clasen
bf04beb711 atspi: Implement Selection for notebook tabs
This is a bit different from the way things were done
in GTK 3 - we follow what was done for GtkStackSwitcher,
and make the tab bar carry the GTK_ACCESSIBLE_TAB_LIST
role, and implement Selection there.
2020-10-14 21:04:25 -04:00
Matthias Clasen
41d4c37563 atspi: Don't crash on unnamed stack pages
GtkNotebook creates unnamed stack pages, and we should
not crash when that happens.
2020-10-14 21:04:25 -04:00
Matthias Clasen
512387afcc atspi: Implement Selection for GtkStackSwitcher 2020-10-14 21:04:25 -04:00
Matthias Clasen
7c6c718e19 stack: Turn pages into accessibles
This requires some cleanup to remove assumptions
about accessibles being widgets in the backend,
and some code to navigate the tree with these
extra objects in between widgets.

The accessibles for stack pages have the role
GTK_ACCESSIBLE_ROLE_TAB_PANEL. This is the first
step towards implementing the tabs patterns
as described in the aria authoring guidelines
for GtkStack.
2020-10-14 21:04:17 -04:00
Matthias Clasen
b818b34143 Cosmetics
Fix a few copy-paste errors.
2020-10-13 21:27:56 -04:00
Matthias Clasen
32d8db103a Cosmetics
Avoid typo-prone repetition of the full interface names.
We have them in the introspection data already.
2020-10-13 18:58:25 -04:00
Matthias Clasen
b15328e0d6 atspi: Implement Selection for GtkFlowBox
This is a copy of the listbox implementation.
2020-10-13 17:24:06 -04:00
Matthias Clasen
db97f99359 atspi: Implement Selection for GtkComboBox
This doesn't really work in Accerciser. But then,
neither does the GTK 3 implementation from which
this is copied.
2020-10-13 17:24:06 -04:00
Matthias Clasen
caeea0e368 Remove excessively spammy debug messages
Non need to announce the same things for every context
we create, and the path is not really that interesting.
without knowing what it belongs to. I would suggest to
make it visible in the inspector instead, so you can
look it up for the widgets you are interested in.
2020-10-13 17:24:06 -04:00
Matthias Clasen
d0753f645e Fix compiler warnings 2020-10-13 17:24:06 -04:00
Matthias Clasen
81e107885c Remove some unused code 2020-10-13 17:24:06 -04:00
Matthias Clasen
8f4bc4a65d atspi: Fix a variant parser oversight
When you pass a variant, the format needs an @.
GVariant is not your friend.
2020-10-13 17:24:06 -04:00
Matthias Clasen
08f57d5c3d atspi: Implement Selection for listbox
Implement the selection interface for GtkListBox.

This also includes a convenience api for context
addresses: gtk_at_spi_context_to_ref.
2020-10-13 17:24:06 -04:00
Matthias Clasen
b909455154 atspi: Fix up the role for password entries
We use to set the the 'password text' role for entries with
visibility = FALSE. Nowadays, we have a separate class for
password entries, so fix up the role mapping based on that.
2020-10-13 10:52:43 -04:00
Matthias Clasen
bf0f3a82cf atspi: Make text change notification work
Make text change notification work for editables, by connecting
to the ::insert-text and ::delete-text signals on the wrapped
GtkText widget, and for GtkTextView by connecting to the
corresponding GtkTextBuffer signals.

This code is more or less directly copied from GtkTextViewAccessible
and GtkEntryAccessible in GTK 3.
2020-10-13 09:44:04 -04:00
Matthias Clasen
81440675af atspi: Set placeholder-text attribute
This is how GTK3 passes placeholder-text to orca,
and it works - orca reads it.
2020-10-12 23:31:03 -04:00
Matthias Clasen
3af56f5216 atspi: Implement EditableText interface for the entry wrappers
Drop the EditableText implementation for GtkText,
and implement it for all the wrapper widgets instead.
2020-10-12 22:07:18 -04:00
Matthias Clasen
b7ac660f37 atspi: Implement Text interface for the entry wrappers
Drop the Text implementation for GtkText, and implement
it for all the wrapper widgets instead.
2020-10-12 21:45:48 -04:00
Matthias Clasen
d0d7848cf2 atspi: Use gtk_accessible_get_platform_state 2020-10-12 21:45:48 -04:00
Matthias Clasen
663934b2dc atspi: Use gtk_accessible_should_present
Replace explicit visibility check by this
more general method of determining whether
an accessible should be presented to the
a11y layer.
2020-10-12 21:43:17 -04:00
Matthias Clasen
5eb482ebaa atspi: Treat all entries the same for collecting state
We are determining editable state based on the
accessible role (although we could make it platform
state now), so cover all the roles that we use for
entry wrappers.
2020-10-12 21:43:17 -04:00
Matthias Clasen
61474b5a94 atspi: Fix collecting states
This is somewhat embarrassing.
2020-10-12 21:42:51 -04:00
Matthias Clasen
8f63443393 Fix the build 2020-10-12 21:37:09 -04:00
Matthias Clasen
dd650ff90e atspi: D-Bus methods return tuples
I've learned this the hard way: When returning a
value from a D-Bus call, the variant construct must
*always* be g_variant_new ("(...)"...
2020-10-12 15:50:36 -04:00
Matthias Clasen
101cbe690e Don't unref a floating variant
It gets consumed somewhere along the way.
2020-10-12 15:10:40 -04:00
Matthias Clasen
62747eb243 atspi: Unregister objects on the bus
When a widget is going away, we need to remove
the context from the bus, or else ATs might have
the idea to call methods on them, leading to badness.
2020-10-12 15:10:40 -04:00
Matthias Clasen
d432cbb02b atspi: Emit property changes for focus
With this orca, actually speaks \o/.  Sadly, it only
says 'gtk modelbutton widget' so far, but its a start.
2020-10-12 15:10:40 -04:00
Matthias Clasen
45e82adf87 atspi: Cosmetics
Use simple wrappers instead of opencoding bit twiddling
all over the place.
2020-10-12 15:10:40 -04:00
Matthias Clasen
b5ee73d299 a11y: Pass on platform changes
Add an enum for 'platform changes' to the at context
change notification mechanism. This will let us pass
along things that ARIA considers 'platform state' such
as focus or editability. The difference between the
platform state and other ARIA states is that we don't
keep the platform state separately in the at context
- backends are expected to just query the widgets.

This is just about avoiding notify listeners for
change notification.
2020-10-12 15:10:40 -04:00
Matthias Clasen
578c8b5068 atspi: Be more careful about indexes
Don't return a number for IndexInParent when we
don't have one.
2020-10-12 15:10:40 -04:00