From f5b01dfeceef49fe856e5a8ed14e92f18c54261d Mon Sep 17 00:00:00 2001 From: Matt George Date: Wed, 30 Oct 2024 00:04:12 -0600 Subject: [PATCH 1/2] hard-code which targets have drag_resize support This replaces the previous check which appeared to rely on the assumption that initiating a drag_resize without a left mouse press wouldn't actually start a resize (this assumption is false on Windows). --- winit/src/application/drag_resize.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/winit/src/application/drag_resize.rs b/winit/src/application/drag_resize.rs index 9f109d3907..ba77f6a5eb 100644 --- a/winit/src/application/drag_resize.rs +++ b/winit/src/application/drag_resize.rs @@ -12,7 +12,7 @@ pub fn event_func( ) -> bool, >, > { - if window.drag_resize_window(ResizeDirection::East).is_ok() { + if drag_resize_supported() { // Keep track of cursor when it is within a resizeable border. let mut cursor_prev_resize_direction = None; @@ -62,6 +62,27 @@ pub fn event_func( } } +/// Test if the current target should be assumed to have winit drag_resize support +const fn drag_resize_supported() -> bool { + #[cfg(all( + unix, + not(target_vendor = "apple"), + not(target_os = "android"), + not(target_os = "emscripten") + ))] + { + return true; + } + + #[cfg(target_os = "windows")] + { + return true; + } + + #[allow(unreachable_code)] + false +} + /// Get the cursor icon that corresponds to the resize direction. fn resize_direction_cursor_icon( resize_direction: Option, From 6dba71128987fa4587029b769ea1b33a27749a10 Mon Sep 17 00:00:00 2001 From: Matt George Date: Sun, 1 Dec 2024 04:51:18 -0700 Subject: [PATCH 2/2] use a variable instead of a fn for hard-coded check --- winit/src/application/drag_resize.rs | 45 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/winit/src/application/drag_resize.rs b/winit/src/application/drag_resize.rs index ba77f6a5eb..d7a30a6cf8 100644 --- a/winit/src/application/drag_resize.rs +++ b/winit/src/application/drag_resize.rs @@ -1,5 +1,27 @@ use winit::window::{CursorIcon, ResizeDirection}; +#[cfg(any( + all( + unix, + not(target_vendor = "apple"), + not(target_os = "android"), + not(target_os = "emscripten"), + ), + target_os = "windows", +))] +const DRAG_RESIZE_SUPPORTED: bool = true; + +#[cfg(not(any( + all( + unix, + not(target_vendor = "apple"), + not(target_os = "android"), + not(target_os = "emscripten"), + ), + target_os = "windows", +)))] +const DRAG_RESIZE_SUPPORTED: bool = false; + /// If supported by winit, returns a closure that implements cursor resize support. pub fn event_func( window: &dyn winit::window::Window, @@ -12,7 +34,7 @@ pub fn event_func( ) -> bool, >, > { - if drag_resize_supported() { + if DRAG_RESIZE_SUPPORTED { // Keep track of cursor when it is within a resizeable border. let mut cursor_prev_resize_direction = None; @@ -62,27 +84,6 @@ pub fn event_func( } } -/// Test if the current target should be assumed to have winit drag_resize support -const fn drag_resize_supported() -> bool { - #[cfg(all( - unix, - not(target_vendor = "apple"), - not(target_os = "android"), - not(target_os = "emscripten") - ))] - { - return true; - } - - #[cfg(target_os = "windows")] - { - return true; - } - - #[allow(unreachable_code)] - false -} - /// Get the cursor icon that corresponds to the resize direction. fn resize_direction_cursor_icon( resize_direction: Option,