From d31dc4343bb153dc241e862c6d194c5571d20472 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 16 Mar 2023 20:59:17 +0000 Subject: [PATCH] Merge branch 'wip/otte/for-main' into 'main' Various small fixes Closes #5380 See merge request GNOME/gtk!5662 (cherry picked from commit fbc8bfb3031cbbdddc4978d6326d68ae19f3f3e3) 707c63c6 win32: Fix rowstride math ef3c515c rowstrides are gsize, not int a0382ef4 listview: Fix culling issues when using CSS padding --- gdk/gdktexture.c | 2 +- gdk/win32/gdkcursor-win32.c | 9 +++++---- gtk/gdkpixbufutils.c | 3 ++- gtk/gtklistbase.c | 39 ++++++++++++++++++++++++------------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c index 007901ffe8..41cb8ea11a 100644 --- a/gdk/gdktexture.c +++ b/gdk/gdktexture.c @@ -395,7 +395,7 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf) bytes = g_bytes_new_with_free_func (gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_height (pixbuf) - * gdk_pixbuf_get_rowstride (pixbuf), + * (gsize) gdk_pixbuf_get_rowstride (pixbuf), g_object_unref, g_object_ref (pixbuf)); texture = gdk_memory_texture_new (gdk_pixbuf_get_width (pixbuf), diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c index dc707d5674..5d388d04b2 100644 --- a/gdk/win32/gdkcursor-win32.c +++ b/gdk/win32/gdkcursor-win32.c @@ -1005,7 +1005,8 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon, } bmi; HDC hdc; uint8_t *pixels, *bits; - int rowstride, x, y, w, h; + int x, y, w, h; + gsize rowstride; if (!GDI_CALL (GetIconInfo, (hicon, &ii))) return NULL; @@ -1057,7 +1058,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon, no_alpha = FALSE; pixels += 4; } - pixels += (w * 4 - rowstride); + pixels += rowstride - w * 4; } /* mask */ @@ -1072,7 +1073,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon, pixels[3] = 255 - bits[(x + y * w) * 4]; pixels += 4; } - pixels += (w * 4 - rowstride); + pixels += rowstride - w * 4; } } } @@ -1146,7 +1147,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon, xorp++; } } - pixels += (w * 4 - rowstride); + pixels += rowstride - w * 4; } } diff --git a/gtk/gdkpixbufutils.c b/gtk/gdkpixbufutils.c index 6b29128376..8d049311ac 100644 --- a/gtk/gdkpixbufutils.c +++ b/gtk/gdkpixbufutils.c @@ -284,7 +284,8 @@ extract_plane (GdkPixbuf *src, int to_plane) { guchar *src_data, *dst_data; - int width, height, src_stride, dst_stride; + int width, height; + gsize src_stride, dst_stride; guchar *src_row, *dst_row; int x, y; diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c index 81ac56cc6f..8bc7271c26 100644 --- a/gtk/gtklistbase.c +++ b/gtk/gtklistbase.c @@ -23,6 +23,7 @@ #include "gtkadjustment.h" #include "gtkbitset.h" +#include "gtkcssboxesprivate.h" #include "gtkcssnodeprivate.h" #include "gtkcsspositionvalueprivate.h" #include "gtkdragsourceprivate.h" @@ -1324,6 +1325,8 @@ update_autoscroll (GtkListBase *self, /* * gtk_list_base_size_allocate_child: * @self: The listbase + * @boxes: The CSS boxes of @self to allow for proper + * clipping * @child: The child * @x: top left coordinate in the across direction * @y: top right coordinate in the along direction @@ -1336,6 +1339,7 @@ update_autoscroll (GtkListBase *self, **/ static void gtk_list_base_size_allocate_child (GtkListBase *self, + GtkCssBoxes *boxes, GtkWidget *child, int x, int y, @@ -1343,10 +1347,9 @@ gtk_list_base_size_allocate_child (GtkListBase *self, int height) { GtkAllocation child_allocation; - int self_width, self_height; + int self_width; self_width = gtk_widget_get_width (GTK_WIDGET (self)); - self_height = gtk_widget_get_height (GTK_WIDGET (self)); if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL) { @@ -1379,14 +1382,14 @@ gtk_list_base_size_allocate_child (GtkListBase *self, child_allocation.height = width; } - if (!gdk_rectangle_intersect (&child_allocation, - &(GdkRectangle) { - - GTK_LIST_BASE_CHILD_MAX_OVERDRAW, - - GTK_LIST_BASE_CHILD_MAX_OVERDRAW, - self_width + GTK_LIST_BASE_CHILD_MAX_OVERDRAW, - self_height + GTK_LIST_BASE_CHILD_MAX_OVERDRAW - }, - NULL)) + if (!graphene_rect_intersection (gtk_css_boxes_get_padding_rect (boxes), + &GRAPHENE_RECT_INIT( + child_allocation.x + GTK_LIST_BASE_CHILD_MAX_OVERDRAW, + child_allocation.y + GTK_LIST_BASE_CHILD_MAX_OVERDRAW, + child_allocation.width + 2 * GTK_LIST_BASE_CHILD_MAX_OVERDRAW, + child_allocation.height + 2 * GTK_LIST_BASE_CHILD_MAX_OVERDRAW + ), + NULL)) { /* child is fully outside the viewport, hide it and don't allocate it */ gtk_widget_set_child_visible (child, FALSE); @@ -1399,7 +1402,8 @@ gtk_list_base_size_allocate_child (GtkListBase *self, } static void -gtk_list_base_allocate_children (GtkListBase *self) +gtk_list_base_allocate_children (GtkListBase *self, + GtkCssBoxes *boxes) { GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self); GtkListTile *tile; @@ -1415,6 +1419,7 @@ gtk_list_base_allocate_children (GtkListBase *self) if (tile->widget) { gtk_list_base_size_allocate_child (GTK_LIST_BASE (self), + boxes, tile->widget, tile->area.x - dx, tile->area.y - dy, @@ -1511,7 +1516,8 @@ gtk_list_base_get_rubberband_coords (GtkListBase *self, } static void -gtk_list_base_allocate_rubberband (GtkListBase *self) +gtk_list_base_allocate_rubberband (GtkListBase *self, + GtkCssBoxes *boxes) { GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self); GtkRequisition min_size; @@ -1531,6 +1537,7 @@ gtk_list_base_allocate_rubberband (GtkListBase *self) rect.y -= offset_y; gtk_list_base_size_allocate_child (self, + boxes, priv->rubberband->widget, rect.x, rect.y, rect.width, rect.height); } @@ -1974,10 +1981,14 @@ gtk_list_base_update_adjustments (GtkListBase *self) void gtk_list_base_allocate (GtkListBase *self) { + GtkCssBoxes boxes; + + gtk_css_boxes_init (&boxes, GTK_WIDGET (self)); + gtk_list_base_update_adjustments (self); - gtk_list_base_allocate_children (self); - gtk_list_base_allocate_rubberband (self); + gtk_list_base_allocate_children (self, &boxes); + gtk_list_base_allocate_rubberband (self, &boxes); } GtkScrollablePolicy -- 2.30.2