Commit 137335a3 authored by Olivier Fourdan's avatar Olivier Fourdan

a11y: apply scale to widget extents

At-spi registry can be used to generate pointer events based on ATK's
reported widget size and position.

If the surface is scaled, the reported values need to be scaled with the
same factor otherwise the coordinates won't match.

Closes: GNOME/gtk#1505
parent fcecc761
Pipeline #45121 passed with stage
in 16 minutes and 2 seconds
......@@ -575,14 +575,17 @@ gtk_widget_accessible_get_extents (AtkComponent *component,
gint x_toplevel, y_toplevel;
GtkWidget *widget;
GtkAllocation allocation;
gint scale;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
if (widget == NULL)
return;
gtk_widget_get_allocation (widget, &allocation);
*width = allocation.width;
*height = allocation.height;
scale = gtk_widget_get_scale_factor (widget);
*width = allocation.width * scale;
*height = allocation.height * scale;
if (!gtk_widget_accessible_on_screen (widget) || (!gtk_widget_is_drawable (widget)))
{
*x = G_MININT;
......@@ -606,6 +609,9 @@ gtk_widget_accessible_get_extents (AtkComponent *component,
*x += x_window;
*y += y_window;
*x *= scale;
*y *= scale;
if (coord_type == ATK_XY_WINDOW)
{
window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
......@@ -660,6 +666,7 @@ gtk_widget_accessible_set_extents (AtkComponent *component,
AtkCoordType coord_type)
{
GtkWidget *widget;
gint scale;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
if (widget == NULL)
......@@ -668,27 +675,28 @@ gtk_widget_accessible_set_extents (AtkComponent *component,
if (!gtk_widget_is_toplevel (widget))
return FALSE;
scale = gtk_widget_get_scale_factor (widget);
if (coord_type == ATK_XY_WINDOW)
{
gint x_current, y_current;
GdkWindow *window = gtk_widget_get_window (widget);
gdk_window_get_origin (window, &x_current, &y_current);
x_current += x;
y_current += y;
x_current += x / scale;
y_current += y / scale;
if (x_current < 0 || y_current < 0)
return FALSE;
else
{
gtk_window_move (GTK_WINDOW (widget), x_current, y_current);
gtk_widget_set_size_request (widget, width, height);
gtk_widget_set_size_request (widget, width / scale, height / scale);
return TRUE;
}
}
else if (coord_type == ATK_XY_SCREEN)
{
gtk_window_move (GTK_WINDOW (widget), x, y);
gtk_widget_set_size_request (widget, width, height);
gtk_widget_set_size_request (widget, width / scale, height / scale);
return TRUE;
}
return FALSE;
......
......@@ -385,6 +385,7 @@ gtk_window_accessible_get_extents (AtkComponent *component,
GdkWindow *window;
GdkRectangle rect;
gint x_toplevel, y_toplevel;
gint scale;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
if (widget == NULL)
......@@ -404,9 +405,10 @@ gtk_window_accessible_get_extents (AtkComponent *component,
return;
gdk_window_get_frame_extents (window, &rect);
scale = gtk_widget_get_scale_factor (widget);
*width = rect.width;
*height = rect.height;
*width = rect.width * scale;
*height = rect.height * scale;
if (!gtk_widget_is_drawable (widget))
{
*x = G_MININT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment