Skip to main content

Window

Struct Window 

Source
pub struct Window { /* private fields */ }
Expand description

A type representing windows managed by the window manager. An instance is only obtainable through wmctrl::get_windows()

Note: Since wmctrl fails silently there is no warranty that the actions performed on the window will be successful. This is a flaw in the command line tool itself and not of this crate.

Implementations§

Source§

impl Window

Source

pub fn set_title(&mut self, title: &str)

Set the title of the window

This method is the equivalent of wmctrl -r <WIN> -N <STR>.

Source

pub fn set_icon_title(&self, title: &str)

Set the icon title (short title) of the window

This method is the equivalent of wmctrl -r <WIN> -I <STR>.

Source

pub fn set_both_title(&mut self, title: &str)

Set both the title and icon title of the window

This method is the equivalent of wmctrl -r <WIN> -T <STR>.

Source

pub fn change_state(&self, state: State)

Change the state of the window

Using this method it’s possible for example to make the window maximized, minimized, or fullscreen. This method is the equivalent of wmctrl -r <WIN> -b <STARG>.

§Examples
let windows = wmctrl::get_windows();
let win = &windows[0];
// Make the window fullscreen
win.change_state(wmctrl::State::new(wmctrl::Action::Add, wmctrl::Property::Fullscreen));
Source

pub fn transform(&mut self, transformation: Transformation)

Resize and move the window around the desktop

This method is the equivalent of wmctrl -r <WIN> -e <MVARG>.

§Examples
let mut windows = wmctrl::get_windows();
let win = &mut windows[0];
// This will move the window to the top left corner and resize it to 960x540
win.transform(wmctrl::Transformation::new(0, 0, 960, 540));
Source

pub fn set_desktop(&mut self, desktop: &str)

Move the window to the specified desktop

This method is the equivalent of wmctrl -r <WIN> -t <DESK>.

Source

pub fn activate(&mut self)

Move the window to the current desktop and raise it

This method is the equivalent of wmctrl -R <WIN>.

Source

pub fn raise(&self)

Activate the window by switching to its desktop and raising it

This method is the equivalent of wmctrl -a <WIN>.

Source

pub fn close(self)

Close the window gracefully

This method is the equivalent of wmctrl -c <WIN>.

§Examples
use wmctrl::Window;

// We need to move the window out of the vector so there is no reference left
let win: Window = wmctrl::get_windows().remove(0);
win.close();
Source

pub fn title(&self) -> &String

Get the title immutably

Trait Implementations§

Source§

impl Debug for Window

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.