Commit cb7b20eb authored by Guido Gunther's avatar Guido Gunther

PhoshLayerSurface: Destroy layer surface on unmap

This and moving some of the initilization from `realized` to `mapped`
allows us to properly `gtk_widget_{show,hide}()` layer surface widgets.

This is brought over from squeekboard
c3a54595ea72638fbc7b65ffc3c26966de772e15
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 1d91e2a8
Pipeline #24706 passed with stages
in 5 minutes and 7 seconds
......@@ -184,10 +184,27 @@ on_phosh_layer_surface_realized (PhoshLayerSurface *self, gpointer unused)
gdk_window = gtk_widget_get_window (GTK_WIDGET (self));
gdk_wayland_window_set_use_custom_surface (gdk_window);
priv->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window);
phosh_wayland_roundtrip (phosh_wayland_get_default());
gtk_window_set_decorated (GTK_WINDOW (self), FALSE);
}
priv->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window);
static void
on_phosh_layer_surface_mapped (PhoshLayerSurface *self, gpointer unused)
{
PhoshLayerSurfacePrivate *priv;
GdkWindow *gdk_window;
g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
priv = phosh_layer_surface_get_instance_private (self);
if (!priv->wl_surface) {
gdk_window = gtk_widget_get_window (GTK_WIDGET (self));
gdk_wayland_window_set_use_custom_surface (gdk_window);
priv->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window);
}
g_debug ("Mapped %p", priv->wl_surface);
priv->layer_surface = zwlr_layer_shell_v1_get_layer_surface(priv->layer_shell,
priv->wl_surface,
......@@ -203,18 +220,26 @@ on_phosh_layer_surface_realized (PhoshLayerSurface *self, gpointer unused)
self);
wl_surface_commit(priv->wl_surface);
gtk_window_set_decorated (GTK_WINDOW (self), FALSE);
/* Process all pending events, otherwise we end up sending ack configure
* to a not yet configured surface */
wl_display_roundtrip (gdk_wayland_display_get_wl_display (gdk_display_get_default ()));
}
static void
on_phosh_layer_surface_mapped (PhoshLayerSurface *self, gpointer unused)
on_phosh_layer_surface_unmapped (PhoshLayerSurface *self, gpointer unused)
{
/* Process all pending events, otherwise we end up sending ack configure
* to a not yet configured surface */
phosh_wayland_roundtrip (phosh_wayland_get_default());
}
PhoshLayerSurfacePrivate *priv;
g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
priv = phosh_layer_surface_get_instance_private (self);
priv = phosh_layer_surface_get_instance_private (self);
if (priv->layer_surface) {
zwlr_layer_surface_v1_destroy(priv->layer_surface);
priv->layer_surface = NULL;
}
priv->wl_surface = NULL;
}
static void
phosh_layer_surface_constructed (GObject *object)
......@@ -227,6 +252,9 @@ phosh_layer_surface_constructed (GObject *object)
g_signal_connect (self, "map",
G_CALLBACK (on_phosh_layer_surface_mapped),
NULL);
g_signal_connect (self, "unmap",
G_CALLBACK (on_phosh_layer_surface_unmapped),
NULL);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment