diff options
Diffstat (limited to 'wlock.c')
| -rw-r--r-- | wlock.c | 65 |
1 files changed, 37 insertions, 28 deletions
@@ -18,6 +18,7 @@ #include <stdio.h> #include <string.h> +#include "ext-session-lock-protocol.h" #include "util.h" #include "drw.h" #include "config.h" @@ -39,8 +40,8 @@ typedef struct { struct wl_registry *registry; struct wl_compositor *compositor; struct wl_shm *shm; - struct zdwl_manager_v1 *dwl_manager; - struct zwlr_layer_shell_v1 *layer; + struct ext_session_lock_manager_v1 *lock_manager; + struct ext_session_lock_v1 *session_lock; struct wl_seat *seat; struct wl_keyboard *keyboard; struct xkb_context *xkb_context; @@ -65,7 +66,7 @@ struct Monitor { Canvas *canvas; struct wl_output *output; struct wl_surface *surface; - struct zwlr_layer_surface_v1 *wlr_surface; + struct ext_session_lock_surface_v1 *lock_surface; Monitor *next; }; @@ -78,7 +79,8 @@ static void remove_monitor(Monitor *mon); static void registry_global(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, uint32_t version); static void remove_global(void *data, struct wl_registry *wl_registry, uint32_t name); static void seat_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities); -static void wlr_layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface, uint32_t serial, uint32_t w, uint32_t h); +static void session_lock_surface_configure(void *data, struct ext_session_lock_surface_v1 *surface, uint32_t serial, uint32_t width, uint32_t height); +static void lock_failed(void *data, struct ext_session_lock_v1 *lock); static void keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size); static void keyboard_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); static void keyboard_repeat_info(void *data, struct wl_keyboard *keyboard, int32_t rate, int32_t delay); @@ -92,11 +94,6 @@ static const struct wl_registry_listener registry_listnener = { .global_remove = remove_global }; -static const struct zwlr_layer_surface_v1_listener wlr_layer_surface_listener = { - .closed = dummy, - .configure = wlr_layer_surface_configure, -}; - static const struct wl_seat_listener seat_listener = { .capabilities = seat_capabilities, .name = dummy, @@ -111,6 +108,15 @@ static const struct wl_keyboard_listener keyboard_listener = { .repeat_info = keyboard_repeat_info, }; +static const struct ext_session_lock_surface_v1_listener session_lock_surface_listener = { + .configure = session_lock_surface_configure +}; + +static const struct ext_session_lock_v1_listener session_lock_listener = { + .locked = dummy, + .finished = lock_failed, +}; + Client client = { 0 }; Monitor *monitors = 0; char input_field[MAX_LINE_LENGTH] = ""; @@ -183,7 +189,7 @@ void remove_monitor(Monitor *mon) { wl_surface_destroy(mon->surface); - zwlr_layer_surface_v1_destroy(mon->wlr_surface); + ext_session_lock_surface_v1_destroy(mon->lock_surface); wl_output_destroy(mon->output); free_drw(mon->canvas); free(mon); @@ -198,7 +204,7 @@ registry_global(void *data, struct wl_registry *wl_registry, uint32_t name, cons match_then_bind(client.shm, wl_shm_interface, 1) or_match match_then_bind(client.compositor, wl_compositor_interface, 4) - or_match match_then_bind(client.layer, zwlr_layer_shell_v1_interface, 1) + or_match match_then_bind(client.lock_manager, ext_session_lock_manager_v1_interface, 1) or_match match_then_bind(client.seat, wl_seat_interface, 7) wl_seat_add_listener(client.seat, &seat_listener, &client); or_match match_then_bind(output, wl_output_interface, 1) @@ -250,13 +256,13 @@ seat_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities) void -wlr_layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface, uint32_t serial, uint32_t w, uint32_t h) +session_lock_surface_configure(void *data, struct ext_session_lock_surface_v1 *surface, uint32_t serial, uint32_t w, uint32_t h) { Monitor *mon = data; mon->width = w; mon->height = h; - zwlr_layer_surface_v1_ack_configure(surface, serial); + ext_session_lock_surface_v1_ack_configure(mon->lock_surface, serial); if (mon->canvas == 0) { mon->canvas = create_drw(client.shm, mon->width, mon->height); @@ -271,6 +277,13 @@ wlr_layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface, u void +lock_failed(void *data, struct ext_session_lock_v1 *lock) +{ + die("failed to lock session"); +} + + +void keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size) { char *key_shm; @@ -377,22 +390,10 @@ handle_keyboard_event() void register_monitor(Monitor *mon) { - char namespace[] = "dmenu-wl"; - uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP; - uint32_t 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; - mon->surface = wl_compositor_create_surface(client.compositor); - mon->wlr_surface = zwlr_layer_shell_v1_get_layer_surface(client.layer, mon->surface, mon->output, layer, namespace); - - zwlr_layer_surface_v1_set_exclusive_zone(mon->wlr_surface, -1); - zwlr_layer_surface_v1_set_keyboard_interactivity(monitors->wlr_surface, 1); - - zwlr_layer_surface_v1_add_listener(mon->wlr_surface, &wlr_layer_surface_listener, mon); - - zwlr_layer_surface_v1_set_anchor(mon->wlr_surface, anchor); + mon->lock_surface = ext_session_lock_v1_get_lock_surface(client.session_lock, mon->surface, mon->output); + ext_session_lock_surface_v1_add_listener(mon->lock_surface, &session_lock_surface_listener, mon); + wl_display_roundtrip(client.display); wl_surface_commit(mon->surface); wl_display_roundtrip(client.display); @@ -402,6 +403,7 @@ register_monitor(Monitor *mon) void setup() { + printf("HERE 0\n"); Monitor *mon; username_font = create_font(fontpath, username_fontsize * 1.5); clock_font = create_font(fontpath, clock_fontsize * 1.5); @@ -410,6 +412,10 @@ setup() client.display = wl_display_connect(0); client.registry = wl_display_get_registry(client.display); wl_registry_add_listener(client.registry, ®istry_listnener, &client); + + wl_display_roundtrip(client.display); + client.session_lock = ext_session_lock_manager_v1_lock(client.lock_manager); + ext_session_lock_v1_add_listener(client.session_lock, &session_lock_listener, &client); wl_display_roundtrip(client.display); for (mon = monitors; mon; mon = mon->next) { @@ -499,5 +505,8 @@ main(int argc, char *argv[]) } } + ext_session_lock_v1_unlock_and_destroy(client.session_lock); + ext_session_lock_manager_v1_destroy(client.lock_manager); + wl_display_dispatch(client.display); } |