diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2023-02-02 15:43:29 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2023-02-03 11:49:17 +0100 |
commit | 3015b9f12071879dd9b071287c21b25bc030cb60 (patch) | |
tree | f659d7bedd20b1b9a1fa9d945fa66328e5667e50 | |
parent | 01549e3c91aa823f077cf11a026675577153c01e (diff) | |
download | gtk+-3015b9f12071879dd9b071287c21b25bc030cb60.tar.gz |
a11y: Fix get_bounds() implementation
Don't allocate graphene_rect_t, and fix the size retrieval.
-rw-r--r-- | gtk/gtkwidget.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4e067f14e7..ab75402d8c 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8494,19 +8494,18 @@ gtk_widget_accessible_get_bounds (GtkAccessible *self, GtkWidget *parent; GtkWidget *bounds_relative_to; double translated_x, translated_y; - graphene_rect_t *bounds; - + graphene_rect_t bounds = GRAPHENE_RECT_INIT_ZERO; + widget = GTK_WIDGET (self); if (!gtk_widget_get_realized (widget)) - return false; + return FALSE; parent = gtk_widget_get_parent (widget); - - if (parent) + if (parent != NULL) { gtk_widget_translate_coordinates (widget, parent, 0., 0., &translated_x, &translated_y); - *x = (int)translated_x; - *y = (int)translated_y; + *x = floorf (translated_x); + *y = floorf (translated_y); bounds_relative_to = parent; } else @@ -8515,14 +8514,18 @@ gtk_widget_accessible_get_bounds (GtkAccessible *self, bounds_relative_to = widget; } - bounds = graphene_rect_alloc (); - if (!gtk_widget_compute_bounds (widget, bounds_relative_to, bounds)) - *width, *height = 0; - *width = (int)graphene_rect_get_width (bounds); - *height = (int)graphene_rect_get_height (bounds); - graphene_rect_free (bounds); + if (!gtk_widget_compute_bounds (widget, bounds_relative_to, &bounds)) + { + *width = 0; + *height = 0; + } + else + { + *width = ceilf (graphene_rect_get_width (&bounds)); + *height = ceilf (graphene_rect_get_height (&bounds)); + } - return true; + return TRUE; } static void |