Commit 092e820f authored by Guido Gunther's avatar Guido Gunther
Browse files

PhoshLayerShell: Don't realize layer shell's right away



This allows us to create them early and keep them around. It also
makes them behave more like regular Gtk widgets.

Closes: #91
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 94cedf31
Pipeline #17211 passed with stages
in 4 minutes and 46 seconds
......@@ -8,6 +8,7 @@
#include "config.h"
#include "layersurface.h"
#include "phosh-wayland.h"
#include <gdk/gdkwayland.h>
......@@ -57,9 +58,9 @@ static void layer_surface_configure(void *data,
uint32_t height)
{
PhoshLayerSurface *self = data;
gtk_window_resize (GTK_WINDOW (self), width, height);
zwlr_layer_surface_v1_ack_configure(surface, serial);
gtk_widget_show (GTK_WIDGET (self));
g_signal_emit (self, signals[CONFIGURED], 0);
}
......@@ -172,20 +173,20 @@ phosh_layer_surface_get_property (GObject *object,
static void
phosh_layer_surface_constructed (GObject *object)
on_phosh_layer_surface_realized (PhoshLayerSurface *self, gpointer unused)
{
PhoshLayerSurface *self = PHOSH_LAYER_SURFACE (object);
PhoshLayerSurfacePrivate *priv = phosh_layer_surface_get_instance_private (self);
PhoshLayerSurfacePrivate *priv;
GdkWindow *gdk_window;
G_OBJECT_CLASS (phosh_layer_surface_parent_class)->constructed (object);
g_return_if_fail (PHOSH_IS_LAYER_SURFACE (self));
gtk_window_set_decorated (GTK_WINDOW (self), FALSE);
/* Realize the window so we can get the GDK window */
gtk_widget_realize(GTK_WIDGET (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);
priv->layer_surface = zwlr_layer_shell_v1_get_layer_surface(priv->layer_shell,
......@@ -201,8 +202,34 @@ phosh_layer_surface_constructed (GObject *object)
&layer_surface_listener,
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 */
phosh_wayland_roundtrip (phosh_wayland_get_default());
}
static void
phosh_layer_surface_constructed (GObject *object)
{
PhoshLayerSurface *self = PHOSH_LAYER_SURFACE (object);
g_signal_connect (self, "realize",
G_CALLBACK (on_phosh_layer_surface_realized),
NULL);
g_signal_connect (self, "map",
G_CALLBACK (on_phosh_layer_surface_mapped),
NULL);
}
static void
phosh_layer_surface_dispose (GObject *object)
{
......@@ -344,6 +371,12 @@ phosh_layer_surface_new (gpointer layer_shell,
"wl-output", wl_output);
}
/**
* phosh_layer_surface_get_surface:
*
* Get the layer layer surface or #NULL if the window
* is not yet realized.
*/
struct zwlr_layer_surface_v1 *
phosh_layer_surface_get_layer_surface(PhoshLayerSurface *self)
{
......@@ -355,6 +388,12 @@ phosh_layer_surface_get_layer_surface(PhoshLayerSurface *self)
}
/**
* phosh_layer_surface_get_wl_surface:
*
* Get the layer wayland surface or #NULL if the window
* is not yet realized.
*/
struct wl_surface *
phosh_layer_surface_get_wl_surface(PhoshLayerSurface *self)
{
......
......@@ -75,10 +75,14 @@ lock_monitor (PhoshLockscreenManager *self,
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
PhoshWayland *wl = phosh_wayland_get_default ();
GtkWidget *shield;
g_ptr_array_add (priv->shields, phosh_lockshield_new (
shield = phosh_lockshield_new (
phosh_wayland_get_zwlr_layer_shell_v1 (wl),
monitor->wl_output));
monitor->wl_output);
g_ptr_array_add (priv->shields, shield);
gtk_widget_show (shield);
}
......@@ -138,6 +142,7 @@ lockscreen_lock (PhoshLockscreenManager *self)
priv->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
phosh_wayland_get_zwlr_layer_shell_v1(wl),
primary_monitor->wl_output));
gtk_widget_show (GTK_WIDGET (priv->lockscreen));
/* Lock all other outputs */
priv->shields = g_ptr_array_new_with_free_func ((GDestroyNotify) (gtk_widget_destroy));
......
......@@ -179,11 +179,14 @@ auth_request_initiate (AuthRequest *request)
user_names,
phosh_wayland_get_zwlr_layer_shell_v1(wl),
primary_monitor->wl_output));
gtk_widget_show (GTK_WIDGET (request->agent->current_prompt));
g_signal_connect (request->agent->current_prompt,
"done",
G_CALLBACK (on_prompt_done),
request);
gtk_widget_show (GTK_WIDGET (request->agent->current_prompt));
}
static void
......
......@@ -346,8 +346,12 @@ panels_create (PhoshShell *self)
priv->panel = PHOSH_LAYER_SURFACE(phosh_panel_new (phosh_wayland_get_zwlr_layer_shell_v1(wl),
monitor->wl_output));
gtk_widget_show (GTK_WIDGET (priv->panel));
priv->home = PHOSH_LAYER_SURFACE(phosh_home_new (phosh_wayland_get_zwlr_layer_shell_v1(wl),
monitor->wl_output));
gtk_widget_show (GTK_WIDGET (priv->home));
g_signal_connect_swapped (
priv->panel,
"settings-activated",
......
......@@ -33,11 +33,15 @@ new_prompt_cb (GcrSystemPrompter *prompter,
{
PhoshWayland *wl = phosh_wayland_get_default ();
PhoshShell *shell = phosh_shell_get_default ();
GtkWidget *prompt;
g_debug ("Building new system prompt");
g_return_val_if_fail (GCR_IS_SYSTEM_PROMPTER (prompter), NULL);
return GCR_PROMPT (phosh_system_prompt_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl),
phosh_shell_get_primary_monitor (shell)->wl_output));
prompt = phosh_system_prompt_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl),
phosh_shell_get_primary_monitor (shell)->wl_output);
gtk_widget_show (prompt);
return GCR_PROMPT (prompt);
}
......
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