Skip to content

Commit

Permalink
Merge pull request #1588 from Night-Hunter-NF/ToggleDecorations
Browse files Browse the repository at this point in the history
add toggle decorations action
  • Loading branch information
hecrj authored Dec 14, 2022
2 parents 02182ee + cfcf201 commit b01be6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions native/src/window/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ pub enum Action<T> {
SetMode(Mode),
/// Sets the window to maximized or back
ToggleMaximize,
/// Toggles whether window has decorations
/// ## Platform-specific
/// - **X11:** Not implemented.
/// - **Web:** Unsupported.
ToggleDecorations,
/// Fetch the current [`Mode`] of the window.
FetchMode(Box<dyn FnOnce(Mode) -> T + 'static>),
}
Expand All @@ -56,6 +61,7 @@ impl<T> Action<T> {
Self::Move { x, y } => Action::Move { x, y },
Self::SetMode(mode) => Action::SetMode(mode),
Self::ToggleMaximize => Action::ToggleMaximize,
Self::ToggleDecorations => Action::ToggleDecorations,
Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))),
}
}
Expand All @@ -77,6 +83,7 @@ impl<T> fmt::Debug for Action<T> {
}
Self::SetMode(mode) => write!(f, "Action::SetMode({:?})", mode),
Self::ToggleMaximize => write!(f, "Action::ToggleMaximize"),
Self::ToggleDecorations => write!(f, "Action::ToggleDecorations"),
Self::FetchMode(_) => write!(f, "Action::FetchMode"),
}
}
Expand Down
3 changes: 3 additions & 0 deletions winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,9 @@ pub fn run_command<A, E>(
window::Action::ToggleMaximize => {
window.set_maximized(!window.is_maximized())
}
window::Action::ToggleDecorations => {
window.set_decorations(!window.is_decorated())
}
window::Action::FetchMode(tag) => {
let mode = if window.is_visible().unwrap_or(true) {
conversion::mode(window.fullscreen())
Expand Down

0 comments on commit b01be6b

Please sign in to comment.