diff options
-rw-r--r-- | runtime/src/window.rs | 12 | ||||
-rw-r--r-- | winit/src/program.rs | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index cdef70e3..e82d4505 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -167,6 +167,9 @@ pub enum Action { /// Set the window to be resizable or not. SetResizable(Id, bool), + + /// Set the window size increment. + SetResizeIncrements(Id, Option<Size>), } /// Subscribes to the frames of the window of the running application. @@ -400,6 +403,15 @@ pub fn set_min_size<T>(id: Id, size: Option<Size>) -> Task<T> { task::effect(crate::Action::Window(Action::SetMinSize(id, size))) } +/// Set the window size increment. +/// +/// This is usually used by apps such as terminal emulators that need "blocky" resizing. +pub fn set_resize_increments<T>(id: Id, increments: Option<Size>) -> Task<T> { + task::effect(crate::Action::Window(Action::SetResizeIncrements( + id, increments, + ))) +} + /// Show the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu diff --git a/winit/src/program.rs b/winit/src/program.rs index 416c8e70..58f4d96d 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -1311,6 +1311,16 @@ fn run_action<P, C>( })); } } + window::Action::SetResizeIncrements(id, increments) => { + if let Some(window) = window_manager.get_mut(id) { + window.raw.set_resize_increments(increments.map(|x| { + winit::dpi::LogicalSize { + width: x.width, + height: x.height, + } + })); + } + } window::Action::ChangeTitle(id, title) => { if let Some(window) = window_manager.get_mut(id) { window.raw.set_title(&title); |