From c21805bf705bd36a6eb7f79039b759e9af79dfcb Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 27 Dec 2023 21:51:42 +0400 Subject: layout: Refactor to support window decorations, add border and fullscreen backdrop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- src/layout/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/layout/mod.rs') 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, /// 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 Layout { @@ -701,7 +717,7 @@ impl Layout { } 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 + '_ { @@ -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> { -- cgit