mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-22 16:48:33 +02:00
refactor(wm): reduce boilerplate with getset
This commit introduces the getset crate to reduce a lot of the boilerplate, especially in workspace.rs, around different variations of getters. Hopefully this will make the codebase easier to navigate for contributors in the future. Also trying to avoid pinning to patch versions and minor versions wherever possible.
This commit is contained in:
@@ -3,6 +3,9 @@ use std::collections::VecDeque;
|
||||
|
||||
use color_eyre::eyre::ContextCompat;
|
||||
use color_eyre::Result;
|
||||
use getset::CopyGetters;
|
||||
use getset::Getters;
|
||||
use getset::MutGetters;
|
||||
use serde::Serialize;
|
||||
|
||||
use komorebi_core::Rect;
|
||||
@@ -11,13 +14,16 @@ use crate::container::Container;
|
||||
use crate::ring::Ring;
|
||||
use crate::workspace::Workspace;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, Getters, CopyGetters, MutGetters)]
|
||||
pub struct Monitor {
|
||||
#[getset(get_copy = "pub")]
|
||||
id: isize,
|
||||
monitor_size: Rect,
|
||||
#[getset(get = "pub")]
|
||||
work_area_size: Rect,
|
||||
workspaces: Ring<Workspace>,
|
||||
#[serde(skip_serializing)]
|
||||
#[getset(get_mut = "pub")]
|
||||
workspace_names: HashMap<usize, String>,
|
||||
}
|
||||
|
||||
@@ -131,16 +137,4 @@ impl Monitor {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn workspace_names_mut(&mut self) -> &mut HashMap<usize, String> {
|
||||
&mut self.workspace_names
|
||||
}
|
||||
|
||||
pub const fn id(&self) -> isize {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub const fn work_area_size(&self) -> &Rect {
|
||||
&self.work_area_size
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user