[−][src]Module penrose::core::layout
User definable window arangements for a Workspace.
Layouts are maintained per monitor and allow for indepent management of the two paramaters
(max_main
, ratio
) that are used to modify layout logic. Layout functions are only called
when there is a need to re-layout a given screen and will always be given a full list of
Clients that the WindowManager considers tiled. There are no restrictions as to
whether or not windows may overlap or that they provide a total covering of the available
screen space. Gaps and borders will be added to the Regions that are specified by layout
functions by eating into the regions specified, so there is no need to account for this when
writing a layout function.
Writing a simple layout function
Lets start with a very basic layout that ignores the two paramaters (max_main
and ratio
)
and instead, simply arranges the Clients it is given as evenly spaced rows:
use penrose::core::{ client::Client, data_types::{Change, Region, ResizeAction, WinId}, }; pub fn rows( clients: &[&Client], _focused: Option<WinId>, monitor_region: &Region, _max_main: u32, _ratio: f32, ) -> Vec<ResizeAction> { monitor_region .as_rows(clients.len() as u32) .iter() .zip(clients) .map(|(r, c)| (c.id(), Some(*r))) .collect() }
Here we are making use of the as_rows method on Region
to split the region we are given
(the total available space on the current screen) into evenly sized rows. (There are a number of
utility methods on Region
to aid in writing layout functions.) We then pair each client with
Some(region)
to indicate that this is where the client should be placed by the
WindowManager
. If we provide None
for any of the clients, that client will then instead be
hidden.
Note, windows are positioned and mapped in order, meaning that later clients will overlap those that have already been positioned if any of the Regions overlap one another.
This simple rows
layout is a sub-set of the behaviour provided by the built in
side_stack layout (in effect, clamping max_main
at 0).
Structs
Layout | Responsible for arranging Clients within a Workspace. |
LayoutConf | When and how a Layout should be applied. |
Functions
bottom_stack | A simple layout that places the main region at the top of the screen and tiles remaining windows in a single row underneath. |
client_breakdown | number of clients for the main area vs secondary |
floating | A no-op floating layout that simply satisfies the type required for Layout |
monocle | A simple monolve layout that places uses the maximum available space for the focused client and unmaps all other windows. |
side_stack | A simple layout that places the main region on the left and tiles remaining windows in a single column to the right. |
Type Definitions
LayoutFunc | A function that can be used to position Clients on a Workspace. |