natives: Use GtkCssBoxes in get_surface_transform
authorTimm Bäder <mail@baedert.org>
Sat, 16 May 2020 06:01:22 +0000 (08:01 +0200)
committerTimm Bäder <mail@baedert.org>
Sat, 16 May 2020 20:04:00 +0000 (22:04 +0200)
gtk/gtkdragicon.c
gtk/gtktexthandle.c
gtk/gtktooltipwindow.c

index 45cb8e1c518542c6a06566beb1b4845bd27da00e..999ab113ca15176b4fd003c391c6ed28dd9f1b9e 100644 (file)
@@ -27,6 +27,7 @@
 #include "gtkcsstypesprivate.h"
 #include "gtknativeprivate.h"
 #include "gtkpicture.h"
+#include "gtkcssboxesimplprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 
 /* for the drag icons */
@@ -122,15 +123,14 @@ gtk_drag_icon_native_get_surface_transform (GtkNative *native,
                                             int       *x,
                                             int       *y)
 {
-  GtkCssStyle *style;
-
-  style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (native)));
-  *x  = _gtk_css_number_value_get (style->size->margin_left, 100) +
-        _gtk_css_number_value_get (style->border->border_left_width, 100) +
-        _gtk_css_number_value_get (style->size->padding_left, 100);
-  *y  = _gtk_css_number_value_get (style->size->margin_top, 100) +
-        _gtk_css_number_value_get (style->border->border_top_width, 100) +
-        _gtk_css_number_value_get (style->size->padding_top, 100);
+  GtkCssBoxes css_boxes;
+  const graphene_rect_t *margin_rect;
+
+  gtk_css_boxes_init (&css_boxes, GTK_WIDGET (native));
+  margin_rect = gtk_css_boxes_get_margin_rect (&css_boxes);
+
+  *x = - margin_rect->origin.x;
+  *y = - margin_rect->origin.y;
 }
 
 static void
index df8ea7c6381ce29a8bb53b340ddc095e298864b7..72ac92bea0c6d78a1297e8c157fd964b1bc4bec2 100644 (file)
 #include "gtkmarshalers.h"
 #include "gtkprivate.h"
 #include "gtkwindowprivate.h"
-#include "gtkcssnodeprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkrendericonprivate.h"
+#include "gtkcssboxesimplprivate.h"
+#include "gtkcssnumbervalueprivate.h"
 #include "gtkstylecontextprivate.h"
 #include "gtkintl.h"
 
@@ -82,15 +83,14 @@ gtk_text_handle_native_get_surface_transform (GtkNative *native,
                                               int       *x,
                                               int       *y)
 {
-  GtkCssStyle *style;
-
-  style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (native)));
-  *x  = _gtk_css_number_value_get (style->size->margin_left, 100) +
-        _gtk_css_number_value_get (style->border->border_left_width, 100) +
-        _gtk_css_number_value_get (style->size->padding_left, 100);
-  *y  = _gtk_css_number_value_get (style->size->margin_top, 100) +
-        _gtk_css_number_value_get (style->border->border_top_width, 100) +
-        _gtk_css_number_value_get (style->size->padding_top, 100);
+  GtkCssBoxes css_boxes;
+  const graphene_rect_t *margin_rect;
+
+  gtk_css_boxes_init (&css_boxes, GTK_WIDGET (native));
+  margin_rect = gtk_css_boxes_get_margin_rect (&css_boxes);
+
+  *x = - margin_rect->origin.x;
+  *y = - margin_rect->origin.y;
 }
 
 static void
index 5c9c4e5097e11455b77c0f6411e3096e28152924..2e871c534cf1b4d0a390018c595ad83d488e43a9 100644 (file)
@@ -39,8 +39,7 @@
 #include "gtkwindowprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtknative.h"
-#include "gtkstylecontext.h"
-#include "gtkcssnodeprivate.h"
+#include "gtkcssboxesimplprivate.h"
 
 struct _GtkTooltipWindow
 {
@@ -98,16 +97,14 @@ gtk_tooltip_window_native_get_surface_transform (GtkNative *native,
                                                  int       *x,
                                                  int       *y)
 {
-  GtkStyleContext *context;
-  GtkBorder margin, border, padding;
+  GtkCssBoxes css_boxes;
+  const graphene_rect_t *margin_rect;
 
-  context = gtk_widget_get_style_context (GTK_WIDGET (native));
-  gtk_style_context_get_margin (context, &margin);
-  gtk_style_context_get_border (context, &border);
-  gtk_style_context_get_padding (context, &padding);
+  gtk_css_boxes_init (&css_boxes, GTK_WIDGET (native));
+  margin_rect = gtk_css_boxes_get_margin_rect (&css_boxes);
 
-  *x = margin.left + border.left + padding.left;
-  *y = margin.top + border.top + padding.top;
+  *x = - margin_rect->origin.x;
+  *y = - margin_rect->origin.y;
 }
 
 static GdkPopupLayout *