diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-12-27 21:51:42 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-12-27 21:51:42 +0400 |
| commit | c21805bf705bd36a6eb7f79039b759e9af79dfcb (patch) | |
| tree | e24213b023c8129320daa782c8b0830ea334d519 /src/layout/mod.rs | |
| parent | bfc24182670a0b3e17f79d66474fd291b7110732 (diff) | |
| download | niri-c21805bf705bd36a6eb7f79039b759e9af79dfcb.tar.gz niri-c21805bf705bd36a6eb7f79039b759e9af79dfcb.tar.bz2 niri-c21805bf705bd36a6eb7f79039b759e9af79dfcb.zip | |
layout: Refactor to support window decorations, add border and fullscreen backdrop
Windows are now wrapped in Tiles, which keep track of window-specific
decorations. Particularly, I implemented a black fullscreen backdrop,
which finally brings fullscreened windows smaller than the screen in
line with how the Wayland protocol says they should lookâcentered in a
black rectangle. I also implemented window borders, which are similar to
the focus ring, but always visible (and hence affect the layout and
sizing).
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 61aaf211..8d454728 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -56,6 +56,7 @@ use crate::utils::output_size; mod focus_ring; mod monitor; +mod tile; mod workspace; pub trait LayoutElement: PartialEq { @@ -97,6 +98,11 @@ pub trait LayoutElement: PartialEq { fn set_preferred_scale_transform(&self, scale: i32, transform: Transform); fn output_enter(&self, output: &Output); fn output_leave(&self, output: &Output); + + /// Whether the element is currently fullscreen. + /// + /// This will *not* switch immediately after a [`LayoutElement::request_fullscreen()`] call. + fn is_fullscreen(&self) -> bool; } #[derive(Debug)] @@ -132,6 +138,7 @@ pub struct Options { /// Extra padding around the working area in logical pixels. struts: Struts, focus_ring: config::FocusRing, + border: config::FocusRing, /// Column widths that `toggle_width()` switches between. preset_widths: Vec<ColumnWidth>, /// Initial width for new windows. @@ -144,6 +151,7 @@ impl Default for Options { gaps: 16, struts: Default::default(), focus_ring: Default::default(), + border: config::default_border(), preset_widths: vec![ ColumnWidth::Proportion(1. / 3.), ColumnWidth::Proportion(0.5), @@ -180,6 +188,7 @@ impl Options { gaps: config.gaps.into(), struts: config.struts, focus_ring: config.focus_ring, + border: config.border, preset_widths, default_width, } @@ -269,6 +278,13 @@ impl LayoutElement for Window { fn output_leave(&self, output: &Output) { SpaceElement::output_leave(self, output) } + + fn is_fullscreen(&self) -> bool { + self.toplevel() + .current_state() + .states + .contains(xdg_toplevel::State::Fullscreen) + } } impl<W: LayoutElement> Layout<W> { @@ -701,7 +717,7 @@ impl<W: LayoutElement> Layout<W> { } let col = &ws.columns[ws.active_column_idx]; - Some((&col.windows[col.active_window_idx], &mon.output)) + Some((&col.windows[col.active_window_idx].window(), &mon.output)) } pub fn windows_for_output(&self, output: &Output) -> impl Iterator<Item = &W> + '_ { @@ -1458,6 +1474,10 @@ mod tests { fn output_enter(&self, _output: &Output) {} fn output_leave(&self, _output: &Output) {} + + fn is_fullscreen(&self) -> bool { + false + } } fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { |
