[gtk/matthiasc/surface-state-rework: 49/80] gdk: Remove GdkSurface::size-changed




commit 60240268e7e7af4fd60beab205888d066c0e4a21
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Dec 2 17:08:07 2020 +0100

    gdk: Remove GdkSurface::size-changed
    
    It's not emitted, and everyone should use the GdkSurface::layout signal
    from now on.

 docs/reference/gtk/migrating-3to4.md |  2 +-
 gdk/gdksurface.c                     | 33 ---------------------------------
 gtk/gtkpopover.c                     |  9 ---------
 gtk/gtkwindow.c                      |  2 --
 tests/testwindowsize.c               | 23 ++++++++++++++++++-----
 5 files changed, 19 insertions(+), 50 deletions(-)
---
diff --git a/docs/reference/gtk/migrating-3to4.md b/docs/reference/gtk/migrating-3to4.md
index 8a4fc9f32e..95847872f7 100644
--- a/docs/reference/gtk/migrating-3to4.md
+++ b/docs/reference/gtk/migrating-3to4.md
@@ -165,7 +165,7 @@ for this change.
 | ::key-release-event | #GtkEventControllerKey |
 | ::enter-notify-event | #GtkEventControllerMotion |
 | ::leave-notify-event | #GtkEventControllerMotion |
-| ::configure-event | replaced by #GdkSurface::size-changed |
+| ::configure-event | replaced by #GdkSurface::layout |
 | ::focus-in-event | #GtkEventControllerFocus |
 | ::focus-out-event | #GtkEventControllerFocus |
 | ::map-event | replaced by #GdkSurface:mapped |
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 0225397f5d..2c52e551f3 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -76,7 +76,6 @@
  */
 
 enum {
-  SIZE_CHANGED,
   LAYOUT,
   RENDER,
   EVENT,
@@ -551,30 +550,6 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
 
   g_object_class_install_properties (object_class, LAST_PROP, properties);
 
-  /**
-   * GdkSurface::size-changed:
-   * @surface: the #GdkSurface
-   * @width: the new width
-   * @height: the new height
-   *
-   * Emitted when the size of @surface is changed.
-   *
-   * Surface size is reported in ”application pixels”, not
-   * ”device pixels” (see gdk_surface_get_scale_factor()).
-   */
-  signals[SIZE_CHANGED] =
-    g_signal_new (g_intern_static_string ("size-changed"),
-                  G_OBJECT_CLASS_TYPE (object_class),
-                  G_SIGNAL_RUN_FIRST,
-                  0,
-                  NULL,
-                  NULL,
-                  NULL,
-                  G_TYPE_NONE,
-                  2,
-                  G_TYPE_INT,
-                  G_TYPE_INT);
-
   /**
    * GdkSurface::layout:
    * @surface: the #GdkSurface
@@ -1306,14 +1281,6 @@ gdk_surface_schedule_update (GdkSurface *surface)
                                    GDK_FRAME_CLOCK_PHASE_PAINT);
 }
 
-void
-gdk_surface_emit_size_changed (GdkSurface *surface,
-                               int         width,
-                               int         height)
-{
-  g_signal_emit (surface, signals[SIZE_CHANGED], 0, width, height);
-}
-
 static void
 gdk_surface_process_updates_internal (GdkSurface *surface)
 {
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index bb2a171864..7fcfac9b66 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -748,13 +748,6 @@ surface_mapped_changed (GtkWidget *widget)
   gtk_widget_set_visible (widget, gdk_surface_get_mapped (priv->surface));
 }
 
-static void
-surface_size_changed (GtkWidget *widget,
-                      guint      width,
-                      guint      height)
-{
-}
-
 static gboolean
 surface_render (GdkSurface     *surface,
                 cairo_region_t *region,
@@ -899,7 +892,6 @@ gtk_popover_realize (GtkWidget *widget)
   gdk_surface_set_widget (priv->surface, widget);
 
   g_signal_connect_swapped (priv->surface, "notify::mapped", G_CALLBACK (surface_mapped_changed), widget);
-  g_signal_connect_swapped (priv->surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
   g_signal_connect (priv->surface, "render", G_CALLBACK (surface_render), widget);
   g_signal_connect (priv->surface, "event", G_CALLBACK (surface_event), widget);
   g_signal_connect (priv->surface, "popup-layout-changed", G_CALLBACK (popup_layout_changed), widget);
@@ -925,7 +917,6 @@ gtk_popover_unrealize (GtkWidget *widget)
   g_clear_object (&priv->renderer);
 
   g_signal_handlers_disconnect_by_func (priv->surface, surface_mapped_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);
   g_signal_handlers_disconnect_by_func (priv->surface, popup_layout_changed, widget);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index aed818e9ce..0b63ac5f57 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4368,7 +4368,6 @@ gtk_window_realize (GtkWidget *widget)
     priv->renderer = gsk_renderer_new_for_surface (surface);
 
   g_signal_connect_swapped (surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
-  g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
   g_signal_connect (surface, "render", G_CALLBACK (surface_render), widget);
   g_signal_connect (surface, "event", G_CALLBACK (surface_event), widget);
   g_signal_connect (surface, "compute-size", G_CALLBACK (toplevel_compute_size), widget);
@@ -4476,7 +4475,6 @@ gtk_window_unrealize (GtkWidget *widget)
   surface = priv->surface;
 
   g_signal_handlers_disconnect_by_func (surface, surface_state_changed, widget);
-  g_signal_handlers_disconnect_by_func (surface, surface_size_changed, widget);
   g_signal_handlers_disconnect_by_func (surface, surface_render, widget);
   g_signal_handlers_disconnect_by_func (surface, surface_event, widget);
 
diff --git a/tests/testwindowsize.c b/tests/testwindowsize.c
index e6539c7ae0..f61669b204 100644
--- a/tests/testwindowsize.c
+++ b/tests/testwindowsize.c
@@ -8,14 +8,27 @@ static GtkWidget *default_width_spin;
 static GtkWidget *default_height_spin;
 static GtkWidget *resizable_check;
 
-static void
-size_changed_cb (GdkSurface *surface, int width, int height, GtkLabel *label)
+static gboolean
+set_label_idle (gpointer user_data)
 {
+  GtkLabel *label = user_data;
+  GtkNative *native = gtk_widget_get_native (GTK_WIDGET (label));
+  GdkSurface *surface = gtk_native_get_surface (native);
   char *str;
 
-  str = g_strdup_printf ("%d x %d", width, height);
+  str = g_strdup_printf ("%d x %d",
+                         gdk_surface_get_width (surface),
+                         gdk_surface_get_height (surface));
   gtk_label_set_label (label, str);
   g_free (str);
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+layout_cb (GdkSurface *surface, int width, int height, GtkLabel *label)
+{
+  g_idle_add (set_label_idle, label);
 }
 
 static void
@@ -63,8 +76,8 @@ show_dialog (void)
 
   gtk_dialog_add_action_widget (GTK_DIALOG (dialog), label, GTK_RESPONSE_HELP);
   gtk_widget_realize (dialog);
-  g_signal_connect (gtk_native_get_surface (GTK_NATIVE (dialog)), "size-changed",
-                    G_CALLBACK (size_changed_cb), label);
+  g_signal_connect (gtk_native_get_surface (GTK_NATIVE (dialog)), "layout",
+                    G_CALLBACK (layout_cb), label);
   g_signal_connect (dialog, "response",
                     G_CALLBACK (gtk_window_destroy),
                     NULL);


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