integrated with the lock callbacks in both Output and LockScreenState
This commit is contained in:
18
src/main.cpp
18
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<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[]) {
|
int main (int argc, char *argv[]) {
|
||||||
std::shared_ptr<state::LockScreenState> application_state = std::make_shared<state::LockScreenState>();
|
std::shared_ptr<state::LockScreenState> application_state = std::make_shared<state::LockScreenState>();
|
||||||
application_state->display = wl_display_connect(nullptr);
|
application_state->display = wl_display_connect(nullptr);
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ namespace state{
|
|||||||
display = nullptr;
|
display = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(session_lock) ext_session_lock_v1_destroy(session_lock);
|
||||||
|
locked=false;
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,5 +39,7 @@ namespace state{
|
|||||||
wl_output_destroy(output);
|
wl_output_destroy(output);
|
||||||
output = nullptr;
|
output = nullptr;
|
||||||
}
|
}
|
||||||
|
if(lock_surface) ext_session_lock_surface_v1_destroy(lock_surface);
|
||||||
|
if(wl_out_surface) wl_surface_destroy(wl_out_surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ namespace state{
|
|||||||
uint32_t width = uint32_t {0};
|
uint32_t width = uint32_t {0};
|
||||||
uint32_t height = 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();
|
~Output();
|
||||||
};
|
};
|
||||||
struct LockScreenState{
|
struct LockScreenState{
|
||||||
@@ -30,6 +34,10 @@ namespace state{
|
|||||||
std::vector<std::shared_ptr<Output>> outputs = std::vector<std::shared_ptr<Output>>{};
|
std::vector<std::shared_ptr<Output>> outputs = std::vector<std::shared_ptr<Output>>{};
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
|
|
||||||
|
ext_session_lock_v1* session_lock = nullptr;
|
||||||
|
bool locked=false;
|
||||||
|
|
||||||
~LockScreenState();
|
~LockScreenState();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user