From ac6e137be3e9d2d2a1d8c1284880096a0e2c2a47 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 11 Oct 2022 15:24:26 +0200 Subject: [PATCH] feat: Add window minimize support --- native/src/window/action.rs | 4 ++++ winit/src/application.rs | 3 +++ winit/src/window.rs | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/native/src/window/action.rs b/native/src/window/action.rs index c49fdf9d6b..009dcc274d 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -20,6 +20,8 @@ pub enum Action { }, /// Sets the window to maximized or back Maximize(bool), + /// Set the window to minimized or back + Minimize(bool), /// Move the window. /// /// Unsupported on Wayland. @@ -50,6 +52,7 @@ impl Action { 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, @@ -68,6 +71,7 @@ impl fmt::Debug for Action { 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) } diff --git a/winit/src/application.rs b/winit/src/application.rs index 7de5a0ce8c..939a50c97b 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -627,6 +627,9 @@ pub fn run_command( 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, diff --git a/winit/src/window.rs b/winit/src/window.rs index 48210c33c9..1e704c5b3d 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -22,6 +22,11 @@ pub fn maximize(value: bool) -> Command { Command::single(command::Action::Window(window::Action::Maximize(value))) } +/// Set the window to minimized or back. +pub fn minimize(value: bool) -> Command { + Command::single(command::Action::Window(window::Action::Minimize(value))) +} + /// Moves a window to the given logical coordinates. pub fn move_to(x: i32, y: i32) -> Command { Command::single(command::Action::Window(window::Action::Move { x, y }))