diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/handlers/xdg_shell.rs | 8 | ||||
| -rw-r--r-- | src/input/mod.rs | 2 | ||||
| -rw-r--r-- | src/ipc/server.rs | 8 | ||||
| -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 |
7 files changed, 41 insertions, 29 deletions
diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 06c60a4c..031ef571 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -332,7 +332,7 @@ impl XdgShellHandler for State { *output = mon .filter(|(_, parent)| !parent) - .map(|(mon, _)| mon.output.clone()); + .map(|(mon, _)| mon.output().clone()); let mon = mon.map(|(mon, _)| mon); let ws = mon @@ -416,7 +416,7 @@ impl XdgShellHandler for State { *output = mon .filter(|(_, parent)| !parent) - .map(|(mon, _)| mon.output.clone()); + .map(|(mon, _)| mon.output().clone()); let mon = mon.map(|(mon, _)| mon); let ws = workspace_name @@ -694,7 +694,7 @@ impl State { // mapped, it fetches the possibly changed parent's output again, and shows up there. let output = mon .filter(|(_, parent)| !parent) - .map(|(mon, _)| mon.output.clone()); + .map(|(mon, _)| mon.output().clone()); let mon = mon.map(|(mon, _)| mon); let mut width = None; @@ -747,7 +747,7 @@ impl State { width, is_full_width, output, - workspace_name: ws.and_then(|w| w.name.clone()), + workspace_name: ws.and_then(|w| w.name().cloned()), }; toplevel.send_configure(); diff --git a/src/input/mod.rs b/src/input/mod.rs index 70356253..763620f5 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -559,7 +559,7 @@ impl State { let mut windows = self.niri.layout.windows(); let window = windows.find(|(_, m)| m.id().get() == id); if let Some((Some(monitor), mapped)) = window { - let output = &monitor.output; + let output = monitor.output(); self.backend.with_primary_renderer(|renderer| { if let Err(err) = self.niri.screenshot_window(renderer, output, mapped) { warn!("error taking screenshot: {err:?}"); diff --git a/src/ipc/server.rs b/src/ipc/server.rs index 633707eb..79af18d5 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -464,7 +464,7 @@ impl State { // Check for any changes that we can't signal as individual events. let output_name = mon.map(|mon| mon.output_name()); if ipc_ws.idx != u8::try_from(ws_idx + 1).unwrap_or(u8::MAX) - || ipc_ws.name != ws.name + || ipc_ws.name.as_ref() != ws.name() || ipc_ws.output.as_ref() != output_name { need_workspaces_changed = true; @@ -487,7 +487,7 @@ impl State { } // Check if this workspace became active. - let is_active = mon.map_or(false, |mon| mon.active_workspace_idx == ws_idx); + let is_active = mon.map_or(false, |mon| mon.active_workspace_idx() == ws_idx); if is_active && !ipc_ws.is_active { events.push(Event::WorkspaceActivated { id, focused: false }); } @@ -508,9 +508,9 @@ impl State { Workspace { id, idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX), - name: ws.name.clone(), + name: ws.name().cloned(), output: mon.map(|mon| mon.output_name().clone()), - is_active: mon.map_or(false, |mon| mon.active_workspace_idx == ws_idx), + is_active: mon.map_or(false, |mon| mon.active_workspace_idx() == ws_idx), is_focused: Some(id) == focused_ws_id, active_window_id: ws.active_window().map(|win| win.id().get()), } 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; } |
