a11y: Expose the Component object for GtkAtSpiSocket
This allows reporting the proper geometry for the AT. This is a simple implementation that simply uses the extents of the first GtkWidget that is parent of the GtkAtSpiSocket accessible. GTK does not support completely detached accessible trees, so a parent GtkWidget is guaranteed to exist. Assert that in code.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "gtkatspicontextprivate.h"
|
||||
#include "gtkatspiprivate.h"
|
||||
#include "gtkatspisocket.h"
|
||||
#include "gtkatspiutilsprivate.h"
|
||||
#include "gtkaccessibleprivate.h"
|
||||
#include "gtkpopover.h"
|
||||
@@ -36,6 +37,24 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
static GtkWidget *
|
||||
find_first_accessible_widget (GtkAccessible *accessible)
|
||||
{
|
||||
GtkAccessible *parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
|
||||
while (parent != NULL)
|
||||
{
|
||||
g_object_unref (parent);
|
||||
|
||||
if (GTK_IS_WIDGET (parent))
|
||||
return GTK_WIDGET (parent);
|
||||
|
||||
parent = gtk_accessible_get_accessible_parent (parent);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
translate_coordinates_to_widget (GtkWidget *widget,
|
||||
AtspiCoordType coordtype,
|
||||
@@ -122,7 +141,16 @@ component_handle_method (GDBusConnection *connection,
|
||||
{
|
||||
GtkATContext *self = user_data;
|
||||
GtkAccessible *accessible = gtk_at_context_get_accessible (self);
|
||||
GtkWidget *widget = GTK_WIDGET (accessible);
|
||||
GtkWidget *widget;
|
||||
|
||||
if (GTK_IS_WIDGET (accessible))
|
||||
widget = GTK_WIDGET (accessible);
|
||||
else if (GTK_IS_AT_SPI_SOCKET (accessible))
|
||||
widget = find_first_accessible_widget (accessible);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
g_assert (widget != NULL);
|
||||
|
||||
if (g_strcmp0 (method_name, "Contains") == 0)
|
||||
{
|
||||
@@ -249,7 +277,7 @@ static const GDBusInterfaceVTable component_vtable = {
|
||||
const GDBusInterfaceVTable *
|
||||
gtk_atspi_get_component_vtable (GtkAccessible *accessible)
|
||||
{
|
||||
if (GTK_IS_WIDGET (accessible))
|
||||
if (GTK_IS_WIDGET (accessible) || GTK_IS_AT_SPI_SOCKET (accessible))
|
||||
return &component_vtable;
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user