Struct ClientGrid
pub(super) struct ClientGrid {
pub cols: i32,
pub rows: i32,
last_row_count: i32,
cells: Vec<GridCell>,
by_pid: HashMap<u32, usize>,
}Expand description
Spatial-grid view over the tracked client PIDs.
Fields§
§cols: i32Number of columns in the dense upper rows.
rows: i32Total number of rows (>= 1 whenever there is at least one cell).
last_row_count: i32Cell count in the last row. 0 means the last row is also dense;
otherwise 1..cols last-row cells are stretched proportionally.
cells: Vec<GridCell>Cells sorted by (row, col) so the top-left cell is at index 0.
by_pid: HashMap<u32, usize>PID lookup table.
Implementations§
§impl ClientGrid
impl ClientGrid
pub(super) fn from_tiled_pids(
cells: &[(u32, usize)],
layout_n: i32,
cols: i32,
rows: i32,
) -> Self
pub(super) fn from_tiled_pids( cells: &[(u32, usize)], layout_n: i32, cols: i32, rows: i32, ) -> Self
Build the grid from (pid, tile_index) pairs and the dimensions
returned by grid_dimensions for the same layout_n.
tile_index is the position each client was assigned the last
time the tiler positioned its window. Surviving clients keep
their tile_index across closures, so passing them here together
with the layout’s original layout_n produces a grid whose cells
land at the same (row, col) the user sees on screen - with
gaps where a window was closed but no retile has happened yet.
§Arguments
cells-(pid, tile_index)pairs for every surviving client.layout_n- Thenumber_of_consolesthe on-screen layout was last computed with. Used to derive the partial-last-row stretch.cols- Columns fromgrid_dimensionsforlayout_n.rows- Rows fromgrid_dimensionsforlayout_n.
§Returns
A populated ClientGrid.
pub(super) fn top_left_pid(&self) -> Option<u32>
pub(super) fn top_left_pid(&self) -> Option<u32>
PID of the top-left cell, or None for an empty grid. Used to
re-anchor the submenu selection onto a sensible visual default.
pub(super) fn anchor_for(&self, cell: &GridCell) -> i32
pub(super) fn anchor_for(&self, cell: &GridCell) -> i32
Compute the anchor column for a cell. Horizontal moves overwrite the in-flight anchor with the destination cell’s anchor.
Upper-row cells: their col (each cell occupies exactly one
upper-grid column). Partial-last-row cells: the upper-grid column
containing the cell’s x-midpoint. The latter makes a Down + Up
roundtrip return to the original cell from any starting point.
§Arguments
cell- The destination cell.
§Returns
The anchor column for the cell.
pub(super) fn step(
&self,
pid: u32,
anchor_col: i32,
direction: NavigationDirection,
edge: EdgeBehavior,
) -> Option<(u32, i32)>
pub(super) fn step( &self, pid: u32, anchor_col: i32, direction: NavigationDirection, edge: EdgeBehavior, ) -> Option<(u32, i32)>
Compute the next selection after one navigation keystroke.
§Arguments
pid- Currently highlighted PID.anchor_col- Anchor column carried from earlier moves.direction- Direction of the keystroke.edge- Behavior when the move would leave the grid.
§Returns
Some((new_pid, new_anchor_col)) on a successful step.
None when pid is not present in this grid (caller should
re-anchor).
fn step_horizontal(
&self,
current: &GridCell,
anchor_col: i32,
direction: NavigationDirection,
edge: EdgeBehavior,
) -> Option<(u32, i32)>
fn step_horizontal( &self, current: &GridCell, anchor_col: i32, direction: NavigationDirection, edge: EdgeBehavior, ) -> Option<(u32, i32)>
Horizontal step within current.row. Returns None only when
the row somehow contains no cells (cannot happen for a valid
current looked up from the grid). A clamped no-op preserves
the in-flight anchor_col so a subsequent vertical step still
targets the column the user originally carried over.
fn step_vertical(
&self,
current: &GridCell,
anchor_col: i32,
direction: NavigationDirection,
edge: EdgeBehavior,
) -> (u32, i32)
fn step_vertical( &self, current: &GridCell, anchor_col: i32, direction: NavigationDirection, edge: EdgeBehavior, ) -> (u32, i32)
Vertical step into the target row, preserving the in-flight
anchor_col.
fn anchor_distance(
&self,
cell: &GridCell,
anchor_col: i32,
is_partial_last_row: bool,
) -> i64
fn anchor_distance( &self, cell: &GridCell, anchor_col: i32, is_partial_last_row: bool, ) -> i64
Spatial distance between a cell and an anchor column, used to
pick the target on a vertical step. Dense rows reduce to
|c.col - anchor|; partial-last-row cells use their stretched
x-extent so the cell whose midpoint is closest to the anchor’s
centerline wins. The result is in arbitrary integer units valid
only for comparisons within the same row.
Auto Trait Implementations§
impl Freeze for ClientGrid
impl RefUnwindSafe for ClientGrid
impl Send for ClientGrid
impl Sync for ClientGrid
impl Unpin for ClientGrid
impl UnsafeUnpin for ClientGrid
impl UnwindSafe for ClientGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.