[gtk/wip/matthiasc/popup5: 128/220] widget: Use GtkNative



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

    widget: Use GtkNative

 gtk/gtkwidget.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9170e20893..01669d2b60 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 ||
@@ -11415,7 +11422,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);
@@ -13014,7 +13021,7 @@ gtk_widget_snapshot (GtkWidget   *widget,
 
 void
 gtk_widget_render (GtkWidget            *widget,
-                   GdkSurface            *surface,
+                   GdkSurface           *surface,
                    const cairo_region_t *region)
 {
   GtkSnapshot *snapshot;
@@ -13022,19 +13029,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);
@@ -13441,7 +13448,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]