[gtk/wip/matthiasc/popup5: 54/145] popover: Stop using gtk_widget_register_surface



commit 6da403826e1f7ede4960913784c76a6076802f6a
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Apr 19 20:14:44 2019 +0000

    popover: Stop using gtk_widget_register_surface
    
    The GtkRoot implementations are expected to handle
    the necessary surface setup themselves, going forward.

 gtk/gtkpopover.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 9f0830e8de..98c54083c3 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -356,12 +356,30 @@ surface_state_changed (GtkWidget *widget)
 }
 
 static void
-surface_size_changed (GtkWindow *window,
+surface_size_changed (GtkWidget *widget,
                       guint      width,
                       guint      height)
 {
 }
 
+static gboolean
+surface_render (GdkSurface     *surface,
+                cairo_region_t *region,
+                GtkWidget      *widget)
+{
+  gtk_widget_render (widget, surface, region);
+  return TRUE;
+}
+
+static gboolean
+surface_event (GdkSurface *surface,
+               GdkEvent   *event,
+               GtkWidget  *widget)
+{
+  gtk_main_do_event (event);
+  return TRUE;
+}
+
 static void
 measure_contents (GtkGizmo       *gizmo,
                   GtkOrientation  orientation,
@@ -479,10 +497,12 @@ gtk_popover_realize (GtkWidget *widget)
   priv->surface = gdk_surface_new_popup_full (display, gtk_widget_get_surface (priv->relative_to));
 
   gtk_widget_set_surface (widget, priv->surface);
+  gdk_surface_set_widget (priv->surface, widget);
+
   g_signal_connect_swapped (priv->surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
   g_signal_connect_swapped (priv->surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
-
-  gtk_widget_register_surface (widget, priv->surface);
+  g_signal_connect (priv->surface, "render", G_CALLBACK (surface_render), widget);
+  g_signal_connect (priv->surface, "event", G_CALLBACK (surface_event), widget);
 
   GTK_WIDGET_CLASS (gtk_popover_parent_class)->realize (widget);
 
@@ -502,6 +522,9 @@ gtk_popover_unrealize (GtkWidget *widget)
 
   g_signal_handlers_disconnect_by_func (priv->surface, surface_state_changed, widget);
   g_signal_handlers_disconnect_by_func (priv->surface, surface_size_changed, widget);
+  g_signal_handlers_disconnect_by_func (priv->surface, surface_render, widget);
+  g_signal_handlers_disconnect_by_func (priv->surface, surface_event, widget);
+  gdk_surface_set_widget (priv->surface, NULL);
 
   g_clear_object (&priv->surface);
 }


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