From 207aaf8adf2c0571403454d98ea5f9b657dcd4b7 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 8 Jul 2022 14:25:26 +0200 Subject: [PATCH] input: Cleanup seat userdata constructors --- src/input/mod.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index d0b11e0b..524b39be 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -25,7 +25,9 @@ crate::utils::id_gen!(next_seat_id, SEAT_ID, SEAT_IDS); #[repr(transparent)] pub struct SeatId(pub usize); pub struct ActiveOutput(pub RefCell); +#[derive(Default)] pub struct SupressedKeys(RefCell>); +#[derive(Default)] pub struct Devices(RefCell>>); impl Default for SeatId { @@ -41,10 +43,6 @@ impl Drop for SeatId { } impl SupressedKeys { - fn new() -> SupressedKeys { - SupressedKeys(RefCell::new(Vec::new())) - } - fn add(&self, keysym: &KeysymHandle) { self.0.borrow_mut().push(keysym.raw_code()); } @@ -61,10 +59,6 @@ impl SupressedKeys { } impl Devices { - fn new() -> Devices { - Devices(RefCell::new(HashMap::new())) - } - fn add_device(&self, device: &D) -> Vec { let id = device.id(); let mut map = self.0.borrow_mut(); @@ -101,8 +95,8 @@ pub fn add_seat(dh: &DisplayHandle, name: String) -> Seat { let seat = Seat::::new(dh, name, None); let userdata = seat.user_data(); userdata.insert_if_missing(SeatId::default); - userdata.insert_if_missing(|| Devices::new()); - userdata.insert_if_missing(|| SupressedKeys::new()); + userdata.insert_if_missing(Devices::default); + userdata.insert_if_missing(SupressedKeys::default); userdata.insert_if_missing(|| RefCell::new(CursorImageStatus::Default)); seat }