diff --git a/src/background.c b/src/background.c index 6b196ae128fea96da04a7bb829db543d12be4252..5063c00360996fbe8be479e53840a186b59dd1c9 100644 --- a/src/background.c +++ b/src/background.c @@ -29,11 +29,11 @@ typedef struct typedef struct _PhoshBackground { - GtkWindow parent; + PhoshLayerSurface parent; } PhoshBackground; -G_DEFINE_TYPE_WITH_PRIVATE (PhoshBackground, phosh_background, GTK_TYPE_WINDOW) +G_DEFINE_TYPE_WITH_PRIVATE (PhoshBackground, phosh_background, PHOSH_TYPE_LAYER_SURFACE) static GdkPixbuf * @@ -227,7 +227,23 @@ phosh_background_init (PhoshBackground *self) GtkWidget * -phosh_background_new (void) +phosh_background_new (gpointer layer_shell, + gpointer wl_output, + guint width, + guint height) { - return g_object_new (PHOSH_TYPE_BACKGROUND, NULL); + return g_object_new (PHOSH_TYPE_BACKGROUND, + "layer-shell", layer_shell, + "wl-output", wl_output, + "width", width, + "height", height, + "anchor", (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | + ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | + ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT), + "layer", ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND, + "kbd-interactivity", FALSE, + "exclusive-zone", -1, + "namespace", "phosh background", + NULL); } diff --git a/src/background.h b/src/background.h index 2edd27f5b4a62abb9023c7b8c19ee97b7d4ff819..11359b5a6a9bbc60443763a44c4ee2e01edc42ed 100644 --- a/src/background.h +++ b/src/background.h @@ -8,11 +8,12 @@ #define PHOSH_BACKGROUND_H #include <gtk/gtk.h> +#include "layersurface.h" #define PHOSH_TYPE_BACKGROUND (phosh_background_get_type()) -G_DECLARE_FINAL_TYPE (PhoshBackground, phosh_background, PHOSH, BACKGROUND, GtkWindow) +G_DECLARE_FINAL_TYPE (PhoshBackground, phosh_background, PHOSH, BACKGROUND, PhoshLayerSurface) -GtkWidget * phosh_background_new (void); +GtkWidget *phosh_background_new (gpointer layer_shell, gpointer wl_output, guint width, guint height); #endif /* PHOSH_BACKGROUND_H */ diff --git a/src/phosh.c b/src/phosh.c index a8d4487667ad144fb48341a94c6547a98d50813e..359e56cad3296cafd366912c60d51087c295221d 100644 --- a/src/phosh.c +++ b/src/phosh.c @@ -80,7 +80,7 @@ typedef struct struct elem *panel; /* Background */ - struct elem *background; + GtkWidget *background; /* Lockscreen */ struct elem *lockscreen; /* phone display lock screen */ @@ -584,33 +584,16 @@ background_create (PhoshShell *self) #ifdef WITH_PHOSH_BACKGROUND PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); - GdkWindow *gdk_window; - struct elem *background; - gint width, height; PhoshMonitor *monitor; + gint width, height; monitor = phosh_monitor_manager_get_monitor (priv->monitor_manager, 0); g_return_if_fail (monitor); - - background = calloc (1, sizeof *background); - background->window = phosh_background_new (); - phosh_shell_get_usable_area (self, NULL, NULL, &width, &height); + /* set it up as the background */ - gdk_window = gtk_widget_get_window (background->window); - gdk_wayland_window_set_use_custom_surface (gdk_window); - background->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window); - background->layer_surface = - zwlr_layer_shell_v1_get_layer_surface(priv->layer_shell, - background->wl_surface, - monitor->wl_output, - ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND, - "phosh"); - zwlr_layer_surface_v1_set_anchor(background->layer_surface, ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM); - zwlr_layer_surface_v1_set_size(background->layer_surface, width, height); - zwlr_layer_surface_v1_add_listener(background->layer_surface, &layer_surface_listener, background); - wl_surface_commit(background->wl_surface); - priv->background = background; + priv->background = phosh_background_new ( + priv->layer_shell, monitor->wl_output, width, height); #endif } @@ -750,6 +733,11 @@ phosh_shell_dispose (GObject *object) PhoshShell *self = PHOSH_SHELL (object); PhoshShellPrivate *priv = phosh_shell_get_instance_private(self); + if (priv->background) { + gtk_widget_destroy (priv->background); + priv->background = NULL; + } + if (priv->shields) { g_ptr_array_free (priv->shields, TRUE); priv->shields = NULL;