integrated with the lock callbacks in both Output and LockScreenState

This commit is contained in:
2025-12-21 22:24:50 -06:00
parent 0d7a4f45e7
commit 62efe90f89
3 changed files with 32 additions and 1 deletions

View File

@@ -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<state::LockScreenState*>(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<state::LockScreenState*>(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<state::LockScreenState> application_state = std::make_shared<state::LockScreenState>();
application_state->display = wl_display_connect(nullptr);

View File

@@ -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);
}
}

View File

@@ -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<std::shared_ptr<Output>> outputs = std::vector<std::shared_ptr<Output>>{};
bool running = true;
ext_session_lock_v1* session_lock = nullptr;
bool locked=false;
~LockScreenState();
};
}