diff --git a/src/main.cpp b/src/main.cpp index c85680e..81c04bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,6 +93,24 @@ static const wl_registry_listener registry_listener = { }; +static void lock_handle_locked(void* data, ext_session_lock_v1* lock) { + auto& ctx = *static_cast(data); + ctx.locked = true; + spdlog::info("🔒 Session LOCKED! We now control all input"); +} + +static void lock_handle_finished(void* data, ext_session_lock_v1* lock) { + auto& ctx = *static_cast(data); + spdlog::error("Lock finished/denied by compositor - exiting"); + ctx.running = false; +} + +static const ext_session_lock_v1_listener lock_listener = { + .locked = lock_handle_locked, + .finished = lock_handle_finished, +}; + + int main (int argc, char *argv[]) { std::shared_ptr application_state = std::make_shared(); application_state->display = wl_display_connect(nullptr); diff --git a/src/state.cpp b/src/state.cpp index d796f2d..2bbaf9a 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -28,6 +28,9 @@ namespace state{ display = nullptr; } + if(session_lock) ext_session_lock_v1_destroy(session_lock); + locked=false; + running = false; } @@ -36,5 +39,7 @@ namespace state{ wl_output_destroy(output); output = nullptr; } + if(lock_surface) ext_session_lock_surface_v1_destroy(lock_surface); + if(wl_out_surface) wl_surface_destroy(wl_out_surface); } } diff --git a/src/state.hpp b/src/state.hpp index 2ad9882..b40ede9 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -16,7 +16,11 @@ namespace state{ uint32_t width = uint32_t {0}; uint32_t height = uint32_t {0}; - wl_surface* wl_surface = nullptr; + wl_surface* wl_out_surface = nullptr; + ext_session_lock_surface_v1* lock_surface = nullptr; + bool configured = false; + uint32_t surface_width = uint32_t {0}; + uint32_t surface_height = uint32_t {0}; ~Output(); }; struct LockScreenState{ @@ -30,6 +34,10 @@ namespace state{ std::vector> outputs = std::vector>{}; bool running = true; + + ext_session_lock_v1* session_lock = nullptr; + bool locked=false; + ~LockScreenState(); }; }