[gtk/wip/matthiasc/popup5: 57/187] widget: Use GtkNative



commit b06e0cf5ce3293712c759a8c23e620c906568f85
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 29 13:47:40 2019 -0400

    widget: Use GtkNative

 gtk/gtkwidget.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 87b8e20fd7..253bc9fa35 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -56,6 +56,8 @@
 #include "gtkprivate.h"
 #include "gtkrenderbackgroundprivate.h"
 #include "gtkrenderborderprivate.h"
+#include "gtkrootprivate.h"
+#include "gtknativeprivate.h"
 #include "gtkscrollable.h"
 #include "gtkselection.h"
 #include "gtksettingsprivate.h"
@@ -3635,7 +3637,7 @@ sync_widget_surface_transform (GtkWidget *widget)
   was_valid = surface_transform_data->cached_surface_transform_valid;
   prev_transform = surface_transform_data->cached_surface_transform;
 
-  if (GTK_IS_ROOT (widget))
+  if (GTK_IS_NATIVE (widget))
     {
       gsk_transform_to_matrix (priv->transform,
                                &surface_transform_data->cached_surface_transform);
@@ -3645,15 +3647,20 @@ sync_widget_surface_transform (GtkWidget *widget)
     {
       surface_transform_data->cached_surface_transform_valid = FALSE;
     }
-  else if (gtk_widget_compute_transform (widget, GTK_WIDGET (priv->root),
-                                         &surface_transform_data->cached_surface_transform))
-    {
-      surface_transform_data->cached_surface_transform_valid = TRUE;
-    }
   else
     {
-      g_warning ("Could not compute surface transform");
-      surface_transform_data->cached_surface_transform_valid = FALSE;
+      GtkWidget *native = gtk_widget_get_ancestor (widget, GTK_TYPE_NATIVE);
+
+      if (gtk_widget_compute_transform (widget, native,
+                                        &surface_transform_data->cached_surface_transform))
+        {
+          surface_transform_data->cached_surface_transform_valid = TRUE;
+        }
+      else
+        {
+          g_warning ("Could not compute surface transform");
+          surface_transform_data->cached_surface_transform_valid = FALSE;
+        }
     }
 
   if (was_valid != surface_transform_data->cached_surface_transform_valid ||
@@ -11413,7 +11420,7 @@ gtk_widget_unregister_surface (GtkWidget    *widget,
  *
  * Returns: (transfer none) (nullable): @widget’s surface.
  */
-GdkSurface*
+GdkSurface *
 gtk_widget_get_surface (GtkWidget *widget)
 {
   GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
@@ -13020,19 +13027,19 @@ gtk_widget_render (GtkWidget            *widget,
   GskRenderNode *root;
   int x, y;
 
-  if (!GTK_IS_ROOT (widget))
+  if (!GTK_IS_NATIVE (widget))
     return;
 
   /* We only render double buffered on native windows */
   if (!gdk_surface_has_native (surface))
     return;
 
-  renderer = gtk_root_get_renderer (GTK_ROOT (widget));
+  renderer = gtk_native_get_renderer (GTK_NATIVE (widget));
   if (renderer == NULL)
     return;
 
   snapshot = gtk_snapshot_new ();
-  gtk_root_get_surface_transform (GTK_ROOT (widget), &x, &y);
+  gtk_native_get_surface_transform (GTK_NATIVE (widget), &x, &y);
   gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
   gtk_widget_snapshot (widget, snapshot);
   root = gtk_snapshot_free_to_node (snapshot);
@@ -13439,7 +13446,7 @@ gtk_widget_set_cursor (GtkWidget *widget,
 
   root = _gtk_widget_get_root (widget);
   if (root)
-    gtk_root_maybe_update_cursor (root, widget, NULL);
+    gtk_window_maybe_update_cursor (GTK_WINDOW (root), widget, NULL);
 
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CURSOR]);
 }


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