layersurface: Update from phosh
This commit is contained in:
		@ -3,15 +3,12 @@
 | 
				
			|||||||
 * SPDX-License-Identifier: GPL-3.0+
 | 
					 * SPDX-License-Identifier: GPL-3.0+
 | 
				
			||||||
 * Author: Guido Günther <agx@sigxcpu.org>
 | 
					 * Author: Guido Günther <agx@sigxcpu.org>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WARNING: this file is taken directly from phosh, with no modificaions apart from this message. Please update phosh instead of changing this file. Please copy the file back here afterwards, with the same notice.
 | 
					WARNING: this file is taken directly from phosh, with no modificaions apart from this message. Please update phosh instead of changing this file. Please copy the file back here afterwards, with the same notice.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#define G_LOG_DOMAIN "phosh-layer-surface"
 | 
					#define G_LOG_DOMAIN "phosh-layer-surface"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "config.h"
 | 
					#include "config.h"
 | 
				
			||||||
@ -27,8 +24,14 @@ enum {
 | 
				
			|||||||
  PHOSH_LAYER_SURFACE_PROP_LAYER,
 | 
					  PHOSH_LAYER_SURFACE_PROP_LAYER,
 | 
				
			||||||
  PHOSH_LAYER_SURFACE_PROP_KBD_INTERACTIVITY,
 | 
					  PHOSH_LAYER_SURFACE_PROP_KBD_INTERACTIVITY,
 | 
				
			||||||
  PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE,
 | 
					  PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE,
 | 
				
			||||||
 | 
					  PHOSH_LAYER_SURFACE_PROP_MARGIN_TOP,
 | 
				
			||||||
 | 
					  PHOSH_LAYER_SURFACE_PROP_MARGIN_BOTTOM,
 | 
				
			||||||
 | 
					  PHOSH_LAYER_SURFACE_PROP_MARGIN_LEFT,
 | 
				
			||||||
 | 
					  PHOSH_LAYER_SURFACE_PROP_MARGIN_RIGHT,
 | 
				
			||||||
  PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH,
 | 
					  PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH,
 | 
				
			||||||
  PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT,
 | 
					  PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT,
 | 
				
			||||||
 | 
					  PHOSH_LAYER_SURFACE_PROP_CONFIGURED_WIDTH,
 | 
				
			||||||
 | 
					  PHOSH_LAYER_SURFACE_PROP_CONFIGURED_HEIGHT,
 | 
				
			||||||
  PHOSH_LAYER_SURFACE_PROP_NAMESPACE,
 | 
					  PHOSH_LAYER_SURFACE_PROP_NAMESPACE,
 | 
				
			||||||
  PHOSH_LAYER_SURFACE_PROP_LAST_PROP
 | 
					  PHOSH_LAYER_SURFACE_PROP_LAST_PROP
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -50,7 +53,10 @@ typedef struct {
 | 
				
			|||||||
  guint layer;
 | 
					  guint layer;
 | 
				
			||||||
  gboolean kbd_interactivity;
 | 
					  gboolean kbd_interactivity;
 | 
				
			||||||
  gint exclusive_zone;
 | 
					  gint exclusive_zone;
 | 
				
			||||||
 | 
					  gint margin_top, margin_bottom;
 | 
				
			||||||
 | 
					  gint margin_left, margin_right;
 | 
				
			||||||
  gint width, height;
 | 
					  gint width, height;
 | 
				
			||||||
 | 
					  gint configured_width, configured_height;
 | 
				
			||||||
  gchar *namespace;
 | 
					  gchar *namespace;
 | 
				
			||||||
  struct zwlr_layer_shell_v1 *layer_shell;
 | 
					  struct zwlr_layer_shell_v1 *layer_shell;
 | 
				
			||||||
  struct wl_output *wl_output;
 | 
					  struct wl_output *wl_output;
 | 
				
			||||||
@ -65,10 +71,24 @@ static void layer_surface_configure(void                         *data,
 | 
				
			|||||||
                                    uint32_t                      height)
 | 
					                                    uint32_t                      height)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PhoshLayerSurface *self = data;
 | 
					  PhoshLayerSurface *self = data;
 | 
				
			||||||
 | 
					  PhoshLayerSurfacePrivate *priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
 | 
				
			||||||
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
  gtk_window_resize (GTK_WINDOW (self), width, height);
 | 
					  gtk_window_resize (GTK_WINDOW (self), width, height);
 | 
				
			||||||
  zwlr_layer_surface_v1_ack_configure(surface, serial);
 | 
					  zwlr_layer_surface_v1_ack_configure(surface, serial);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->configured_height != height) {
 | 
				
			||||||
 | 
					    priv->configured_height = height;
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_CONFIGURED_HEIGHT]);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->configured_width != width) {
 | 
				
			||||||
 | 
					    priv->configured_width = width;
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_CONFIGURED_WIDTH]);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_debug("Configured %p", self);
 | 
				
			||||||
  g_signal_emit (self, signals[CONFIGURED], 0);
 | 
					  g_signal_emit (self, signals[CONFIGURED], 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -98,6 +118,7 @@ phosh_layer_surface_set_property (GObject      *object,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  PhoshLayerSurface *self = PHOSH_LAYER_SURFACE (object);
 | 
					  PhoshLayerSurface *self = PHOSH_LAYER_SURFACE (object);
 | 
				
			||||||
  PhoshLayerSurfacePrivate *priv = phosh_layer_surface_get_instance_private (self);
 | 
					  PhoshLayerSurfacePrivate *priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
 | 
					  gint width, height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (property_id) {
 | 
					  switch (property_id) {
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_LAYER_SHELL:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_LAYER_SHELL:
 | 
				
			||||||
@ -113,16 +134,46 @@ phosh_layer_surface_set_property (GObject      *object,
 | 
				
			|||||||
    priv->layer = g_value_get_uint (value);
 | 
					    priv->layer = g_value_get_uint (value);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_KBD_INTERACTIVITY:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_KBD_INTERACTIVITY:
 | 
				
			||||||
    priv->kbd_interactivity = g_value_get_boolean (value);
 | 
					    phosh_layer_surface_set_kbd_interactivity (self, g_value_get_boolean (value));
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE:
 | 
				
			||||||
    priv->exclusive_zone = g_value_get_int (value);
 | 
					    phosh_layer_surface_set_exclusive_zone (self, g_value_get_int (value));
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_TOP:
 | 
				
			||||||
 | 
					    phosh_layer_surface_set_margins (self,
 | 
				
			||||||
 | 
					                                     g_value_get_int (value),
 | 
				
			||||||
 | 
					                                     priv->margin_right,
 | 
				
			||||||
 | 
					                                     priv->margin_bottom,
 | 
				
			||||||
 | 
					                                     priv->margin_left);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_BOTTOM:
 | 
				
			||||||
 | 
					    phosh_layer_surface_set_margins (self,
 | 
				
			||||||
 | 
					                                     priv->margin_top,
 | 
				
			||||||
 | 
					                                     priv->margin_right,
 | 
				
			||||||
 | 
					                                     g_value_get_int (value),
 | 
				
			||||||
 | 
					                                     priv->margin_left);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_LEFT:
 | 
				
			||||||
 | 
					    phosh_layer_surface_set_margins (self,
 | 
				
			||||||
 | 
					                                     priv->margin_top,
 | 
				
			||||||
 | 
					                                     priv->margin_right,
 | 
				
			||||||
 | 
					                                     priv->margin_bottom,
 | 
				
			||||||
 | 
					                                     g_value_get_int (value));
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_RIGHT:
 | 
				
			||||||
 | 
					    phosh_layer_surface_set_margins (self,
 | 
				
			||||||
 | 
					                                     priv->margin_top,
 | 
				
			||||||
 | 
					                                     g_value_get_int (value),
 | 
				
			||||||
 | 
					                                     priv->margin_bottom,
 | 
				
			||||||
 | 
					                                     priv->margin_left);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH:
 | 
				
			||||||
    priv->width = g_value_get_uint (value);
 | 
					    width = g_value_get_uint (value);
 | 
				
			||||||
 | 
					    phosh_layer_surface_set_size(self, width, priv->height);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT:
 | 
				
			||||||
    priv->height = g_value_get_uint (value);
 | 
					    height = g_value_get_uint (value);
 | 
				
			||||||
 | 
					    phosh_layer_surface_set_size(self, priv->width, height);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_NAMESPACE:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_NAMESPACE:
 | 
				
			||||||
    g_free (priv->namespace);
 | 
					    g_free (priv->namespace);
 | 
				
			||||||
@ -161,7 +212,19 @@ phosh_layer_surface_get_property (GObject    *object,
 | 
				
			|||||||
    g_value_set_boolean (value, priv->kbd_interactivity);
 | 
					    g_value_set_boolean (value, priv->kbd_interactivity);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE:
 | 
				
			||||||
    g_value_set_boolean (value, priv->exclusive_zone);
 | 
					    g_value_set_int (value, priv->exclusive_zone);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_TOP:
 | 
				
			||||||
 | 
					    g_value_set_int (value, priv->margin_top);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_BOTTOM:
 | 
				
			||||||
 | 
					    g_value_set_int (value, priv->margin_bottom);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_LEFT:
 | 
				
			||||||
 | 
					    g_value_set_int (value, priv->margin_left);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_MARGIN_RIGHT:
 | 
				
			||||||
 | 
					    g_value_set_int (value, priv->margin_right);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH:
 | 
				
			||||||
    g_value_set_uint (value, priv->width);
 | 
					    g_value_set_uint (value, priv->width);
 | 
				
			||||||
@ -169,6 +232,12 @@ phosh_layer_surface_get_property (GObject    *object,
 | 
				
			|||||||
  case PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT:
 | 
				
			||||||
    g_value_set_uint (value, priv->height);
 | 
					    g_value_set_uint (value, priv->height);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_CONFIGURED_WIDTH:
 | 
				
			||||||
 | 
					    g_value_set_uint (value, priv->configured_width);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case PHOSH_LAYER_SURFACE_PROP_CONFIGURED_HEIGHT:
 | 
				
			||||||
 | 
					    g_value_set_uint (value, priv->configured_height);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
  case PHOSH_LAYER_SURFACE_PROP_NAMESPACE:
 | 
					  case PHOSH_LAYER_SURFACE_PROP_NAMESPACE:
 | 
				
			||||||
    g_value_set_string (value, priv->namespace);
 | 
					    g_value_set_string (value, priv->namespace);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
@ -221,6 +290,11 @@ on_phosh_layer_surface_mapped (PhoshLayerSurface *self, gpointer unused)
 | 
				
			|||||||
  zwlr_layer_surface_v1_set_exclusive_zone(priv->layer_surface, priv->exclusive_zone);
 | 
					  zwlr_layer_surface_v1_set_exclusive_zone(priv->layer_surface, priv->exclusive_zone);
 | 
				
			||||||
  zwlr_layer_surface_v1_set_size(priv->layer_surface, priv->width, priv->height);
 | 
					  zwlr_layer_surface_v1_set_size(priv->layer_surface, priv->width, priv->height);
 | 
				
			||||||
  zwlr_layer_surface_v1_set_anchor(priv->layer_surface, priv->anchor);
 | 
					  zwlr_layer_surface_v1_set_anchor(priv->layer_surface, priv->anchor);
 | 
				
			||||||
 | 
					  zwlr_layer_surface_v1_set_margin(priv->layer_surface,
 | 
				
			||||||
 | 
					                                   priv->margin_top,
 | 
				
			||||||
 | 
					                                   priv->margin_right,
 | 
				
			||||||
 | 
					                                   priv->margin_bottom,
 | 
				
			||||||
 | 
					                                   priv->margin_left);
 | 
				
			||||||
  zwlr_layer_surface_v1_set_keyboard_interactivity(priv->layer_surface, priv->kbd_interactivity);
 | 
					  zwlr_layer_surface_v1_set_keyboard_interactivity(priv->layer_surface, priv->kbd_interactivity);
 | 
				
			||||||
  zwlr_layer_surface_v1_add_listener(priv->layer_surface,
 | 
					  zwlr_layer_surface_v1_add_listener(priv->layer_surface,
 | 
				
			||||||
                                     &layer_surface_listener,
 | 
					                                     &layer_surface_listener,
 | 
				
			||||||
@ -262,6 +336,8 @@ phosh_layer_surface_constructed (GObject *object)
 | 
				
			|||||||
  g_signal_connect (self, "unmap",
 | 
					  g_signal_connect (self, "unmap",
 | 
				
			||||||
                    G_CALLBACK (on_phosh_layer_surface_unmapped),
 | 
					                    G_CALLBACK (on_phosh_layer_surface_unmapped),
 | 
				
			||||||
                    NULL);
 | 
					                    NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  G_OBJECT_CLASS (phosh_layer_surface_parent_class)->constructed (object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -332,7 +408,7 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass)
 | 
				
			|||||||
      "Keyboard interactivity",
 | 
					      "Keyboard interactivity",
 | 
				
			||||||
      "Whether the surface interacts with the keyboard",
 | 
					      "Whether the surface interacts with the keyboard",
 | 
				
			||||||
      FALSE,
 | 
					      FALSE,
 | 
				
			||||||
      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  props[PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE] =
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE] =
 | 
				
			||||||
    g_param_spec_int (
 | 
					    g_param_spec_int (
 | 
				
			||||||
@ -342,7 +418,47 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass)
 | 
				
			|||||||
      -1,
 | 
					      -1,
 | 
				
			||||||
      G_MAXINT,
 | 
					      G_MAXINT,
 | 
				
			||||||
      0,
 | 
					      0,
 | 
				
			||||||
      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_MARGIN_LEFT] =
 | 
				
			||||||
 | 
					    g_param_spec_int (
 | 
				
			||||||
 | 
					      "margin-left",
 | 
				
			||||||
 | 
					      "Left margin",
 | 
				
			||||||
 | 
					      "Distance away from the left anchor point",
 | 
				
			||||||
 | 
					      G_MININT,
 | 
				
			||||||
 | 
					      G_MAXINT,
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_MARGIN_RIGHT] =
 | 
				
			||||||
 | 
					    g_param_spec_int (
 | 
				
			||||||
 | 
					      "margin-right",
 | 
				
			||||||
 | 
					      "Right margin",
 | 
				
			||||||
 | 
					      "Distance away from the right anchor point",
 | 
				
			||||||
 | 
					      G_MININT,
 | 
				
			||||||
 | 
					      G_MAXINT,
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_MARGIN_TOP] =
 | 
				
			||||||
 | 
					    g_param_spec_int (
 | 
				
			||||||
 | 
					      "margin-top",
 | 
				
			||||||
 | 
					      "Top margin",
 | 
				
			||||||
 | 
					      "Distance away from the top anchor point",
 | 
				
			||||||
 | 
					      G_MININT,
 | 
				
			||||||
 | 
					      G_MAXINT,
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_MARGIN_BOTTOM] =
 | 
				
			||||||
 | 
					    g_param_spec_int (
 | 
				
			||||||
 | 
					      "margin-bottom",
 | 
				
			||||||
 | 
					      "Bottom margin",
 | 
				
			||||||
 | 
					      "Distance away from the bottom anchor point",
 | 
				
			||||||
 | 
					      G_MININT,
 | 
				
			||||||
 | 
					      G_MAXINT,
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  props[PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH] =
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH] =
 | 
				
			||||||
    g_param_spec_uint (
 | 
					    g_param_spec_uint (
 | 
				
			||||||
@ -352,7 +468,7 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass)
 | 
				
			|||||||
      0,
 | 
					      0,
 | 
				
			||||||
      G_MAXUINT,
 | 
					      G_MAXUINT,
 | 
				
			||||||
      0,
 | 
					      0,
 | 
				
			||||||
      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  props[PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT] =
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_LAYER_HEIGHT] =
 | 
				
			||||||
    g_param_spec_uint (
 | 
					    g_param_spec_uint (
 | 
				
			||||||
@ -362,7 +478,28 @@ phosh_layer_surface_class_init (PhoshLayerSurfaceClass *klass)
 | 
				
			|||||||
      0,
 | 
					      0,
 | 
				
			||||||
      G_MAXUINT,
 | 
					      G_MAXUINT,
 | 
				
			||||||
      0,
 | 
					      0,
 | 
				
			||||||
      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 | 
					      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_CONFIGURED_WIDTH] =
 | 
				
			||||||
 | 
					    g_param_spec_uint (
 | 
				
			||||||
 | 
					      "configured-width",
 | 
				
			||||||
 | 
					      "Configured width",
 | 
				
			||||||
 | 
					      "The width of the layer surface set by the compositor",
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_MAXUINT,
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_CONFIGURED_HEIGHT] =
 | 
				
			||||||
 | 
					    g_param_spec_uint (
 | 
				
			||||||
 | 
					      "configured-height",
 | 
				
			||||||
 | 
					      "Configured height",
 | 
				
			||||||
 | 
					      "The height of the layer surface set by the compositor",
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_MAXUINT,
 | 
				
			||||||
 | 
					      0,
 | 
				
			||||||
 | 
					      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  props[PHOSH_LAYER_SURFACE_PROP_NAMESPACE] =
 | 
					  props[PHOSH_LAYER_SURFACE_PROP_NAMESPACE] =
 | 
				
			||||||
    g_param_spec_string (
 | 
					    g_param_spec_string (
 | 
				
			||||||
@ -438,3 +575,148 @@ phosh_layer_surface_get_wl_surface(PhoshLayerSurface *self)
 | 
				
			|||||||
  priv = phosh_layer_surface_get_instance_private (self);
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
  return priv->wl_surface;
 | 
					  return priv->wl_surface;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * phosh_layer_surface_set_size:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Set the size of a layer surface. A value of '-1' indicates 'use old value'
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					phosh_layer_surface_set_size(PhoshLayerSurface *self, gint width, gint height)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PhoshLayerSurfacePrivate *priv;
 | 
				
			||||||
 | 
					  gint old_width, old_height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
 | 
				
			||||||
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->height == height && priv->width == width)
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  old_width = priv->width;
 | 
				
			||||||
 | 
					  old_height = priv->height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (width != -1)
 | 
				
			||||||
 | 
					    priv->width = width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (height != -1)
 | 
				
			||||||
 | 
					    priv->height = 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]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->width != old_width)
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_LAYER_WIDTH]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * phosh_layer_surface_set_margins:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Set anchor margins of a layer surface.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					phosh_layer_surface_set_margins(PhoshLayerSurface *self, gint top, gint right, gint bottom, gint left)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PhoshLayerSurfacePrivate *priv;
 | 
				
			||||||
 | 
					  gint old_top, old_bottom, old_left, old_right;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
 | 
				
			||||||
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  old_top = priv->margin_top;
 | 
				
			||||||
 | 
					  old_left = priv->margin_left;
 | 
				
			||||||
 | 
					  old_right = priv->margin_right;
 | 
				
			||||||
 | 
					  old_bottom = priv->margin_bottom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (old_top == top && old_left == left && old_right == right && old_bottom == bottom)
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  priv->margin_top = top;
 | 
				
			||||||
 | 
					  priv->margin_left = left;
 | 
				
			||||||
 | 
					  priv->margin_right = right;
 | 
				
			||||||
 | 
					  priv->margin_bottom = bottom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->layer_surface)
 | 
				
			||||||
 | 
					    zwlr_layer_surface_v1_set_margin(priv->layer_surface, top, right, bottom, left);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (old_top != top)
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_MARGIN_TOP]);
 | 
				
			||||||
 | 
					  if (old_bottom != bottom)
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_MARGIN_BOTTOM]);
 | 
				
			||||||
 | 
					  if (old_left != left)
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_MARGIN_LEFT]);
 | 
				
			||||||
 | 
					  if (old_right != right)
 | 
				
			||||||
 | 
					    g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_MARGIN_RIGHT]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * phosh_layer_surface_set_exclusive_zone:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Set exclusive zone of a layer surface.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					phosh_layer_surface_set_exclusive_zone(PhoshLayerSurface *self, gint zone)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PhoshLayerSurfacePrivate *priv;
 | 
				
			||||||
 | 
					  gint old_zone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
 | 
				
			||||||
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  old_zone = priv->exclusive_zone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (old_zone == zone)
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  priv->exclusive_zone = zone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->layer_surface)
 | 
				
			||||||
 | 
					    zwlr_layer_surface_v1_set_exclusive_zone(priv->layer_surface, zone);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_EXCLUSIVE_ZONE]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * phosh_layer_surface_set_keyboard_interactivity:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Set keyboard ineractivity a layer surface.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					phosh_layer_surface_set_kbd_interactivity (PhoshLayerSurface *self, gboolean interactivity)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PhoshLayerSurfacePrivate *priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
 | 
				
			||||||
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (priv->kbd_interactivity == interactivity)
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  priv->kbd_interactivity = interactivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->layer_surface)
 | 
				
			||||||
 | 
					    zwlr_layer_surface_v1_set_keyboard_interactivity (priv->layer_surface, interactivity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LAYER_SURFACE_PROP_KBD_INTERACTIVITY]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * phosh_layer_surface_wl_surface_commit:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Forces a commit of layer surface's state.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					phosh_layer_surface_wl_surface_commit (PhoshLayerSurface *self)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PhoshLayerSurfacePrivate *priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
 | 
				
			||||||
 | 
					  priv = phosh_layer_surface_get_instance_private (self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (priv->wl_surface)
 | 
				
			||||||
 | 
					    wl_surface_commit (priv->wl_surface);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,6 @@ WARNING: this file is taken directly from phosh, with no modificaions apart from
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <gtk/gtk.h>
 | 
					#include <gtk/gtk.h>
 | 
				
			||||||
@ -39,3 +38,16 @@ GtkWidget *phosh_layer_surface_new (gpointer layer_shell,
 | 
				
			|||||||
                                    gpointer wl_output);
 | 
					                                    gpointer wl_output);
 | 
				
			||||||
struct     zwlr_layer_surface_v1 *phosh_layer_surface_get_layer_surface(PhoshLayerSurface *self);
 | 
					struct     zwlr_layer_surface_v1 *phosh_layer_surface_get_layer_surface(PhoshLayerSurface *self);
 | 
				
			||||||
struct     wl_surface            *phosh_layer_surface_get_wl_surface(PhoshLayerSurface *self);
 | 
					struct     wl_surface            *phosh_layer_surface_get_wl_surface(PhoshLayerSurface *self);
 | 
				
			||||||
 | 
					void                              phosh_layer_surface_set_size(PhoshLayerSurface *self,
 | 
				
			||||||
 | 
					                                                               gint width,
 | 
				
			||||||
 | 
					                                                               gint height);
 | 
				
			||||||
 | 
					void                              phosh_layer_surface_set_margins(PhoshLayerSurface *self,
 | 
				
			||||||
 | 
					                                                                  gint top,
 | 
				
			||||||
 | 
					                                                                  gint right,
 | 
				
			||||||
 | 
					                                                                  gint bottom,
 | 
				
			||||||
 | 
					                                                                  gint left);
 | 
				
			||||||
 | 
					void                              phosh_layer_surface_set_exclusive_zone(PhoshLayerSurface *self,
 | 
				
			||||||
 | 
					                                                                         gint zone);
 | 
				
			||||||
 | 
					void                              phosh_layer_surface_set_kbd_interactivity(PhoshLayerSurface *self,
 | 
				
			||||||
 | 
					                                                                            gboolean interactivity);
 | 
				
			||||||
 | 
					void                              phosh_layer_surface_wl_surface_commit (PhoshLayerSurface *self);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user