add toggle decorations action
This commit is contained in:
parent
7ceb8b8d40
commit
750fecd6bc
2 changed files with 10 additions and 0 deletions
|
|
@ -35,6 +35,11 @@ pub enum Action<T> {
|
||||||
SetMode(Mode),
|
SetMode(Mode),
|
||||||
/// Sets the window to maximized or back
|
/// Sets the window to maximized or back
|
||||||
ToggleMaximize,
|
ToggleMaximize,
|
||||||
|
/// Toggles whether window has decorations
|
||||||
|
/// ## Platform-specific
|
||||||
|
/// - **X11:** Not implemented.
|
||||||
|
/// - **iOS / Android / Web:** Unsupported.
|
||||||
|
ToggleDecorations,
|
||||||
/// Fetch the current [`Mode`] of the window.
|
/// Fetch the current [`Mode`] of the window.
|
||||||
FetchMode(Box<dyn FnOnce(Mode) -> T + 'static>),
|
FetchMode(Box<dyn FnOnce(Mode) -> T + 'static>),
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +61,7 @@ impl<T> Action<T> {
|
||||||
Self::Move { x, y } => Action::Move { x, y },
|
Self::Move { x, y } => Action::Move { x, y },
|
||||||
Self::SetMode(mode) => Action::SetMode(mode),
|
Self::SetMode(mode) => Action::SetMode(mode),
|
||||||
Self::ToggleMaximize => Action::ToggleMaximize,
|
Self::ToggleMaximize => Action::ToggleMaximize,
|
||||||
|
Self::ToggleDecorations => Action::ToggleDecorations,
|
||||||
Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))),
|
Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +83,7 @@ impl<T> fmt::Debug for Action<T> {
|
||||||
}
|
}
|
||||||
Self::SetMode(mode) => write!(f, "Action::SetMode({:?})", mode),
|
Self::SetMode(mode) => write!(f, "Action::SetMode({:?})", mode),
|
||||||
Self::ToggleMaximize => write!(f, "Action::ToggleMaximize"),
|
Self::ToggleMaximize => write!(f, "Action::ToggleMaximize"),
|
||||||
|
Self::ToggleDecorations => write!(f, "Action::ToggleDecorations"),
|
||||||
Self::FetchMode(_) => write!(f, "Action::FetchMode"),
|
Self::FetchMode(_) => write!(f, "Action::FetchMode"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -660,6 +660,9 @@ pub fn run_command<A, E>(
|
||||||
window::Action::ToggleMaximize => {
|
window::Action::ToggleMaximize => {
|
||||||
window.set_maximized(!window.is_maximized())
|
window.set_maximized(!window.is_maximized())
|
||||||
}
|
}
|
||||||
|
window::Action::ToggleDecorations => {
|
||||||
|
window.set_decorations(!window.is_decorated())
|
||||||
|
}
|
||||||
window::Action::FetchMode(tag) => {
|
window::Action::FetchMode(tag) => {
|
||||||
let mode = if window.is_visible().unwrap_or(true) {
|
let mode = if window.is_visible().unwrap_or(true) {
|
||||||
conversion::mode(window.fullscreen())
|
conversion::mode(window.fullscreen())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue