feat(wm): improve scrolling layout window hiding

This commit makes a small improvement to the Scrolling layout by hiding
windows to which layouts which are not contained within the horizontal
bounds of the work area would otherwise be applied.

This should also allow this layout to now be useable on configurations
using multiple monitors.
This commit is contained in:
LGUG2Z committed 2025-10-30 07:23:50 -07:00
1 parent 9711a00cd0
commit 2eea8b79a4
4 files changed
+16 -21

No files matched your search

+6
View File
@@ -69,6 +69,12 @@ impl Rect {
CoreGraphicsApi::contains_rect(other.into(), self.into())
}
pub fn contains_within_horizontal_bounds(&self, other: &Rect) -> bool {
let within_left_bound = other.left >= self.left;
let within_right_bound = other.left < self.left + self.right;
within_left_bound && within_right_bound
}
/// Decrease the size of self by the padding amount.
pub fn add_padding<T>(&mut self, padding: T)
where
-11
View File
@@ -1212,8 +1212,6 @@ impl StaticConfig {
workspace_matching_rules.clear();
drop(workspace_matching_rules);
let monitor_count = wm.monitors().len();
let offset = wm.work_area_offset;
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
let preferred_config_idx = {
@@ -1268,15 +1266,6 @@ impl StaticConfig {
monitor.update_workspaces_globals(offset);
for (j, ws) in monitor.workspaces_mut().iter_mut().enumerate() {
if let Some(workspace_config) = monitor_config.workspaces.get_mut(j) {
if monitor_count > 1
&& matches!(workspace_config.layout, Some(DefaultLayout::Scrolling))
{
tracing::warn!(
"scrolling layout is only supported for a single monitor; falling back to columns layout"
);
workspace_config.layout = Some(DefaultLayout::Columns);
}
ws.load_static_config(workspace_config)?;
}
}
-8
View File
@@ -881,16 +881,8 @@ impl WindowManager {
pub fn change_workspace_layout_default(&mut self, layout: DefaultLayout) -> eyre::Result<()> {
tracing::info!("changing layout");
let monitor_count = self.monitors().len();
let workspace = self.focused_workspace_mut()?;
if monitor_count > 1 && matches!(layout, DefaultLayout::Scrolling) {
tracing::warn!(
"scrolling layout is only supported for a single monitor; not changing layout"
);
return Ok(());
}
workspace.layout = Layout::Default(layout);
self.update_focused_workspace(self.mouse_follows_focus, false)
}
+10 -2
View File
@@ -1133,6 +1133,9 @@ impl Workspace {
&self.latest_layout,
);
let is_scrolling = matches!(self.layout, Layout::Default(DefaultLayout::Scrolling));
let window_hiding_position = self.globals.window_hiding_position;
let containers = self.containers_mut();
for (i, container) in containers.iter_mut().enumerate() {
@@ -1140,8 +1143,13 @@ impl Workspace {
layout.add_padding(border_offset);
layout.add_padding(border_width);
for window in container.windows() {
if let Err(error) = window.set_position(layout) {
for window in container.windows_mut() {
if is_scrolling && !work_area.contains_within_horizontal_bounds(layout)
{
if let Err(error) = window.hide(window_hiding_position) {
tracing::warn!("failed to set window position: {error}")
}
} else if let Err(error) = window.set_position(layout) {
tracing::warn!("failed to set window position: {error}")
}
}