Struct penrose::pure::StackSet

source ·
pub struct StackSet<C>where
    C: Clone + PartialEq + Eq + Hash,{ /* private fields */ }
Expand description

The side-effect free internal state representation of the window manager.

Implementations§

source§

impl<C> StackSet<C>where C: Clone + PartialEq + Eq + Hash,

source

pub fn try_new<I, J, T>( layouts: LayoutStack, ws_tags: I, screen_details: J ) -> Result<Self>where T: Into<String>, I: IntoIterator<Item = T>, J: IntoIterator<Item = Rect>,

Create a new StackSet of empty stacks with the given workspace names.

Errors

This method will error if there are not enough workspaces to cover the attached screens or if no screens are attached.

source

pub fn focus_screen(&mut self, screen_index: usize)

Set focus to the Screen with the specified index.

If there is no matching screen then the StackSet is unmodified.

source

pub fn focus_tag(&mut self, tag: impl AsRef<str>)

Set focus to the Workspace with the specified tag.

If there is no matching workspace then the StackSet is unmodified. If the Workspace is currently visible then focus moves to the screen containing that workspace, otherwise the workspace replaces whatever was on the active screen.

If you always want to focus the given tag on the active screen, see StackSet::pull_tag_to_screen instead.

source

pub fn pull_tag_to_screen(&mut self, tag: impl AsRef<str>)

Focus the requested tag on the current screen, swapping the current tag with it.

source

pub fn toggle_tag(&mut self)

Toggle focus back to the previously focused Workspace based on its tag

source

pub fn focus_client(&mut self, client: &C)

Focus the given client and set its Workspace as current (see focus_tag).

If the client is unknown then this is a no-op.

source

pub fn insert(&mut self, client: C)

Insert the given client to the current Stack in a default Position.

source

pub fn insert_at(&mut self, pos: Position, client: C)

Insert the given client to the current Stack at the requested Position. If the client is already present somewhere in the StackSet the stack_set is unmodified.

source

pub fn sink(&mut self, client: &C) -> Option<Rect>

Clear the floating status of a client, returning its previous preferred screen position if the client was known, otherwise None.

source

pub fn has_floating_windows(&self, tag: impl AsRef<str>) -> bool

Check whether a given tag currently has any floating windows present.

Returns false if the tag given is unknown to this StackSet.

source

pub fn remove_client(&mut self, client: &C) -> Option<C>

Delete a client from this StackSet.

source

pub fn remove_focused(&mut self) -> Option<C>

Remove the currently focused client from this stack if there is one.

The client is returned to the caller as Some(C) if there was one.

source

pub fn kill_focused(&mut self)

Delete the currently focused client from this stack if there is one.

The following diff will send a kill client message to this client on refresh.

source

pub fn move_focused_to_tag(&mut self, tag: impl AsRef<str>)

Move the focused client of the current Workspace to the focused position of the workspace matching the provided tag.

source

pub fn move_focused_to_screen(&mut self, screen: usize)

Move the focused client of the current Workspace to the focused position of the workspace on Screen screen.

source

pub fn move_client_to_tag(&mut self, client: &C, tag: impl AsRef<str>)

Move the given client to the focused position of the Workspace matching the provided tag. If the client is already on the target workspace it is moved to the focused position.

source

pub fn move_client_to_current_tag(&mut self, client: &C)

Move the given client to the focused position of the current Workspace. If the client is already on the target workspace it is moved to the focused position.

source

pub fn contains_tag(&self, tag: &str) -> bool

Is the given tag present in the StackSet?

source

pub fn ordered_tags(&self) -> Vec<String>

All Workspace tags in this StackSet order by their id that have not been marked as being invisible.

source

pub fn ordered_workspaces(&self) -> impl Iterator<Item = &Workspace<C>>

All Workspaces in this StackSet order by their id that have not been marked as being invisible.

source

pub fn tag_for_screen(&self, index: usize) -> Option<&str>

Find the tag of the Workspace currently displayed on Screen index.

Returns None if the index is out of bounds

source

pub fn tag_for_client(&self, client: &C) -> Option<&str>

Find the tag of the Workspace containing a given client. Returns Some(tag) if the client is known otherwise None.

source

pub fn screen_for_client(&self, client: &C) -> Option<&Screen<C>>

If the given client is currently visible on a screen return a reference to that screen, otherwise None.

source

pub fn tag_for_workspace_id(&self, id: usize) -> Option<String>

Find the tag of the Workspace with the given NetWmDesktop ID.

source

pub fn contains(&self, client: &C) -> bool

Returns true if the StackSet contains an element equal to the given value.

source

pub fn current_client(&self) -> Option<&C>

Extract a reference to the focused element of the current Stack

source

pub fn current_screen(&self) -> &Screen<C>

An immutable reference to the currently focused Screen

source

pub fn current_workspace(&self) -> &Workspace<C>

An immutable reference to the current Workspace

source

pub fn current_workspace_mut(&mut self) -> &mut Workspace<C>

A mutable reference to the current Workspace

source

pub fn current_stack(&self) -> Option<&Stack<C>>

An immutable reference to the current Stack if there is one

source

pub fn current_tag(&self) -> &str

The tag of the current Workspace

source

pub fn add_workspace<T>(&mut self, tag: T, layouts: LayoutStack) -> Result<()>where T: Into<String>,

Add a new Workspace to this StackSet.

The id assigned to this workspace will be max(workspace ids) + 1.

Errors

This function will error with NonUniqueTags if the given tag is already present.

source

pub fn add_invisible_workspace<T>(&mut self, tag: T) -> Result<()>where T: Into<String>,

Add a new invisible Workspace to this StackSet.

It will not be possible to focus this workspace on a screen but its state will be tracked and clients can be placed on it. The id assigned to this workspace will be max(workspace ids) + 1.

Errors

This function will error with NonUniqueTags if the given tag is already present.

source

pub fn workspace(&self, tag: &str) -> Option<&Workspace<C>>

A reference to the Workspace with a tag of tag if there is one

source

pub fn workspace_mut(&mut self, tag: &str) -> Option<&mut Workspace<C>>

A mutable reference to the Workspace with a tag of tag if there is one

source

pub fn next_layout(&mut self)

Switch to the next available Layout on the focused Workspace

source

pub fn previous_layout(&mut self)

Switch to the previous available Layout on the focused Workspace

source

pub fn set_layout_by_name(&mut self, layout: impl AsRef<str>)

Attempt to set the current Layout by name.

This is a no-op if the requested layout is already active or if no layout with the given name is available for the active workspace.

source

pub fn next_screen(&mut self)

Move focus to the next Screen

source

pub fn previous_screen(&mut self)

Move focus to the previous Screen

source

pub fn drag_workspace_forward(&mut self)

Drag the focused workspace onto the next Screen, holding focus

source

pub fn drag_workspace_backward(&mut self)

Drag the focused workspace onto the previous Screen, holding focus

source

pub fn with<T, F>(&self, default: T, f: F) -> Twhere F: Fn(&Stack<C>) -> T,

If the current Stack is None, return default otherwise apply the function to it to generate a value

source

pub fn modify<F>(&mut self, f: F)where F: FnOnce(Option<Stack<C>>) -> Option<Stack<C>>,

Apply a function to modify the current Stack if there is one or compute and inject a default value if it is currently None

source

pub fn modify_occupied<F>(&mut self, f: F)where F: FnOnce(Stack<C>) -> Stack<C>,

Apply a function to modify the current Stack if it is non-empty without allowing for emptying it entirely.

source

pub fn screens(&self) -> impl Iterator<Item = &Screen<C>>

Iterate over each Screen in this StackSet in an arbitrary order.

source

pub fn screens_mut(&mut self) -> impl Iterator<Item = &mut Screen<C>>

Mutably iterate over each Screen in this StackSet in an arbitrary order.

source

pub fn workspaces(&self) -> impl Iterator<Item = &Workspace<C>>

Iterate over each Workspace in this StackSet in an arbitrary order.

source

pub fn non_hidden_workspaces(&self) -> impl Iterator<Item = &Workspace<C>>

Iterate over each non-hidden Workspace in this StackSet in an arbitrary order.

source

pub fn workspaces_mut(&mut self) -> impl Iterator<Item = &mut Workspace<C>>

Mutably iterate over each Workspace in this StackSet in an arbitrary order.

source

pub fn on_screen_workspaces(&self) -> impl Iterator<Item = &Workspace<C>>

Iterate over the Workspace currently displayed on a screen in an arbitrary order.

source

pub fn hidden_workspaces(&self) -> impl Iterator<Item = &Workspace<C>>

Iterate over the currently hidden Workspace in this StackSet in an arbitrary order.

source

pub fn hidden_workspaces_mut( &mut self ) -> impl Iterator<Item = &mut Workspace<C>>

Iterate over the currently hidden Workspace in this StackSet in an arbitrary order.

source

pub fn clients(&self) -> impl Iterator<Item = &C>

Iterate over each client in this StackSet in an arbitrary order.

source

pub fn on_screen_workspace_clients(&self) -> impl Iterator<Item = &C>

Iterate over clients present in on-screen Workspaces.

NOTE: this does not mean that every client returned by this iterator is visible on the screen: only that it is currently assigned to a workspace that is displayed on a screen.

source

pub fn hidden_workspace_clients(&self) -> impl Iterator<Item = &C>

Iterate over clients from workspaces not currently mapped to a screen.

source§

impl StackSet<Xid>

source

pub fn float(&mut self, client: Xid, r: Rect) -> Result<()>

Record a known client as floating, giving its preferred screen position.

Errors

This method with return Error::UnknownClient if the given client is not already managed in this stack_set.

This method with return Error::ClientIsNotVisible if the given client is not currently mapped to a screen. This is required to determine the correct relative positioning for the floating client as is it is moved between screens.

source§

impl<C> StackSet<C>where C: Clone + PartialEq + Eq + Hash,

source

pub fn focus_up(&mut self)

Move focus from the current element up the Stack, wrapping to the bottom if focus is already at the top. This is a no-op if the current stack is empty.

source

pub fn focus_down(&mut self)

Move focus from the current element down the Stack, wrapping to the top if focus is already at the bottom. This is a no-op if the current stack is empty.

source

pub fn swap_up(&mut self)

Swap the position of the focused element with one above it. The currently focused element is maintained by this operation. This is a no-op if the current stack is empty.

source

pub fn swap_down(&mut self)

Swap the position of the focused element with one below it. The currently focused element is maintained by this operation. This is a no-op if the current stack is empty.

source

pub fn rotate_up(&mut self)

Rotate all elements of the stack forward, wrapping from top to bottom. The currently focused position in the stack is maintained by this operation. This is a no-op if the current stack is empty.

source

pub fn rotate_down(&mut self)

Rotate all elements of the stack back, wrapping from bottom to top. The currently focused position in the stack is maintained by this operation. This is a no-op if the current stack is empty.

source

pub fn rotate_focus_to_head(&mut self)

Rotate the Stack until the current focused element is in the head position. This is a no-op if the current stack is empty.

source

pub fn focus_head(&mut self)

Move focus to the element in the head position. This is a no-op if the current stack is empty.

source

pub fn swap_focus_and_head(&mut self)

Swap the current head element with the focused element in the stack order. Focus stays with the original focused element. This is a no-op if the current stack is empty.

Trait Implementations§

source§

impl<C> Clone for StackSet<C>where C: Clone + PartialEq + Eq + Hash + Clone,

source§

fn clone(&self) -> StackSet<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C> Debug for StackSet<C>where C: Clone + PartialEq + Eq + Hash + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C> Default for StackSet<C>where C: Clone + PartialEq + Eq + Hash + Default,

source§

fn default() -> StackSet<C>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for StackSet<C>

§

impl<C> !Send for StackSet<C>

§

impl<C> !Sync for StackSet<C>

§

impl<C> Unpin for StackSet<C>where C: Unpin,

§

impl<C> !UnwindSafe for StackSet<C>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Any for Twhere T: Any,

§

impl<T> CloneAny for Twhere T: Any + Clone,