[gtk/a11y/component] fixup: Add ATSPI_COORD_TYPE_PARENT
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/a11y/component] fixup: Add ATSPI_COORD_TYPE_PARENT
- Date: Wed, 14 Oct 2020 12:19:58 +0000 (UTC)
commit 4d51bad15fc23c32ec6b1b525a607b0f0e7c7fa8
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 14 08:18:09 2020 -0400
fixup: Add ATSPI_COORD_TYPE_PARENT
It is ill-defined, but do something anyway.
The unanswered question here is: what is the parent.
Could be
- the parent accessible (might not have extent)
- the nearest parent Component
- the parent widget
- the parent window (?)
gtk/a11y/gtkatspicomponent.c | 122 +++++++++++++++++++++++++++++++------------
gtk/a11y/gtkatspiprivate.h | 1 +
2 files changed, 89 insertions(+), 34 deletions(-)
---
diff --git a/gtk/a11y/gtkatspicomponent.c b/gtk/a11y/gtkatspicomponent.c
index 26f4b45f83..4f334ca0f2 100644
--- a/gtk/a11y/gtkatspicomponent.c
+++ b/gtk/a11y/gtkatspicomponent.c
@@ -33,6 +33,84 @@
#include <gio/gio.h>
+static void
+translate_coordinates_to_widget (GtkWidget *widget,
+ AtspiCoordType coordtype,
+ int xi,
+ int yi,
+ int *xo,
+ int *yo)
+{
+ double x = xi;
+ double y = yi;
+
+ switch (coordtype)
+ {
+ case ATSPI_COORD_TYPE_SCREEN:
+ g_warning ("Not suppporting screen coordinates, reported positions will be wrong");
+ G_GNUC_FALLTHROUGH;
+
+ case ATSPI_COORD_TYPE_WINDOW:
+ gtk_widget_translate_coordinates (GTK_WIDGET (gtk_widget_get_root (widget)),
+ widget,
+ x, y,
+ &x, &y);
+ break;
+
+ case ATSPI_COORD_TYPE_PARENT:
+ gtk_widget_translate_coordinates (gtk_widget_get_parent (widget),
+ widget,
+ x, y,
+ &x, &y);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ *xo = (int)x;
+ *yo = (int)y;
+}
+
+static void
+translate_coordinates_from_widget (GtkWidget *widget,
+ AtspiCoordType coordtype,
+ int xi,
+ int yi,
+ int *xo,
+ int *yo)
+{
+ double x = xi;
+ double y = yi;
+
+ switch (coordtype)
+ {
+ case ATSPI_COORD_TYPE_SCREEN:
+ g_warning ("Not suppporting screen coordinates, reported positions will be wrong");
+ G_GNUC_FALLTHROUGH;
+
+ case ATSPI_COORD_TYPE_WINDOW:
+ gtk_widget_translate_coordinates (widget,
+ GTK_WIDGET (gtk_widget_get_root (widget)),
+ x, y,
+ &x, &y);
+ break;
+
+ case ATSPI_COORD_TYPE_PARENT:
+ gtk_widget_translate_coordinates (widget,
+ gtk_widget_get_parent (widget),
+ x, y,
+ &x, &y);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ *xo = (int)x;
+ *yo = (int)y;
+}
+
static void
component_handle_method (GDBusConnection *connection,
const gchar *sender,
@@ -52,40 +130,26 @@ g_print ("%s %s\n", interface_name, method_name);
{
int x, y;
AtspiCoordType coordtype;
- double xo, yo;
gboolean ret;
g_variant_get (parameters, "(iiu)", &x, &y, &coordtype);
- if (coordtype != ATSPI_COORD_TYPE_WINDOW)
- g_warning ("Not suppporting screen coordinates, reported positions will be wrong");
-
- gtk_widget_translate_coordinates (GTK_WIDGET (gtk_widget_get_root (widget)),
- widget,
- x, y,
- &xo, &yo);
+ translate_coordinates_to_widget (widget, coordtype, x, y, &x, &y);
- ret = gtk_widget_contains (widget, xo, yo);
+ ret = gtk_widget_contains (widget, x, y);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", ret));
}
else if (g_strcmp0 (method_name, "GetAccessibleAtPoint") == 0)
{
int x, y;
AtspiCoordType coordtype;
- double xo, yo;
GtkWidget *child;
g_variant_get (parameters, "(iiu)", &x, &y, &coordtype);
- if (coordtype != ATSPI_COORD_TYPE_WINDOW)
- g_warning ("Not suppporting screen coordinates, reported positions will be wrong");
+ translate_coordinates_to_widget (widget, coordtype, x, y, &x, &y);
- gtk_widget_translate_coordinates (GTK_WIDGET (gtk_widget_get_root (widget)),
- widget,
- x, y,
- &xo, &yo);
-
- child = gtk_widget_pick (widget, xo, yo, GTK_PICK_DEFAULT);
+ child = gtk_widget_pick (widget, x, y, GTK_PICK_DEFAULT);
if (!child)
{
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", gtk_at_spi_null_ref
()));
@@ -100,36 +164,26 @@ g_print ("%s %s\n", interface_name, method_name);
else if (g_strcmp0 (method_name, "GetExtents") == 0)
{
AtspiCoordType coordtype;
- double x, y;
+ int x, y;
int width = gtk_widget_get_width (widget);
int height = gtk_widget_get_height (widget);
g_variant_get (parameters, "(u)", &coordtype);
- if (coordtype != ATSPI_COORD_TYPE_WINDOW)
- g_warning ("Not suppporting screen coordinates, reported positions will be wrong");
+ translate_coordinates_from_widget (widget, coordtype, 0, 0, &x, &y);
- gtk_widget_translate_coordinates (widget,
- GTK_WIDGET (gtk_widget_get_root (widget)),
- 0., 0.,
- &x, &y);
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("((iiii))", (int)x, (int)y, width,
height));
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("((iiii))", x, y, width, height));
}
else if (g_strcmp0 (method_name, "GetPosition") == 0)
{
AtspiCoordType coordtype;
- double x, y;
+ int x, y;
g_variant_get (parameters, "(u)", &coordtype);
- if (coordtype != ATSPI_COORD_TYPE_WINDOW)
- g_warning ("Not suppporting screen coordinates, reported positions will be wrong");
+ translate_coordinates_from_widget (widget, coordtype, 0, 0, &x, &y);
- gtk_widget_translate_coordinates (widget,
- GTK_WIDGET (gtk_widget_get_root (widget)),
- 0, 0,
- &x, &y);
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("(ii)", (int)x, (int)y));
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(ii)", x, y));
}
else if (g_strcmp0 (method_name, "GetSize") == 0)
{
diff --git a/gtk/a11y/gtkatspiprivate.h b/gtk/a11y/gtkatspiprivate.h
index fc458f41c0..9d3d316354 100644
--- a/gtk/a11y/gtkatspiprivate.h
+++ b/gtk/a11y/gtkatspiprivate.h
@@ -249,6 +249,7 @@ typedef enum {
typedef enum {
ATSPI_COORD_TYPE_SCREEN,
ATSPI_COORD_TYPE_WINDOW,
+ ATSPI_COORD_TYPE_PARENT,
} AtspiCoordType;
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]