diff options
author | Timm Bäder <mail@baedert.org> | 2018-04-07 13:37:24 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2018-04-10 09:43:47 +0200 |
commit | 3ce6355bf4ba0ac1d3c3e4f637babdbf4b85b91c (patch) | |
tree | c5e40c3c2719efb62c0d23ed89ab5703cda99e22 | |
parent | 3a5b2f54ea2d09fd9f1ed48ff90a32a77d83edc1 (diff) | |
download | gtk+-3ce6355bf4ba0ac1d3c3e4f637babdbf4b85b91c.tar.gz |
widget: Remove _get_own_allocation
Replace all usages of it with _compute_bounds
-rw-r--r-- | gtk/gtkcontainer.c | 8 | ||||
-rw-r--r-- | gtk/gtkentry.c | 33 | ||||
-rw-r--r-- | gtk/gtklistbox.c | 14 | ||||
-rw-r--r-- | gtk/gtkmenu.c | 13 | ||||
-rw-r--r-- | gtk/gtknotebook.c | 19 | ||||
-rw-r--r-- | gtk/gtkpaned.c | 49 | ||||
-rw-r--r-- | gtk/gtkrange.c | 61 | ||||
-rw-r--r-- | gtk/gtkscale.c | 22 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.c | 14 | ||||
-rw-r--r-- | gtk/gtkseparator.c | 1 | ||||
-rw-r--r-- | gtk/gtkstackswitcher.c | 5 | ||||
-rw-r--r-- | gtk/gtkswitch.c | 8 | ||||
-rw-r--r-- | gtk/gtktreeviewcolumn.c | 15 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 19 | ||||
-rw-r--r-- | gtk/gtkwidgetprivate.h | 2 |
15 files changed, 125 insertions, 158 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 821d027682..9ac9cf03b4 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -1892,7 +1892,6 @@ gtk_container_real_set_focus_child (GtkContainer *container, { GtkAdjustment *hadj; GtkAdjustment *vadj; - GtkAllocation allocation; gint x, y; hadj = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id); @@ -1900,6 +1899,7 @@ gtk_container_real_set_focus_child (GtkContainer *container, if (hadj || vadj) { GtkWidget *child = focus_child; + graphene_rect_t child_bounds; while (gtk_widget_get_focus_child (child)) child = gtk_widget_get_focus_child (child); @@ -1908,13 +1908,13 @@ gtk_container_real_set_focus_child (GtkContainer *container, 0, 0, &x, &y)) return; - gtk_widget_get_outer_allocation (child, &allocation); + gtk_widget_compute_bounds (child, child, &child_bounds); if (vadj) - gtk_adjustment_clamp_page (vadj, y, y + allocation.height); + gtk_adjustment_clamp_page (vadj, y, y + child_bounds.size.height); if (hadj) - gtk_adjustment_clamp_page (hadj, x, x + allocation.width); + gtk_adjustment_clamp_page (hadj, x, x + child_bounds.size.width); } } } diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index d005011893..c6d2bef241 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -3518,12 +3518,12 @@ gtk_entry_event (GtkWidget *widget, for (i = 0; i < MAX_ICONS; i++) { - GtkAllocation icon_alloc; if (priv->icons[i]) { - gtk_widget_get_outer_allocation (priv->icons[i]->widget, &icon_alloc); - - if (gdk_rectangle_contains_point (&icon_alloc, (int)x, (int)y)) + int icon_x, icon_y; + gtk_widget_translate_coordinates (widget, priv->icons[i]->widget, + x, y, &icon_x, &icon_y); + if (gtk_widget_contains (priv->icons[i]->widget, icon_x, icon_y)) { icon_info = priv->icons[i]; break; @@ -7739,8 +7739,8 @@ gtk_entry_get_icon_storage_type (GtkEntry *entry, /** * gtk_entry_get_icon_at_pos: * @entry: a #GtkEntry - * @x: the x coordinate of the position to find - * @y: the y coordinate of the position to find + * @x: the x coordinate of the position to find, relative to @entry + * @y: the y coordinate of the position to find, relative to @entry * * Finds the icon at the given position and return its index. The * position’s coordinates are relative to the @entry’s top left corner. @@ -7763,13 +7763,15 @@ gtk_entry_get_icon_at_pos (GtkEntry *entry, for (i = 0; i < MAX_ICONS; i++) { EntryIconInfo *icon_info = priv->icons[i]; - GtkAllocation allocation; + int icon_x, icon_y; if (icon_info == NULL) continue; - gtk_widget_get_outer_allocation (icon_info->widget, &allocation); - if (gdk_rectangle_contains_point (&allocation, x, y)) + gtk_widget_translate_coordinates (GTK_WIDGET (entry), icon_info->widget, + x, y, &icon_x, &icon_y); + + if (gtk_widget_contains (icon_info->widget, icon_x, icon_y)) return i; } @@ -7868,8 +7870,6 @@ gtk_entry_get_current_icon_drag_source (GtkEntry *entry) * If the entry is not realized or has no icon at the given position, * @icon_area is filled with zeros. Otherwise, @icon_area will be filled * with the icon's allocation, relative to @entry's allocation. - * - * See also gtk_entry_get_text_area() */ void gtk_entry_get_icon_area (GtkEntry *entry, @@ -7886,7 +7886,16 @@ gtk_entry_get_icon_area (GtkEntry *entry, if (icon_info) { - gtk_widget_get_outer_allocation (icon_info->widget, icon_area); + graphene_rect_t r; + + gtk_widget_compute_bounds (icon_info->widget, GTK_WIDGET (entry), &r); + + *icon_area = (GdkRectangle){ + floorf (r.origin.x), + floorf (r.origin.y), + ceilf (r.size.width), + ceilf (r.size.height), + }; } else { diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 5d7b62b7ed..311661b8e2 100644 --- a/gtk/gtklistbox.c +++ b/gtk/gtklistbox.c @@ -1437,22 +1437,22 @@ ensure_row_visible (GtkListBox *box, GtkListBoxPrivate *priv = BOX_PRIV (box); GtkWidget *header; gint y, height; - GtkAllocation allocation; + graphene_rect_t rect; if (!priv->adjustment) return; - gtk_widget_get_outer_allocation (GTK_WIDGET (row), &allocation); - y = allocation.y; - height = allocation.height; + gtk_widget_compute_bounds (GTK_WIDGET (row), GTK_WIDGET (box), &rect); + y = rect.origin.y; + height = rect.size.height; /* If the row has a header, we want to ensure that it is visible as well. */ header = ROW_PRIV (row)->header; if (GTK_IS_WIDGET (header) && gtk_widget_is_drawable (header)) { - gtk_widget_get_outer_allocation (header, &allocation); - y = allocation.y; - height += allocation.height; + gtk_widget_compute_bounds (header, GTK_WIDGET (box), &rect); + y = rect.origin.y; + height += rect.size.height; } gtk_adjustment_clamp_page (priv->adjustment, y, y + height); diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 56b502f8d1..3e58d7e152 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -3056,16 +3056,17 @@ check_threshold (GtkWidget *widget, } static gboolean -definitely_within_item (GtkWidget *widget, +definitely_within_item (GtkMenu *menu, + GtkWidget *widget, gint x, gint y) { - GtkAllocation allocation; int w, h; + graphene_rect_t bounds; - gtk_widget_get_outer_allocation (widget, &allocation); - w = allocation.width; - h = allocation.height; + gtk_widget_compute_bounds (widget, GTK_WIDGET (menu), &bounds); + w = bounds.size.width; + h = bounds.size.height; return check_threshold (widget, 0, 0, x, y) && @@ -3128,7 +3129,7 @@ gtk_menu_motion (GtkEventController *controller, menu_shell = GTK_MENU_SHELL (parent); menu = GTK_MENU (menu_shell); - if (definitely_within_item (menu_item, event->x, event->y)) + if (definitely_within_item (menu, menu_item, event->x, event->y)) menu_shell->priv->activate_time = 0; /* Check to see if we are within an active submenu's navigation region diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 03407ac810..a168b115d6 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2292,7 +2292,6 @@ gtk_notebook_gesture_pressed (GtkGestureMultiPress *gesture, if ((tab = get_tab_at_pos (notebook, x, y)) != NULL) { - GtkAllocation allocation; gboolean page_changed, was_focus; page = tab->data; @@ -2308,6 +2307,8 @@ gtk_notebook_gesture_pressed (GtkGestureMultiPress *gesture, /* save press to possibly begin a drag */ if (page->reorderable || page->detachable) { + graphene_rect_t tab_bounds; + priv->pressed_button = button; priv->mouse_x = x; @@ -2316,10 +2317,10 @@ gtk_notebook_gesture_pressed (GtkGestureMultiPress *gesture, priv->drag_begin_x = priv->mouse_x; priv->drag_begin_y = priv->mouse_y; - gtk_widget_get_outer_allocation (page->tab_widget, &allocation); + gtk_widget_compute_bounds (page->tab_widget, GTK_WIDGET (notebook), &tab_bounds); - priv->drag_offset_x = priv->drag_begin_x - allocation.x; - priv->drag_offset_y = priv->drag_begin_y - allocation.y; + priv->drag_offset_x = priv->drag_begin_x - tab_bounds.origin.x; + priv->drag_offset_y = priv->drag_begin_y - tab_bounds.origin.y; } } } @@ -2416,9 +2417,9 @@ get_drop_position (GtkNotebook *notebook) page->tab_label && gtk_widget_get_mapped (page->tab_label)) { - GtkAllocation allocation; + graphene_rect_t tab_bounds; - gtk_widget_get_outer_allocation (page->tab_widget, &allocation); + gtk_widget_compute_bounds (page->tab_widget, GTK_WIDGET (notebook), &tab_bounds); switch (priv->tab_pos) { @@ -2426,19 +2427,19 @@ get_drop_position (GtkNotebook *notebook) case GTK_POS_BOTTOM: if (!is_rtl) { - if (allocation.x + allocation.width / 2 > x) + if (tab_bounds.origin.x + tab_bounds.size.width / 2 > x) return children; } else { - if (allocation.x + allocation.width / 2 < x) + if (tab_bounds.origin.x + tab_bounds.size.width / 2 < x) return children; } break; case GTK_POS_LEFT: case GTK_POS_RIGHT: - if (allocation.y + allocation.height / 2 > y) + if (tab_bounds.origin.y + tab_bounds.size.height / 2 > y) return children; break; diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 369468c0a6..97ea15593b 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -292,21 +292,18 @@ add_move_binding (GtkBindingSet *binding_set, } static void -get_handle_area (GtkPaned *paned, - GdkRectangle *area) +get_handle_area (GtkPaned *paned, + graphene_rect_t *area) { GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned); int extra = 0; - gtk_widget_get_outer_allocation (priv->handle_widget, area); + gtk_widget_compute_bounds (priv->handle_widget, GTK_WIDGET (paned), area); if (!gtk_paned_get_wide_handle (paned)) extra = HANDLE_EXTRA_SIZE; - area->x -= extra; - area->y -= extra; - area->width += extra * 2; - area->height += extra * 2; + graphene_rect_inset (area, - extra, - extra); } static void @@ -316,11 +313,12 @@ gtk_paned_motion (GtkEventControllerMotion *motion, GtkPaned *paned) { GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned); - GdkRectangle handle_area; + graphene_rect_t handle_area; get_handle_area (paned, &handle_area); - if (gdk_rectangle_contains_point (&handle_area, x, y) || priv->panning) + if (graphene_rect_contains_point (&handle_area, &(graphene_point_t){x, y}) || + priv->panning) { if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) gtk_widget_set_cursor_from_name (GTK_WIDGET (paned), "col-resize"); @@ -748,7 +746,7 @@ gesture_drag_begin_cb (GtkGestureDrag *gesture, { GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned); GdkEventSequence *sequence; - GdkRectangle handle_area; + graphene_rect_t handle_area; const GdkEvent *event; GdkDevice *device; gboolean is_touch; @@ -771,7 +769,7 @@ gesture_drag_begin_cb (GtkGestureDrag *gesture, return; } - if (gdk_rectangle_contains_point (&handle_area, (int)start_x, (int)start_y) || + if (graphene_rect_contains_point (&handle_area, &(graphene_point_t){start_x, start_y}) || (is_touch && initiates_touch_drag (paned, start_x, start_y))) { if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) @@ -1401,7 +1399,6 @@ gtk_paned_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) { GtkPanedPrivate *priv = gtk_paned_get_instance_private (GTK_PANED (widget)); - GtkAllocation child_allocation; gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT ( @@ -1416,34 +1413,10 @@ gtk_paned_snapshot (GtkWidget *widget, gtk_widget_snapshot_child (widget, priv->handle_widget, snapshot); if (priv->child1 && gtk_widget_get_visible (priv->child1)) - { - gtk_widget_get_outer_allocation (priv->child1, &child_allocation); - gtk_snapshot_push_clip (snapshot, - &GRAPHENE_RECT_INIT ( - child_allocation.x, - child_allocation.y, - child_allocation.width, - child_allocation.height - ), - "GtkPanedChild1"); - gtk_widget_snapshot_child (widget, priv->child1, snapshot); - gtk_snapshot_pop (snapshot); - } + gtk_widget_snapshot_child (widget, priv->child1, snapshot); if (priv->child2 && gtk_widget_get_visible (priv->child2)) - { - gtk_widget_get_outer_allocation (priv->child2, &child_allocation); - gtk_snapshot_push_clip (snapshot, - &GRAPHENE_RECT_INIT ( - child_allocation.x, - child_allocation.y, - child_allocation.width, - child_allocation.height - ), - "GtkPanedChild2"); - gtk_widget_snapshot_child (widget, priv->child2, snapshot); - gtk_snapshot_pop (snapshot); - } + gtk_widget_snapshot_child (widget, priv->child2, snapshot); gtk_snapshot_pop (snapshot); } diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 3c54dee724..67b94f7da2 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -40,7 +40,6 @@ #include "gtkprivate.h" #include "gtkscale.h" #include "gtktypebuiltins.h" -#include "gtkwidgetprivate.h" #include "gtkwindow.h" #include "gtkeventcontrollerkey.h" @@ -901,11 +900,19 @@ gtk_range_get_range_rect (GtkRange *range, GdkRectangle *range_rect) { GtkRangePrivate *priv = gtk_range_get_instance_private (range); + graphene_rect_t r; g_return_if_fail (GTK_IS_RANGE (range)); g_return_if_fail (range_rect != NULL); - gtk_widget_get_outer_allocation (priv->trough_widget, range_rect); + gtk_widget_compute_bounds (priv->trough_widget, GTK_WIDGET (range), &r); + + *range_rect = (GdkRectangle) { + floorf (r.origin.x), + floorf (r.origin.y), + ceilf (r.size.width), + ceilf (r.size.height), + }; } /** @@ -927,25 +934,25 @@ gtk_range_get_slider_range (GtkRange *range, gint *slider_end) { GtkRangePrivate *priv = gtk_range_get_instance_private (range); - GtkAllocation slider_alloc; + graphene_rect_t slider_bounds; g_return_if_fail (GTK_IS_RANGE (range)); - gtk_widget_get_outer_allocation (priv->slider_widget, &slider_alloc); + gtk_widget_compute_bounds (priv->slider_widget, GTK_WIDGET (range), &slider_bounds); if (priv->orientation == GTK_ORIENTATION_VERTICAL) { if (slider_start) - *slider_start = slider_alloc.y; + *slider_start = slider_bounds.origin.y; if (slider_end) - *slider_end = slider_alloc.y + slider_alloc.height; + *slider_end = slider_bounds.origin.y + slider_bounds.size.height; } else { if (slider_start) - *slider_start = slider_alloc.x; + *slider_start = slider_bounds.origin.y; if (slider_end) - *slider_end = slider_alloc.x + slider_alloc.width; + *slider_end = slider_bounds.origin.x + slider_bounds.size.width; } } @@ -1760,19 +1767,19 @@ coord_to_value (GtkRange *range, gdouble value; gint trough_length; gint slider_length; - GtkAllocation slider_alloc; + graphene_rect_t slider_bounds; - gtk_widget_get_outer_allocation (priv->slider_widget, &slider_alloc); + gtk_widget_compute_bounds (priv->slider_widget, priv->slider_widget, &slider_bounds); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { trough_length = gtk_widget_get_width (priv->trough_widget); - slider_length = slider_alloc.width; + slider_length = slider_bounds.size.width; } else { trough_length = gtk_widget_get_height (priv->trough_widget); - slider_length = slider_alloc.height; + slider_length = slider_bounds.size.height; } if (trough_length == slider_length) @@ -1819,14 +1826,14 @@ gtk_range_key_controller_key_pressed (GtkEventControllerKey *controller, (keyval == GDK_KEY_Shift_L || keyval == GDK_KEY_Shift_R)) { - GtkAllocation slider_alloc; + graphene_rect_t slider_bounds; - gtk_widget_get_outer_allocation (priv->slider_widget, &slider_alloc); + gtk_widget_compute_bounds (priv->slider_widget, priv->trough_widget, &slider_bounds); if (priv->orientation == GTK_ORIENTATION_VERTICAL) - priv->slide_initial_slider_position = slider_alloc.y; + priv->slide_initial_slider_position = slider_bounds.origin.y; else - priv->slide_initial_slider_position = slider_alloc.x; + priv->slide_initial_slider_position = slider_bounds.origin.x; update_zoom_state (range, !priv->zoom); return GDK_EVENT_STOP; @@ -1893,8 +1900,8 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture, gboolean shift_pressed; guint button; GdkModifierType state_mask; - GtkAllocation slider_alloc; GtkWidget *mouse_location; + graphene_rect_t slider_bounds; if (!gtk_widget_has_focus (widget)) gtk_widget_grab_focus (widget); @@ -1908,7 +1915,7 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture, source_device = gdk_event_get_source_device ((GdkEvent *) event); source = gdk_device_get_source (source_device); - gtk_widget_get_outer_allocation (priv->slider_widget, &slider_alloc); + gtk_widget_compute_bounds (priv->slider_widget, priv->slider_widget, &slider_bounds); g_object_get (gtk_widget_get_settings (widget), "gtk-primary-button-warps-slider", &primary_warps, @@ -1956,8 +1963,8 @@ gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture, /* If we aren't fixed, center on the slider. I.e. if this is not a scale... */ if (!priv->slider_size_fixed) { - slider_range_x += (slider_alloc.width / 2); - slider_range_y += (slider_alloc.height / 2); + slider_range_x += (slider_bounds.size.width / 2); + slider_range_y += (slider_bounds.size.height / 2); } update_initial_slider_position (range, slider_range_x, slider_range_y); @@ -2044,12 +2051,12 @@ update_slider_position (GtkRange *range, if (priv->zoom) { - GtkAllocation trough_alloc; + graphene_rect_t trough_bounds; - gtk_widget_get_outer_allocation (priv->trough_widget, &trough_alloc); + gtk_widget_compute_bounds (priv->trough_widget, priv->trough_widget, &trough_bounds); zoom = MIN(1.0, (priv->orientation == GTK_ORIENTATION_VERTICAL ? - trough_alloc.height : trough_alloc.width) / + trough_bounds.size.height : trough_bounds.size.width) / (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment))); @@ -2063,14 +2070,14 @@ update_slider_position (GtkRange *range, /* recalculate the initial position from the current position */ if (priv->slide_initial_slider_position == -1) { - GtkAllocation slider_alloc; + graphene_rect_t slider_bounds; - gtk_widget_get_outer_allocation (priv->slider_widget, &slider_alloc); + gtk_widget_compute_bounds (priv->slider_widget, GTK_WIDGET (range), &slider_bounds); if (priv->orientation == GTK_ORIENTATION_VERTICAL) - priv->slide_initial_slider_position = (zoom * (mouse_y - priv->slide_initial_coordinate_delta) - slider_alloc.y) / (zoom - 1.0); + priv->slide_initial_slider_position = (zoom * (mouse_y - priv->slide_initial_coordinate_delta) - slider_bounds.origin.y) / (zoom - 1.0); else - priv->slide_initial_slider_position = (zoom * (mouse_x - priv->slide_initial_coordinate_delta) - slider_alloc.x) / (zoom - 1.0); + priv->slide_initial_slider_position = (zoom * (mouse_x - priv->slide_initial_coordinate_delta) - slider_bounds.origin.x) / (zoom - 1.0); } if (priv->orientation == GTK_ORIENTATION_VERTICAL) diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index cea8b3ef6d..96554cedac 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -42,7 +42,6 @@ #include "gtkstylecontextprivate.h" #include "gtkstylepropertyprivate.h" #include "gtktypebuiltins.h" -#include "gtkwidgetprivate.h" #include "a11y/gtkscaleaccessible.h" @@ -329,14 +328,15 @@ gtk_scale_allocate_value (GtkScale *scale) GtkWidget *widget = GTK_WIDGET (scale); GtkRange *range = GTK_RANGE (widget); GtkWidget *slider_widget; - GtkAllocation slider_alloc, value_alloc; + GtkAllocation value_alloc; int range_width, range_height; + graphene_rect_t slider_bounds; range_width = gtk_widget_get_width (widget); range_height = gtk_widget_get_height (widget); slider_widget = gtk_range_get_slider_widget (range); - gtk_widget_get_outer_allocation (slider_widget, &slider_alloc); + gtk_widget_compute_bounds (slider_widget, widget, &slider_bounds); gtk_widget_measure (priv->value_widget, GTK_ORIENTATION_HORIZONTAL, -1, @@ -362,12 +362,12 @@ gtk_scale_allocate_value (GtkScale *scale) break; case GTK_POS_TOP: - value_alloc.x = slider_alloc.x + (slider_alloc.width - value_alloc.width) / 2; + value_alloc.x = slider_bounds.origin.x + (slider_bounds.size.width - value_alloc.width) / 2; value_alloc.y = 0; break; case GTK_POS_BOTTOM: - value_alloc.x = slider_alloc.x + (slider_alloc.width - value_alloc.width) / 2; + value_alloc.x = slider_bounds.origin.x + (slider_bounds.size.width - value_alloc.width) / 2; value_alloc.y = range_height - value_alloc.height; break; @@ -382,12 +382,12 @@ gtk_scale_allocate_value (GtkScale *scale) { case GTK_POS_LEFT: value_alloc.x = 0; - value_alloc.y = (slider_alloc.y + (slider_alloc.height / 2)) - value_alloc.height / 2; + value_alloc.y = (slider_bounds.origin.y + (slider_bounds.size.height / 2)) - value_alloc.height / 2; break; case GTK_POS_RIGHT: value_alloc.x = range_width - value_alloc.width; - value_alloc.y = (slider_alloc.y + (slider_alloc.height / 2)) - value_alloc.height / 2; + value_alloc.y = (slider_bounds.origin.y + (slider_bounds.size.height / 2)) - value_alloc.height / 2; break; case GTK_POS_TOP: @@ -1514,7 +1514,7 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale, gint *y) { GtkScalePrivate *priv = gtk_scale_get_instance_private (scale); - GtkAllocation value_alloc; + graphene_rect_t value_bounds; if (!priv->value_widget) { @@ -1524,10 +1524,10 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale, return; } - gtk_widget_get_outer_allocation (priv->value_widget, &value_alloc); + gtk_widget_compute_bounds (priv->value_widget, GTK_WIDGET (scale), &value_bounds); - *x = value_alloc.x; - *y = value_alloc.y; + *x = value_bounds.origin.x; + *y = value_bounds.origin.y; } static gchar * diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 761a09c3c6..9da2d1ea82 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1063,13 +1063,13 @@ event_close_to_indicator (GtkScrolledWindow *sw, GdkEvent *event) { GtkScrolledWindowPrivate *priv; - GtkAllocation indicator_alloc; + graphene_rect_t indicator_bounds; gdouble x, y; gint distance; priv = sw->priv; - gtk_widget_get_outer_allocation (indicator->scrollbar, &indicator_alloc); + gtk_widget_compute_bounds (indicator->scrollbar, GTK_WIDGET (sw), &indicator_bounds); gdk_event_get_coords (event, &x, &y); if (indicator->over) @@ -1077,16 +1077,18 @@ event_close_to_indicator (GtkScrolledWindow *sw, else distance = INDICATOR_CLOSE_DISTANCE; + graphene_rect_inset (&indicator_bounds, distance, distance); + if (indicator == &priv->hindicator) { - if (y >= indicator_alloc.y - distance && - y < indicator_alloc.y + indicator_alloc.height + distance) + if (y >= indicator_bounds.origin.y && + y < indicator_bounds.origin.y + indicator_bounds.size.height) return TRUE; } else if (indicator == &priv->vindicator) { - if (x >= indicator_alloc.x - distance && - x < indicator_alloc.x + indicator_alloc.width + distance) + if (x >= indicator_bounds.origin.x && + x < indicator_bounds.origin.x + indicator_bounds.size.width) return TRUE; } diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c index cd5af76fce..c6acab5da7 100644 --- a/gtk/gtkseparator.c +++ b/gtk/gtkseparator.c @@ -29,7 +29,6 @@ #include "gtkorientableprivate.h" #include "gtkintl.h" #include "gtkprivate.h" -#include "gtkwidgetprivate.h" /** * SECTION:gtkseparator diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c index 000e87bf9c..62435ad831 100644 --- a/gtk/gtkstackswitcher.c +++ b/gtk/gtkstackswitcher.c @@ -310,10 +310,7 @@ gtk_stack_switcher_drag_motion (GtkWidget *widget, g_hash_table_iter_init (&iter, priv->buttons); while (g_hash_table_iter_next (&iter, NULL, &value)) { - GdkRectangle allocation; - - gtk_widget_get_outer_allocation (GTK_WIDGET (value), &allocation); - if (gdk_rectangle_contains_point (&allocation, (int)x, (int)y)) + if (gtk_widget_contains (GTK_WIDGET (value), x, y)) { button = GTK_WIDGET (value); retval = TRUE; diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index fb3b21f732..2116eafcf2 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -188,16 +188,16 @@ gtk_switch_multipress_gesture_pressed (GtkGestureMultiPress *gesture, GtkSwitch *sw) { GtkSwitchPrivate *priv = gtk_switch_get_instance_private (sw); - GtkAllocation allocation; + graphene_rect_t switch_bounds; - gtk_widget_get_outer_allocation (GTK_WIDGET (sw), &allocation); + gtk_widget_compute_bounds (GTK_WIDGET (sw), GTK_WIDGET (sw), &switch_bounds); gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); /* If the press didn't happen in the draggable handle, * cancel the pan gesture right away */ - if ((priv->is_active && x <= allocation.width / 2.0) || - (!priv->is_active && x > allocation.width / 2.0)) + if ((priv->is_active && x <= switch_bounds.size.width / 2.0) || + (!priv->is_active && x > switch_bounds.size.width / 2.0)) gtk_gesture_set_state (priv->pan_gesture, GTK_EVENT_SEQUENCE_DENIED); } diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index defb47a51d..af4531ebda 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -3059,7 +3059,7 @@ _gtk_tree_view_column_coords_in_resize_rect (GtkTreeViewColumn *column, double y) { GtkTreeViewColumnPrivate *priv = column->priv; - GtkAllocation button_allocation; + graphene_rect_t button_bounds; /* x and y are in treeview coordinates. */ @@ -3068,14 +3068,13 @@ _gtk_tree_view_column_coords_in_resize_rect (GtkTreeViewColumn *column, !priv->visible) return FALSE; - gtk_widget_get_outer_allocation (priv->button, &button_allocation); - - /* No translation needed */ - g_assert (gtk_widget_get_parent (priv->button) == priv->tree_view); + gtk_widget_compute_bounds (priv->button, priv->tree_view, &button_bounds); if (gtk_widget_get_direction (priv->tree_view) == GTK_TEXT_DIR_LTR) - button_allocation.x += button_allocation.width - TREE_VIEW_DRAG_WIDTH; + button_bounds.origin.x += button_bounds.size.width - TREE_VIEW_DRAG_WIDTH; + + button_bounds.size.width = TREE_VIEW_DRAG_WIDTH; - button_allocation.width = TREE_VIEW_DRAG_WIDTH; - return gdk_rectangle_contains_point (&button_allocation, (int)x, (int)y); + return graphene_rect_contains_point (&button_bounds, + &(graphene_point_t){x, y}); } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index d9ed6d06e7..0ed3d85c13 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -11445,25 +11445,6 @@ gtk_widget_pick (GtkWidget *widget, return GTK_WIDGET_GET_CLASS (widget)->pick (widget, x, y); } -void -gtk_widget_get_outer_allocation (GtkWidget *widget, - GdkRectangle *allocation) -{ - GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - GtkBorder margin; - GtkCssStyle *style; - - style = gtk_css_node_get_style (priv->cssnode); - get_box_margin (style, &margin); - - *allocation = priv->allocation; - - allocation->x += margin.left; - allocation->y += margin.top; - allocation->width -= margin.left + margin.right; - allocation->height -= margin.top + margin.bottom; -} - /** * gtk_widget_compute_bounds: * @widget: the #GtkWidget to query diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index a6be3a51d1..9a1d918444 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -319,8 +319,6 @@ void gtk_widget_focus_sort (GtkWidget *wi gboolean gtk_widget_focus_move (GtkWidget *widget, GtkDirectionType direction, GPtrArray *focus_order); -void gtk_widget_get_outer_allocation (GtkWidget *widget, - GtkAllocation *allocation); void gtk_widget_get_surface_allocation (GtkWidget *widget, GtkAllocation *allocation); |