diff --git a/ext-unlocker-v1.xml b/ext-unlocker-v1.xml new file mode 100644 index 000000000..5e6cc647b --- /dev/null +++ b/ext-unlocker-v1.xml @@ -0,0 +1,47 @@ + + + + Copyright 2021 Manuel Stoeckl + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + IN THE SOFTWARE. + + + + + This protocol provides an interface for letting a special lock screen + client, which was created when the session was locked, communicate to + the compositor that the session should be unlocked. + + + + + Announce that this object will no longer be used. + + + + + + Let the compositor know that it should unlock the screen. + + After this request has been sent by the client, sending it again shall + have no effect. + + + + diff --git a/include/swaylock.h b/include/swaylock.h index 3993fe5aa..e60db807e 100644 --- a/include/swaylock.h +++ b/include/swaylock.h @@ -79,6 +79,7 @@ struct swaylock_state { struct wl_subcompositor *subcompositor; struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_input_inhibit_manager_v1 *input_inhibit_manager; + struct ext_unlocker_v1 *unlocker; struct wl_shm *shm; struct wl_list surfaces; struct wl_list images; diff --git a/main.c b/main.c index a8bd10654..442abff0b 100644 --- a/main.c +++ b/main.c @@ -23,6 +23,7 @@ #include "pool-buffer.h" #include "seat.h" #include "swaylock.h" +#include "ext-unlocker-v1-client-protocol.h" #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "xdg-output-unstable-v1-client-protocol.h" @@ -344,6 +345,9 @@ static void handle_global(void *data, struct wl_registry *registry, create_layer_surface(surface); wl_display_roundtrip(state->display); } + } else if (strcmp(interface, ext_unlocker_v1_interface.name) == 0) { + state->unlocker = wl_registry_bind( + registry, name, &ext_unlocker_v1_interface, 1); } } @@ -1086,6 +1090,11 @@ static void display_in(int fd, short mask, void *data) { static void comm_in(int fd, short mask, void *data) { if (read_comm_reply()) { + if (state.unlocker) { + ext_unlocker_v1_unlock(state.unlocker); + // ensure compositor sees this immediately + wl_display_roundtrip(state.display); + } // Authentication succeeded state.run_display = false; } else { diff --git a/meson.build b/meson.build index 62c188aa6..6d3d3e597 100644 --- a/meson.build +++ b/meson.build @@ -88,6 +88,7 @@ client_protocols = [ [wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'], ['wlr-layer-shell-unstable-v1.xml'], ['wlr-input-inhibitor-unstable-v1.xml'], + ['ext-unlocker-v1.xml'], ] foreach p : client_protocols