From 9434e48ae5fff3298f59fa6836195d7c6710ca1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Thu, 19 Apr 2018 10:40:18 +0200
Subject: [PATCH] lockscreen: Switch to layer-shell protocol

We use the overlay level for the lock screen so it's above 'top' which
is currently being used for the menus (until they turn into xdg popups).

Together with the input-inhibit protocol this make sure neither clients
nor other shell surfaces get any input.
---
 src/phosh.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/phosh.c b/src/phosh.c
index 0bbadc7..fac7c2c 100644
--- a/src/phosh.c
+++ b/src/phosh.c
@@ -239,12 +239,21 @@ lockscreen_create (PhoshShell *self)
   gdk_wayland_window_set_use_custom_surface (gdk_window);
 
   lockscreen->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window);
-
-#if 0
-  phosh_mobile_shell_set_lock_surface(priv->mshell,
-                                      lockscreen->wl_surface);
-#endif
-  gtk_widget_show_all (lockscreen->window);
+  lockscreen->layer_surface = zwlr_layer_shell_v1_get_layer_surface(priv->layer_shell,
+                                                                    lockscreen->wl_surface,
+                                                                    priv->output,
+                                                                    ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
+                                                                    "lockscreen");
+  zwlr_layer_surface_v1_set_exclusive_zone(lockscreen->layer_surface, -1);
+  zwlr_layer_surface_v1_set_size(lockscreen->layer_surface, 0, 0);
+  zwlr_layer_surface_v1_set_anchor(lockscreen->layer_surface,
+                                   ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
+                                   ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
+                                   ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
+                                   ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
+  zwlr_layer_surface_v1_set_keyboard_interactivity(lockscreen->layer_surface, TRUE);
+  zwlr_layer_surface_v1_add_listener(lockscreen->layer_surface, &layer_surface_listener, lockscreen);
+  wl_surface_commit(lockscreen->wl_surface);
   priv->lockscreen = lockscreen;
 
   priv->unlock_handler_id = g_signal_connect_swapped (
-- 
GitLab