layersurface: Refresh layersurface on map
If the surface gets unmapped and mapped again we have another GDK window so we have to reconfigure the layers surface on map and destroy it on unmap. This will be merged back into phosh if it works out.
This commit is contained in:
@ -185,18 +185,34 @@ on_phosh_layer_surface_realized (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);
|
||||
|
||||
gdk_window = gtk_widget_get_window (GTK_WIDGET (self));
|
||||
gdk_wayland_window_set_use_custom_surface (gdk_window);
|
||||
|
||||
wl_display_roundtrip (gdk_wayland_display_get_wl_display (gdk_display_get_default ()));
|
||||
|
||||
priv->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window);
|
||||
|
||||
gtk_window_set_decorated (GTK_WINDOW (self), FALSE);
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
priv->wl_output,
|
||||
@ -211,18 +227,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);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
on_phosh_layer_surface_mapped (PhoshLayerSurface *self, gpointer unused)
|
||||
{
|
||||
/* 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_unmapped (PhoshLayerSurface *self, gpointer unused)
|
||||
{
|
||||
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)
|
||||
@ -235,6 +259,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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user