Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow session lock if existing session lock is no longer valid #205

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use smithay::{
output::{Mode as OutputMode, Output, Scale},
reexports::{
calloop::{LoopHandle, LoopSignal},
wayland_protocols::ext::session_lock::v1::server::ext_session_lock_v1::ExtSessionLockV1,
wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode,
wayland_server::{
backend::{ClientData, ClientId, DisconnectReason},
Expand Down Expand Up @@ -189,6 +190,7 @@ pub struct SurfaceDmabufFeedback {

#[derive(Debug)]
pub struct SessionLock {
pub ext_session_lock: ExtSessionLockV1,
pub surfaces: HashMap<Output, LockSurface>,
}

Expand Down
24 changes: 18 additions & 6 deletions src/wayland/handlers/session_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
use smithay::{
delegate_session_lock,
output::Output,
reexports::wayland_server::protocol::wl_output::WlOutput,
reexports::wayland_server::{protocol::wl_output::WlOutput, Resource},
utils::Size,
wayland::session_lock::{
LockSurface, SessionLockHandler, SessionLockManagerState, SessionLocker,
Expand All @@ -21,12 +21,24 @@ impl SessionLockHandler for State {
}

fn lock(&mut self, locker: SessionLocker) {
if self.common.session_lock.is_none() {
locker.lock();
self.common.session_lock = Some(SessionLock {
surfaces: HashMap::new(),
});
// Reject lock if sesion lock exists and is still valid
if let Some(session_lock) = self.common.session_lock.as_ref() {
if self
.common
.display_handle
.get_client(session_lock.ext_session_lock.id())
.is_ok()
{
return;
}
}

let ext_session_lock = locker.ext_session_lock().clone();
locker.lock();
self.common.session_lock = Some(SessionLock {
ext_session_lock,
surfaces: HashMap::new(),
});
}

fn unlock(&mut self) {
Expand Down