feat: add a window drag resize task

This commit is contained in:
tsuza 2024-10-16 18:17:10 +02:00 committed by Héctor Ramón Jiménez
parent a00f564dee
commit e3f149d932
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 77 additions and 2 deletions

View file

@ -1120,7 +1120,7 @@ pub fn native_key_code(
}
}
/// Converts some [`UserAttention`] into it's `winit` counterpart.
/// Converts some [`UserAttention`] into its `winit` counterpart.
///
/// [`UserAttention`]: window::UserAttention
pub fn user_attention(
@ -1136,6 +1136,32 @@ pub fn user_attention(
}
}
/// Converts some [`ResizeDirection`] into its `winit` counterpart.
///
/// [`ResizeDirection`]: window::ResizeDirection
pub fn resize_direction(
resize_direction: window::Direction,
) -> winit::window::ResizeDirection {
match resize_direction {
window::Direction::North => winit::window::ResizeDirection::North,
window::Direction::South => winit::window::ResizeDirection::South,
window::Direction::East => winit::window::ResizeDirection::East,
window::Direction::West => winit::window::ResizeDirection::West,
window::Direction::NorthEast => {
winit::window::ResizeDirection::NorthEast
}
window::Direction::NorthWest => {
winit::window::ResizeDirection::NorthWest
}
window::Direction::SouthEast => {
winit::window::ResizeDirection::SouthEast
}
window::Direction::SouthWest => {
winit::window::ResizeDirection::SouthWest
}
}
}
/// Converts some [`window::Icon`] into it's `winit` counterpart.
///
/// Returns `None` if there is an error during the conversion.

View file

@ -1265,6 +1265,13 @@ fn run_action<P, C>(
let _ = window.raw.drag_window();
}
}
window::Action::DragResize(id, direction) => {
if let Some(window) = window_manager.get_mut(id) {
let _ = window.raw.drag_resize_window(
conversion::resize_direction(direction),
);
}
}
window::Action::Resize(id, size) => {
if let Some(window) = window_manager.get_mut(id) {
let _ = window.raw.request_inner_size(