1
0
Fork 0
forked from wry/wry

seat: handle surface cursor lifetimes explicitly

This commit is contained in:
Julian Orth 2024-03-29 19:31:40 +01:00
parent 566a05494a
commit be0935c8dd
4 changed files with 6 additions and 1 deletions

View file

@ -60,6 +60,7 @@ pub trait Cursor {
fn set_output(&self, output: &Rc<OutputNode>) { fn set_output(&self, output: &Rc<OutputNode>) {
let _ = output; let _ = output;
} }
fn handle_set(self: Rc<Self>) {}
fn handle_unset(&self) {} fn handle_unset(&self) {}
fn tick(&self) {} fn tick(&self) {}
fn needs_tick(&self) -> bool { fn needs_tick(&self) -> bool {

View file

@ -879,6 +879,7 @@ impl WlSeatGlobal {
old.handle_unset(); old.handle_unset();
} }
if let Some(cursor) = cursor.as_ref() { if let Some(cursor) = cursor.as_ref() {
cursor.clone().handle_set();
cursor.set_output(&self.output.get()); cursor.set_output(&self.output.get());
} }
self.cursor.set(cursor.clone()); self.cursor.set(cursor.clone());

View file

@ -620,7 +620,6 @@ impl WlSurface {
let cursor = Rc::new(CursorSurface::new(seat, self)); let cursor = Rc::new(CursorSurface::new(seat, self));
track!(self.client, cursor); track!(self.client, cursor);
cursor.handle_buffer_change(); cursor.handle_buffer_change();
self.cursors.insert(seat.id(), cursor.clone());
Ok(cursor) Ok(cursor)
} }

View file

@ -123,6 +123,10 @@ impl Cursor for CursorSurface {
self.surface.set_output(output); self.surface.set_output(output);
} }
fn handle_set(self: Rc<Self>) {
self.surface.cursors.insert(self.seat.id(), self.clone());
}
fn handle_unset(&self) { fn handle_unset(&self) {
self.surface.cursors.remove(&self.seat.id()); self.surface.cursors.remove(&self.seat.id());
} }