From d7951f5ed656165e9faed5cb16b78e95b330fd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 19 Oct 2019 14:00:43 +0200 Subject: [PATCH] layer-surface: Don't make width/height construct only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use phosh_layer_surface_set_size which results in more calls to zwlr_layer_surface_v1_set_size but that won't matter since the actual size change happens at the surface's commit time. Signed-off-by: Guido Günther --- src/layersurface.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/layersurface.c b/src/layersurface.c index 34a65019..a5ba8d99 100644 --- a/src/layersurface.c +++ b/src/layersurface.c @@ -110,6 +110,7 @@ phosh_layer_surface_set_property (GObject *object, { PhoshLayerSurface *self = PHOSH_LAYER_SURFACE (object); PhoshLayerSurfacePrivate *priv = phosh_layer_surface_get_instance_private (self); + gint width, height; switch (property_id) { case PHOSH_LAYER_SURFACE_PROP_LAYER_SHELL: @@ -159,14 +160,12 @@ phosh_layer_surface_set_property (GObject *object, priv->margin_left); break; case PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH: - priv->width = g_value_get_uint (value); - /* construct-only, so we can always emit the signal */ - g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH]); + width = g_value_get_uint (value); + phosh_layer_surface_set_size(self, width, priv->height); break; case PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT: - priv->height = g_value_get_uint (value); - /* construct-only, so we can always emit the signal */ - g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT]); + height = g_value_get_uint (value); + phosh_layer_surface_set_size(self, priv->width, height); break; case PHOSH_LAYER_SURFACE_PROP_NAMESPACE: g_free (priv->namespace); @@ -447,10 +446,6 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass) 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); - /* - * construct only since we don't want width height to be set individually - * but rather through set_size to avoid multiple calls to zwlr_layer_surface_v1_set_size - */ props[PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH] = g_param_spec_uint ( "width", @@ -459,7 +454,7 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass) 0, G_MAXUINT, 0, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); props[PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT] = g_param_spec_uint ( @@ -469,7 +464,7 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass) 0, G_MAXUINT, 0, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); props[PHOSH_LAYER_SURFACE_PROP_NAMESPACE] = g_param_spec_string ( @@ -572,7 +567,9 @@ phosh_layer_surface_set_size(PhoshLayerSurface *self, gint width, gint height) if (height != -1) priv->height = height; - zwlr_layer_surface_v1_set_size(priv->layer_surface, priv->width, priv->height); + if (gtk_widget_get_mapped (GTK_WIDGET (self))) { + zwlr_layer_surface_v1_set_size(priv->layer_surface, priv->width, priv->height); + } if (priv->height != old_height) g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT]); -- 2.26.2