Skip to content

Commit

Permalink
feat: Add window minimize support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Oct 11, 2022
1 parent 8a50836 commit ac6e137
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions native/src/window/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum Action<T> {
},
/// Sets the window to maximized or back
Maximize(bool),
/// Set the window to minimized or back
Minimize(bool),
/// Move the window.
///
/// Unsupported on Wayland.
Expand Down Expand Up @@ -50,6 +52,7 @@ impl<T> Action<T> {
Self::Drag => Action::Drag,
Self::Resize { width, height } => Action::Resize { width, height },
Self::Maximize(bool) => Action::Maximize(bool),
Self::Minimize(bool) => Action::Minimize(bool),
Self::Move { x, y } => Action::Move { x, y },
Self::SetMode(mode) => Action::SetMode(mode),
Self::ToggleMaximize => Action::ToggleMaximize,
Expand All @@ -68,6 +71,7 @@ impl<T> fmt::Debug for Action<T> {
width, height
),
Self::Maximize(value) => write!(f, "Action::Maximize({})", value),
Self::Minimize(value) => write!(f, "Action::Minimize({}", value),
Self::Move { x, y } => {
write!(f, "Action::Move {{ x: {}, y: {} }}", x, y)
}
Expand Down
3 changes: 3 additions & 0 deletions winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@ pub fn run_command<A, E>(
window::Action::Maximize(value) => {
window.set_maximized(value);
}
window::Action::Minimize(value) => {
window.set_minimized(value);
}
window::Action::Move { x, y } => {
window.set_outer_position(winit::dpi::LogicalPosition {
x,
Expand Down
5 changes: 5 additions & 0 deletions winit/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pub fn maximize<Message>(value: bool) -> Command<Message> {
Command::single(command::Action::Window(window::Action::Maximize(value)))
}

/// Set the window to minimized or back.
pub fn minimize<Message>(value: bool) -> Command<Message> {
Command::single(command::Action::Window(window::Action::Minimize(value)))
}

/// Moves a window to the given logical coordinates.
pub fn move_to<Message>(x: i32, y: i32) -> Command<Message> {
Command::single(command::Action::Window(window::Action::Move { x, y }))
Expand Down

0 comments on commit ac6e137

Please sign in to comment.