[gtk+] widget: Fix math screwups in clip calculation



commit 9a06b0fd5f6e992027f09623c4d72a803b9bfd23
Author: Benjamin Otte <otte redhat com>
Date:   Thu Nov 17 23:16:14 2016 +0100

    widget: Fix math screwups in clip calculation
    
    We need so subtract the allocation from the clip to get the clip offset,
    not the other way around.
    
    This was screwing in particular with marks on GtkScale, because GtkScale
    mark clip computation is broken and always returns (0,0) which makes
    scales have a waaaaay too large clip.
    But that's another bug.

 gtk/gtkwidget.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4045e3f..c45f9a3 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6413,13 +6413,13 @@ gtk_widget_draw_internal (GtkWidget *widget,
           GskRenderNode *node;
 
           graphene_rect_init (&viewport,
-                              widget->priv->allocation.x - widget->priv->clip.x,
-                              widget->priv->allocation.y - widget->priv->clip.y,
+                              widget->priv->clip.x - widget->priv->allocation.x,
+                              widget->priv->clip.y - widget->priv->allocation.y,
                               widget->priv->clip.width,
                               widget->priv->clip.height);
           clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
-                                                widget->priv->allocation.x - widget->priv->clip.x,
-                                                widget->priv->allocation.y - widget->priv->clip.y,
+                                                widget->priv->clip.x - widget->priv->allocation.x,
+                                                widget->priv->clip.y - widget->priv->allocation.y,
                                                 widget->priv->clip.width,
                                                 widget->priv->clip.height});
           fallback = gsk_renderer_create_fallback (renderer, &viewport, cr);
@@ -15656,7 +15656,7 @@ gtk_widget_snapshot (GtkWidget   *widget,
 
   gtk_widget_get_clip (widget, &clip);
   _gtk_widget_get_allocation (widget, &alloc);
-  graphene_rect_init (&bounds, alloc.x - clip.x, alloc.y - clip.y, clip.width, clip.height);
+  graphene_rect_init (&bounds, clip.x - alloc.x, clip.y - alloc.y, clip.width, clip.height);
   if (gtk_snapshot_clips_rect (snapshot, &bounds))
     return;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]