Skip to content

Commit

Permalink
session-lock: move unlock logic to single place
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Jul 10, 2024
1 parent 5a53b74 commit 44bdca8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
11 changes: 1 addition & 10 deletions src/ifs/ext_session_lock_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,7 @@ impl ExtSessionLockV1RequestHandler for ExtSessionLockV1 {
return Err(ExtSessionLockV1Error::NeverLocked);
}
if !self.finished.get() {
let state = &self.client.state;
state.lock.locked.set(false);
state.lock.lock.take();
for output in state.root.outputs.lock().values() {
if let Some(surface) = output.set_lock_surface(None) {
surface.destroy_node();
}
}
state.tree_changed();
state.damage();
self.client.state.do_unlock();
}
self.client.remove_obj(self)?;
Ok(())
Expand Down
13 changes: 3 additions & 10 deletions src/ifs/jay_compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,12 @@ impl JayCompositorRequestHandler for JayCompositor {

fn unlock(&self, _req: Unlock, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let state = &self.client.state;
if state.lock.locked.replace(false) {
if let Some(lock) = state.lock.lock.take() {
if state.lock.locked.get() {
if let Some(lock) = state.lock.lock.get() {
lock.finish();
}
for output in state.root.outputs.lock().values() {
if let Some(surface) = output.set_lock_surface(None) {
surface.destroy_node();
}
}
state.tree_changed();
state.damage();
state.do_unlock();
}
self.client.symmetric_delete.set(true);
Ok(())
}

Expand Down
12 changes: 12 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,18 @@ impl State {
}
}

pub fn do_unlock(&self) {
self.lock.locked.set(false);
self.lock.lock.take();
for output in self.root.outputs.lock().values() {
if let Some(surface) = output.set_lock_surface(None) {
surface.destroy_node();
}
}
self.tree_changed();
self.damage();
}

pub fn clear(&self) {
self.lock.lock.take();
self.xwayland.handler.borrow_mut().take();
Expand Down

0 comments on commit 44bdca8

Please sign in to comment.