Merge pull request #205 from pop-os/check-session-lock-valid_jammy

Allow session lock if existing session lock is no longer valid
This commit is contained in:
Victoria Brekenfeld 2023-11-07 18:34:18 +01:00 • committed by GitHub
commit 18067def18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View file

@ -50,6 +50,7 @@ use smithay::{
output::{Mode as OutputMode, Output, Scale}, output::{Mode as OutputMode, Output, Scale},
reexports::{ reexports::{
calloop::{LoopHandle, LoopSignal}, 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_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode,
wayland_server::{ wayland_server::{
backend::{ClientData, ClientId, DisconnectReason}, backend::{ClientData, ClientId, DisconnectReason},
@ -189,6 +190,7 @@ pub struct SurfaceDmabufFeedback {
#[derive(Debug)] #[derive(Debug)]
pub struct SessionLock { pub struct SessionLock {
pub ext_session_lock: ExtSessionLockV1,
pub surfaces: HashMap<Output, LockSurface>, pub surfaces: HashMap<Output, LockSurface>,
} }

View file

@ -7,7 +7,7 @@ use crate::{
use smithay::{ use smithay::{
delegate_session_lock, delegate_session_lock,
output::Output, output::Output,
reexports::wayland_server::protocol::wl_output::WlOutput, reexports::wayland_server::{protocol::wl_output::WlOutput, Resource},
utils::Size, utils::Size,
wayland::session_lock::{ wayland::session_lock::{
LockSurface, SessionLockHandler, SessionLockManagerState, SessionLocker, LockSurface, SessionLockHandler, SessionLockManagerState, SessionLocker,
@ -21,12 +21,24 @@ impl SessionLockHandler for State {
} }
fn lock(&mut self, locker: SessionLocker) { fn lock(&mut self, locker: SessionLocker) {
if self.common.session_lock.is_none() { // Reject lock if sesion lock exists and is still valid
locker.lock(); if let Some(session_lock) = self.common.session_lock.as_ref() {
self.common.session_lock = Some(SessionLock { if self
surfaces: HashMap::new(), .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) { fn unlock(&mut self) {