From ac3b49b6571ceda3f8db11a98bfe320106996280 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 27 Nov 2022 14:18:29 +0100 Subject: Drop support for layer-shell Superseded by ext-session-lock-v1 --- main.c | 106 ++++++++++------------------------------------------------------- 1 file changed, 15 insertions(+), 91 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 68c7bac..26d30a5 100644 --- a/main.c +++ b/main.c @@ -25,8 +25,6 @@ #include "pool-buffer.h" #include "seat.h" #include "swaylock.h" -#include "wlr-input-inhibitor-unstable-v1-client-protocol.h" -#include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "ext-session-lock-v1-client-protocol.h" static uint32_t parse_color(const char *color) { @@ -96,9 +94,6 @@ static void daemonize(void) { static void destroy_surface(struct swaylock_surface *surface) { wl_list_remove(&surface->link); - if (surface->layer_surface != NULL) { - zwlr_layer_surface_v1_destroy(surface->layer_surface); - } if (surface->ext_session_lock_surface_v1 != NULL) { ext_session_lock_surface_v1_destroy(surface->ext_session_lock_surface_v1); } @@ -113,7 +108,6 @@ static void destroy_surface(struct swaylock_surface *surface) { free(surface); } -static const struct zwlr_layer_surface_v1_listener layer_surface_listener; static const struct ext_session_lock_surface_v1_listener ext_session_lock_surface_v1_listener; static cairo_surface_t *select_image(struct swaylock_state *state, @@ -140,28 +134,10 @@ static void create_surface(struct swaylock_surface *surface) { assert(surface->subsurface); wl_subsurface_set_sync(surface->subsurface); - if (state->ext_session_lock_v1) { - surface->ext_session_lock_surface_v1 = ext_session_lock_v1_get_lock_surface( - state->ext_session_lock_v1, surface->surface, surface->output); - ext_session_lock_surface_v1_add_listener(surface->ext_session_lock_surface_v1, - &ext_session_lock_surface_v1_listener, surface); - } else { - surface->layer_surface = zwlr_layer_shell_v1_get_layer_surface( - state->layer_shell, surface->surface, surface->output, - ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, "lockscreen"); - - zwlr_layer_surface_v1_set_size(surface->layer_surface, 0, 0); - zwlr_layer_surface_v1_set_anchor(surface->layer_surface, - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | - ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT); - zwlr_layer_surface_v1_set_exclusive_zone(surface->layer_surface, -1); - zwlr_layer_surface_v1_set_keyboard_interactivity( - surface->layer_surface, true); - zwlr_layer_surface_v1_add_listener(surface->layer_surface, - &layer_surface_listener, surface); - } + surface->ext_session_lock_surface_v1 = ext_session_lock_v1_get_lock_surface( + state->ext_session_lock_v1, surface->surface, surface->output); + ext_session_lock_surface_v1_add_listener(surface->ext_session_lock_surface_v1, + &ext_session_lock_surface_v1_listener, surface); if (surface_is_opaque(surface) && surface->state->args.mode != BACKGROUND_MODE_CENTER && @@ -172,34 +148,8 @@ static void create_surface(struct swaylock_surface *surface) { wl_surface_set_opaque_region(surface->surface, region); wl_region_destroy(region); } - - if (!state->ext_session_lock_v1) { - wl_surface_commit(surface->surface); - } -} - -static void layer_surface_configure(void *data, - struct zwlr_layer_surface_v1 *layer_surface, - uint32_t serial, uint32_t width, uint32_t height) { - struct swaylock_surface *surface = data; - surface->width = width; - surface->height = height; - zwlr_layer_surface_v1_ack_configure(layer_surface, serial); - render_frame_background(surface); - render_frame(surface); -} - -static void layer_surface_closed(void *data, - struct zwlr_layer_surface_v1 *layer_surface) { - struct swaylock_surface *surface = data; - destroy_surface(surface); } -static const struct zwlr_layer_surface_v1_listener layer_surface_listener = { - .configure = layer_surface_configure, - .closed = layer_surface_closed, -}; - static void ext_session_lock_surface_v1_handle_configure(void *data, struct ext_session_lock_surface_v1 *lock_surface, uint32_t serial, uint32_t width, uint32_t height) { @@ -347,12 +297,6 @@ static void handle_global(void *data, struct wl_registry *registry, calloc(1, sizeof(struct swaylock_seat)); swaylock_seat->state = state; wl_seat_add_listener(seat, &seat_listener, swaylock_seat); - } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { - state->layer_shell = wl_registry_bind( - registry, name, &zwlr_layer_shell_v1_interface, 1); - } else if (strcmp(interface, zwlr_input_inhibit_manager_v1_interface.name) == 0) { - state->input_inhibit_manager = wl_registry_bind( - registry, name, &zwlr_input_inhibit_manager_v1_interface, 1); } else if (strcmp(interface, wl_output_interface.name) == 0) { struct swaylock_surface *surface = calloc(1, sizeof(struct swaylock_surface)); @@ -1273,27 +1217,17 @@ int main(int argc, char **argv) { return 1; } - if (state.ext_session_lock_manager_v1) { - swaylock_log(LOG_DEBUG, "Using ext-session-lock-v1"); - state.ext_session_lock_v1 = ext_session_lock_manager_v1_lock(state.ext_session_lock_manager_v1); - ext_session_lock_v1_add_listener(state.ext_session_lock_v1, - &ext_session_lock_v1_listener, &state); - } else if (state.layer_shell && state.input_inhibit_manager) { - swaylock_log(LOG_DEBUG, "Using wlr-layer-shell + wlr-input-inhibitor"); - zwlr_input_inhibit_manager_v1_get_inhibitor(state.input_inhibit_manager); - } else { - swaylock_log(LOG_ERROR, "Missing ext-session-lock-v1, wlr-layer-shell " - "and wlr-input-inhibitor"); + if (!state.ext_session_lock_manager_v1) { + swaylock_log(LOG_ERROR, "Missing ext-session-lock-v1"); return 1; } + state.ext_session_lock_v1 = ext_session_lock_manager_v1_lock(state.ext_session_lock_manager_v1); + ext_session_lock_v1_add_listener(state.ext_session_lock_v1, + &ext_session_lock_v1_listener, &state); + if (wl_display_roundtrip(state.display) == -1) { free(state.args.font); - if (state.input_inhibit_manager) { - swaylock_log(LOG_ERROR, "Exiting - failed to inhibit input:" - " is another lockscreen already running?"); - return 2; - } return 1; } @@ -1305,19 +1239,11 @@ int main(int argc, char **argv) { create_surface(surface); } - if (state.ext_session_lock_manager_v1) { - while (!state.locked) { - if (wl_display_dispatch(state.display) < 0) { - swaylock_log(LOG_ERROR, "wl_display_dispatch() failed"); - return 2; - } - } - } else { - if (wl_display_roundtrip(state.display) < 0) { - swaylock_log(LOG_ERROR, "wl_display_roundtrip() failed"); + while (!state.locked) { + if (wl_display_dispatch(state.display) < 0) { + swaylock_log(LOG_ERROR, "wl_display_dispatch() failed"); return 2; } - state.locked = true; } if (state.args.ready_fd >= 0) { @@ -1353,10 +1279,8 @@ int main(int argc, char **argv) { loop_poll(state.eventloop); } - if (state.ext_session_lock_v1) { - ext_session_lock_v1_unlock_and_destroy(state.ext_session_lock_v1); - wl_display_roundtrip(state.display); - } + ext_session_lock_v1_unlock_and_destroy(state.ext_session_lock_v1); + wl_display_roundtrip(state.display); free(state.args.font); cairo_destroy(state.test_cairo); -- cgit v1.2.3