feat(wm): single_window -> window_based offset

This commit updates the initial design of single_window_work_area_offset
to window_based_work_area_offset where the user can set
window_based_work_area_offset_limit to determine the limit of windows on
the screen that this offset should apply to.

By default this is 1, and in the most extreme case of someone using a
super ultrawide monitor this might be 2.
This commit is contained in:
LGUG2Z
2024-05-14 14:39:37 -07:00
parent 81f741bbbd
commit 3d53c602a7
5 changed files with 74 additions and 26 deletions
+11 -4
View File
@@ -37,7 +37,9 @@ pub struct Monitor {
#[getset(get_copy = "pub", set = "pub")]
work_area_offset: Option<Rect>,
#[getset(get_copy = "pub", set = "pub")]
single_window_work_area_offset: Option<Rect>,
window_based_work_area_offset: Option<Rect>,
#[getset(get_copy = "pub", set = "pub")]
window_based_work_area_offset_limit: isize,
workspaces: Ring<Workspace>,
#[serde(skip_serializing_if = "Option::is_none")]
#[getset(get_copy = "pub", set = "pub")]
@@ -60,7 +62,8 @@ pub fn new(id: isize, size: Rect, work_area_size: Rect, name: String) -> Monitor
size,
work_area_size,
work_area_offset: None,
single_window_work_area_offset: None,
window_based_work_area_offset: None,
window_based_work_area_offset_limit: 1,
workspaces,
last_focused_workspace: None,
workspace_names: HashMap::default(),
@@ -197,7 +200,11 @@ impl Monitor {
pub fn update_focused_workspace(&mut self, offset: Option<Rect>) -> Result<()> {
let work_area = *self.work_area_size();
let single_window_work_area_offset = self.single_window_work_area_offset();
let window_based_work_area_offset = (
self.window_based_work_area_offset_limit(),
self.window_based_work_area_offset(),
);
let offset = if self.work_area_offset().is_some() {
self.work_area_offset()
} else {
@@ -206,7 +213,7 @@ impl Monitor {
self.focused_workspace_mut()
.ok_or_else(|| anyhow!("there is no workspace"))?
.update(&work_area, offset, single_window_work_area_offset)?;
.update(&work_area, offset, window_based_work_area_offset)?;
Ok(())
}