diff options
author | Matthias Clasen <mclasen@redhat.com> | 2023-03-29 21:13:59 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2023-03-29 21:14:24 -0400 |
commit | fc573491b279f359f6f9307b8fdf26836684236e (patch) | |
tree | d20825fe0682893c417d12668f4ecacbf46bf378 /gtk/gtkemojichooser.c | |
parent | 5e9405887e685ff8106561c02fe952ce2ea713de (diff) | |
download | gtk+-fc573491b279f359f6f9307b8fdf26836684236e.tar.gz |
emojichooser: Stop using gtk_widget_get_allocation
Replace all uses with gtk_widget_compute_bounds.
Diffstat (limited to 'gtk/gtkemojichooser.c')
-rw-r--r-- | gtk/gtkemojichooser.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c index 63f62c8489..9288e7342d 100644 --- a/gtk/gtkemojichooser.c +++ b/gtk/gtkemojichooser.c @@ -260,14 +260,18 @@ scroll_to_section (EmojiSection *section) { GtkEmojiChooser *chooser; GtkAdjustment *adj; - GtkAllocation alloc = { 0, 0, 0, 0 }; + graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0); chooser = GTK_EMOJI_CHOOSER (gtk_widget_get_ancestor (section->box, GTK_TYPE_EMOJI_CHOOSER)); adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window)); if (section->heading) - gtk_widget_get_allocation (section->heading, &alloc); - gtk_adjustment_animate_to_value (adj, alloc.y - BOX_SPACE); + { + if (!gtk_widget_compute_bounds (section->heading, gtk_widget_get_parent (section->heading), &bounds)) + graphene_rect_init (&bounds, 0, 0, 0, 0); + } + + gtk_adjustment_animate_to_value (adj, bounds.origin.y - BOX_SPACE); } static void @@ -275,16 +279,17 @@ scroll_to_child (GtkWidget *child) { GtkEmojiChooser *chooser; GtkAdjustment *adj; - GtkAllocation alloc; graphene_point_t p; double value; double page_size; + graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0); chooser = GTK_EMOJI_CHOOSER (gtk_widget_get_ancestor (child, GTK_TYPE_EMOJI_CHOOSER)); adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window)); - gtk_widget_get_allocation (child, &alloc); + if (!gtk_widget_compute_bounds (child, gtk_widget_get_parent (child), &bounds)) + graphene_rect_init (&bounds, 0, 0, 0, 0); value = gtk_adjustment_get_value (adj); page_size = gtk_adjustment_get_page_size (adj); @@ -295,8 +300,8 @@ scroll_to_child (GtkWidget *child) if (p.y < value) gtk_adjustment_animate_to_value (adj, p.y); - else if (p.y + alloc.height >= value + page_size) - gtk_adjustment_animate_to_value (adj, value + ((p.y + alloc.height) - (value + page_size))); + else if (p.y + bounds.size.height >= value + page_size) + gtk_adjustment_animate_to_value (adj, value + ((p.y + bounds.size.height) - (value + page_size))); } static void @@ -794,17 +799,21 @@ adj_value_changed (GtkAdjustment *adj, for (i = 0; i < G_N_ELEMENTS (sections); ++i) { EmojiSection const *section = sections[i]; - GtkAllocation alloc; + GtkWidget *child; + graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0); if (!gtk_widget_get_visible (section->box)) continue; if (section->heading) - gtk_widget_get_allocation (section->heading, &alloc); + child = section->heading; else - gtk_widget_get_allocation (section->box, &alloc); + child = section->box; + + if (!gtk_widget_compute_bounds (child, gtk_widget_get_parent (child), &bounds)) + graphene_rect_init (&bounds, 0, 0, 0, 0); - if (value < alloc.y - BOX_SPACE) + if (value < bounds.origin.y - BOX_SPACE) break; select_section = section; @@ -1141,10 +1150,10 @@ keynav_failed (GtkWidget *box, GtkWidget *focus; GtkWidget *child; GtkWidget *sibling; - GtkAllocation alloc; int i; int column; int child_x; + graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0); focus = gtk_root_get_focus (gtk_widget_get_root (box)); if (focus == NULL) @@ -1161,14 +1170,15 @@ keynav_failed (GtkWidget *box, if (!gtk_widget_get_child_visible (sibling)) continue; - gtk_widget_get_allocation (sibling, &alloc); + if (!gtk_widget_compute_bounds (sibling, box, &bounds)) + graphene_rect_init (&bounds, 0, 0, 0, 0); - if (alloc.x < child_x) + if (bounds.origin.x < child_x) column = 0; else column++; - child_x = alloc.x; + child_x = (int) bounds.origin.x; if (sibling == child) break; @@ -1192,14 +1202,15 @@ keynav_failed (GtkWidget *box, if (!gtk_widget_get_child_visible (sibling)) continue; - gtk_widget_get_allocation (sibling, &alloc); + if (!gtk_widget_compute_bounds (sibling, next->box, &bounds)) + graphene_rect_init (&bounds, 0, 0, 0, 0); - if (alloc.x < child_x) + if (bounds.origin.x < child_x) i = 0; else i++; - child_x = alloc.x; + child_x = (int) bounds.origin.x; if (i == column) { @@ -1228,14 +1239,15 @@ keynav_failed (GtkWidget *box, if (!gtk_widget_get_child_visible (sibling)) continue; - gtk_widget_get_allocation (sibling, &alloc); + if (!gtk_widget_compute_bounds (sibling, next->box, &bounds)) + graphene_rect_init (&bounds, 0, 0, 0, 0); - if (alloc.x < child_x) + if (bounds.origin.x < child_x) i = 0; else i++; - child_x = alloc.x; + child_x = (int) bounds.origin.x; if (i == column) child = sibling; |