[gtk/wip/matthiasc/popup4: 39/94] popover: Stop using gtk_widget_register_surface



commit f409cf775e4583442bc34ef86f6121b175f1f01b
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 5e849d9d09..a852361539 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -353,12 +353,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,
@@ -434,10 +452,12 @@ gtk_popover_realize (GtkWidget *widget)
   priv->surface = gdk_surface_new_popup_full (priv->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);
 
@@ -457,6 +477,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]