aboutsummaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-02-23 13:57:56 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-02-23 14:01:32 +0400
commit2317021a7c4a7296606533d38f1fdce96826f7dc (patch)
tree10ff4760e21b9379853065f3472ae75d3986f183 /src/layout/mod.rs
parentaf6485cd8c85665b15ef8d2c812da17604ca4e32 (diff)
downloadniri-2317021a7c4a7296606533d38f1fdce96826f7dc.tar.gz
niri-2317021a7c4a7296606533d38f1fdce96826f7dc.tar.bz2
niri-2317021a7c4a7296606533d38f1fdce96826f7dc.zip
Implement explicit unmapped window state tracking
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index edc0d9de..c7239a2b 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -531,15 +531,10 @@ impl<W: LayoutElement> Layout<W> {
pub fn add_window(
&mut self,
window: W,
- width: Option<Option<ColumnWidth>>,
+ width: Option<ColumnWidth>,
is_full_width: bool,
) -> Option<&Output> {
- let width = match width {
- Some(Some(width)) => Some(width),
- Some(None) => None,
- None => self.options.default_width,
- }
- .unwrap_or_else(|| ColumnWidth::Fixed(window.size().w));
+ let width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w));
match &mut self.monitor_set {
MonitorSet::Normal {
@@ -587,15 +582,10 @@ impl<W: LayoutElement> Layout<W> {
&mut self,
right_of: &W,
window: W,
- width: Option<Option<ColumnWidth>>,
+ width: Option<ColumnWidth>,
is_full_width: bool,
) -> Option<&Output> {
- let width = match width {
- Some(Some(width)) => Some(width),
- Some(None) => None,
- None => self.options.default_width,
- }
- .unwrap_or_else(|| ColumnWidth::Fixed(window.size().w));
+ let width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w));
match &mut self.monitor_set {
MonitorSet::Normal { monitors, .. } => {
@@ -623,15 +613,10 @@ impl<W: LayoutElement> Layout<W> {
&mut self,
output: &Output,
window: W,
- width: Option<Option<ColumnWidth>>,
+ width: Option<ColumnWidth>,
is_full_width: bool,
) {
- let width = match width {
- Some(Some(width)) => Some(width),
- Some(None) => None,
- None => self.options.default_width,
- }
- .unwrap_or_else(|| ColumnWidth::Fixed(window.size().w));
+ let width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w));
let MonitorSet::Normal {
monitors,
@@ -931,6 +916,19 @@ impl<W: LayoutElement> Layout<W> {
Some(&mut monitors[*active_monitor_idx])
}
+ pub fn active_monitor_ref(&self) -> Option<&Monitor<W>> {
+ let MonitorSet::Normal {
+ monitors,
+ active_monitor_idx,
+ ..
+ } = &self.monitor_set
+ else {
+ return None;
+ };
+
+ Some(&monitors[*active_monitor_idx])
+ }
+
pub fn monitor_for_output(&self, output: &Output) -> Option<&Monitor<W>> {
let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
return None;