Merge branch 'wip/otte/for-main' into 'main'
authorBenjamin Otte <otte.benjamin@googlemail.com>
Thu, 16 Mar 2023 20:59:17 +0000 (20:59 +0000)
committerBenjamin Otte <otte.benjamin@googlemail.com>
Thu, 16 Mar 2023 21:05:40 +0000 (17:05 -0400)
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
gdk/win32/gdkcursor-win32.c
gtk/gdkpixbufutils.c
gtk/gtklistbase.c

index 007901ffe847ef1f11c22fadf084510aaa918de5..41cb8ea11a16b24cff76e874816d098c8fa8991a 100644 (file)
@@ -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),
index dc707d56749591b825bd6ff2a998c71cee5705f4..5d388d04b229311311824d03292c4d4a584fb1e7 100644 (file)
@@ -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;
        }
     }
 
index 6b29128376d7ea75a26fb422e58d41644c9e64f5..8d049311ac4934091ce3fbab50d28552066414e8 100644 (file)
@@ -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;
 
index 81ac56cc6ff997a569d8d05204b095f31b740a9d..8bc7271c26e0ec6cbfa5a16dd5966a7ec304dfaf 100644 (file)
@@ -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