Skip to content
Snippets Groups Projects
Commit e6b06877 authored by Guido Gunther's avatar Guido Gunther :zzz:
Browse files

background: Turn into PhoshSurfaceLayer


Signed-off-by: default avatarGuido Günther <agx@sigxcpu.org>
parent 78e63e84
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......@@ -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 */
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment