[gtk/wip/matthiasc/popup5: 131/145] surface: Make surface-type a property



commit 0ad31ecce470897e2e4853ae4f31d2dce19da5fa
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 22 22:35:09 2019 +0000

    surface: Make surface-type a property
    
    Make surface-type a construct-only property,
    so we can set it before the frame clock.

 gdk/broadway/gdksurface-broadway.c |  2 +-
 gdk/gdksurface.c                   | 16 ++++++++++++++++
 gdk/wayland/gdksurface-wayland.c   |  2 +-
 gdk/x11/gdksurface-x11.c           |  2 +-
 4 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index db46f56f87..6c3af4c95a 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -209,13 +209,13 @@ _gdk_broadway_display_create_surface (GdkDisplay     *display,
   frame_clock = _gdk_frame_clock_idle_new ();
 
   surface = g_object_new (GDK_TYPE_BROADWAY_SURFACE,
+                          "surface-type", surface_type,
                           "display", display,
                           "frame-clock", frame_clock,
                           NULL);
 
   g_object_unref (frame_clock);
 
-  surface->surface_type = surface_type;
   surface->parent = parent;
   surface->x = x;
   surface->y = y;
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 8a610e18fd..e5807600f0 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -77,6 +77,7 @@ enum {
 
 enum {
   PROP_0,
+  PROP_SURFACE_TYPE,
   PROP_CURSOR,
   PROP_DISPLAY,
   PROP_PARENT,
@@ -473,6 +474,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
                             FALSE,
                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
 
+  properties[PROP_SURFACE_TYPE] =
+      g_param_spec_enum ("surface-type",
+                          P_("Surface type"),
+                          P_("Surface type"),
+                          GDK_TYPE_SURFACE_TYPE, GDK_SURFACE_TOPLEVEL,
+                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
   g_object_class_install_properties (object_class, LAST_PROP, properties);
 
   /**
@@ -653,6 +661,10 @@ gdk_surface_set_property (GObject      *object,
       surface->autohide = g_value_get_boolean (value);
       break;
 
+    case PROP_SURFACE_TYPE:
+      surface->surface_type = g_value_get_enum (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -697,6 +709,10 @@ gdk_surface_get_property (GObject    *object,
       g_value_set_boolean (value, surface->autohide);
       break;
 
+    case PROP_SURFACE_TYPE:
+      g_value_set_enum (value, surface->surface_type);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index b3dafbaf4f..f7bd5c9f9d 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -516,6 +516,7 @@ _gdk_wayland_display_create_surface (GdkDisplay     *display,
     frame_clock = _gdk_frame_clock_idle_new ();
 
   surface = g_object_new (GDK_TYPE_WAYLAND_SURFACE,
+                          "surface-type", surface_type,
                           "display", display,
                           "parent", parent,
                           "frame-clock", frame_clock,
@@ -534,7 +535,6 @@ _gdk_wayland_display_create_surface (GdkDisplay     *display,
       height = 65535;
     }
 
-  surface->surface_type = surface_type;
   surface->x = x;
   surface->y = y;
   surface->width = width;
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 64a1d11cca..dc12f44f0a 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -820,13 +820,13 @@ _gdk_x11_display_create_surface (GdkDisplay     *display,
     frame_clock = _gdk_frame_clock_idle_new ();
 
   surface = g_object_new (GDK_TYPE_X11_SURFACE,
+                          "surface-type", surface_type,
                           "display", display,
                           "frame-clock", frame_clock,
                           NULL);
 
   g_object_unref (frame_clock);
 
-  surface->surface_type = surface_type;
   surface->parent = parent;
   surface->x = x;
   surface->y = y;


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