diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-10 09:24:20 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-10-10 09:24:20 +0300 |
| commit | ab7d81aae00e88395f85b629489512b4a7bac064 (patch) | |
| tree | 239f976094a3454022754e218fb71c6fceee8431 /src/layout | |
| parent | e24723125f5ef91983735043fba893a940469686 (diff) | |
| download | niri-ab7d81aae00e88395f85b629489512b4a7bac064.tar.gz niri-ab7d81aae00e88395f85b629489512b4a7bac064.tar.bz2 niri-ab7d81aae00e88395f85b629489512b4a7bac064.zip | |
layout: Reduce field visibility
The outside code isn't supposed to mess with the fields.
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 2 | ||||
| -rw-r--r-- | src/layout/monitor.rs | 22 | ||||
| -rw-r--r-- | src/layout/tile.rs | 2 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 26 |
4 files changed, 32 insertions, 20 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 7c4d4618..05cbdccd 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -81,7 +81,7 @@ pub type LayoutElementRenderSnapshot = #[derive(Debug, Clone, Copy)] pub struct InteractiveResizeData { - pub edges: ResizeEdge, + pub(self) edges: ResizeEdge, } #[derive(Debug, Clone, Copy)] diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 2bd84665..a4960012 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -33,19 +33,19 @@ const WORKSPACE_GESTURE_RUBBER_BAND: RubberBand = RubberBand { #[derive(Debug)] pub struct Monitor<W: LayoutElement> { /// Output for this monitor. - pub output: Output, + pub(super) output: Output, /// Cached name of the output. output_name: String, // Must always contain at least one. - pub workspaces: Vec<Workspace<W>>, + pub(super) workspaces: Vec<Workspace<W>>, /// Index of the currently active workspace. - pub active_workspace_idx: usize, + pub(super) active_workspace_idx: usize, /// ID of the previously active workspace. - pub previous_workspace_id: Option<WorkspaceId>, + pub(super) previous_workspace_id: Option<WorkspaceId>, /// In-progress switch between workspaces. - pub workspace_switch: Option<WorkspaceSwitch>, + pub(super) workspace_switch: Option<WorkspaceSwitch>, /// Configurable properties of the layout. - pub options: Rc<Options>, + pub(super) options: Rc<Options>, } #[derive(Debug)] @@ -59,7 +59,7 @@ pub struct WorkspaceSwitchGesture { /// Index of the workspace where the gesture was started. center_idx: usize, /// Current, fractional workspace index. - pub current_idx: f64, + pub(super) current_idx: f64, tracker: SwipeTracker, /// Whether the gesture is controlled by the touchpad. is_touchpad: bool, @@ -105,10 +105,18 @@ impl<W: LayoutElement> Monitor<W> { } } + pub fn output(&self) -> &Output { + &self.output + } + pub fn output_name(&self) -> &String { &self.output_name } + pub fn active_workspace_idx(&self) -> usize { + self.active_workspace_idx + } + pub fn active_workspace_ref(&self) -> &Workspace<W> { &self.workspaces[self.active_workspace_idx] } diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 11c266d4..28b3ffd0 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -74,7 +74,7 @@ pub struct Tile<W: LayoutElement> { scale: f64, /// Configurable properties of the layout. - pub options: Rc<Options>, + pub(super) options: Rc<Options>, } niri_render_elements! { diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 179055ae..2b4133cd 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -37,7 +37,7 @@ pub struct Workspace<W: LayoutElement> { /// /// Most of the time this will be the workspace's current output, however, after an output /// disconnection, it may remain pointing to the disconnected output. - pub original_output: OutputId, + pub(super) original_output: OutputId, /// Current output of this workspace. output: Option<Output>, @@ -67,13 +67,13 @@ pub struct Workspace<W: LayoutElement> { working_area: Rectangle<f64, Logical>, /// Columns of windows on this workspace. - pub columns: Vec<Column<W>>, + pub(super) columns: Vec<Column<W>>, /// Extra per-column data. data: Vec<ColumnData>, /// Index of the currently active column, if any. - pub active_column_idx: usize, + pub(super) active_column_idx: usize, /// Ongoing interactive resize. interactive_resize: Option<InteractiveResize<W>>, @@ -107,13 +107,13 @@ pub struct Workspace<W: LayoutElement> { closing_windows: Vec<ClosingWindow>, /// Configurable properties of the layout as received from the parent monitor. - pub base_options: Rc<Options>, + pub(super) base_options: Rc<Options>, /// Configurable properties of the layout with logical sizes adjusted for the current `scale`. - pub options: Rc<Options>, + pub(super) options: Rc<Options>, /// Optional name of this workspace. - pub name: Option<String>, + pub(super) name: Option<String>, /// Unique ID of this workspace. id: WorkspaceId, @@ -237,7 +237,7 @@ pub struct Column<W: LayoutElement> { /// Tiles in this column. /// /// Must be non-empty. - pub tiles: Vec<Tile<W>>, + pub(super) tiles: Vec<Tile<W>>, /// Extra per-tile data. /// @@ -245,19 +245,19 @@ pub struct Column<W: LayoutElement> { data: Vec<TileData>, /// Index of the currently active tile. - pub active_tile_idx: usize, + pub(super) active_tile_idx: usize, /// Desired width of this column. /// /// If the column is full-width or full-screened, this is the width that should be restored /// upon unfullscreening and untoggling full-width. - pub width: ColumnWidth, + pub(super) width: ColumnWidth, /// Whether this column is full-width. - pub is_full_width: bool, + pub(super) is_full_width: bool, /// Whether this column contains a single full-screened window. - pub is_fullscreen: bool, + pub(super) is_fullscreen: bool, /// Animation of the render offset during window swapping. move_animation: Option<Animation>, @@ -471,6 +471,10 @@ impl<W: LayoutElement> Workspace<W> { self.id } + pub fn name(&self) -> Option<&String> { + self.name.as_ref() + } + pub fn unname(&mut self) { self.name = None; } |
