mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
On Windows, add drag_resize_window
method support (#2966)
This commit is contained in:
parent
f7a84a5b50
commit
c62e64060b
|
@ -24,6 +24,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On Web, implement `Window::focus_window()`.
|
- On Web, implement `Window::focus_window()`.
|
||||||
- On Web, remove unnecessary `Window::is_dark_mode()`, which was replaced with `Window::theme()`.
|
- On Web, remove unnecessary `Window::is_dark_mode()`, which was replaced with `Window::theme()`.
|
||||||
- On Web, add `WindowBuilderExtWebSys::with_append()` to append the canvas element to the web page on creation.
|
- On Web, add `WindowBuilderExtWebSys::with_append()` to append the canvas element to the web page on creation.
|
||||||
|
- On Windows, add `drag_resize_window` method support.
|
||||||
|
|
||||||
# 0.29.0-beta.0
|
# 0.29.0-beta.0
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ Legend:
|
||||||
|Gamepad/Joystick events |❌[#804] |❌ |❌ |❌ |❌ |❌ |❓ |**N/A** |
|
|Gamepad/Joystick events |❌[#804] |❌ |❌ |❌ |❌ |❌ |❓ |**N/A** |
|
||||||
|Device movement events |❓ |❓ |❓ |❓ |❌ |❌ |❓ |**N/A** |
|
|Device movement events |❓ |❓ |❓ |❓ |❌ |❌ |❓ |**N/A** |
|
||||||
|Drag window with cursor |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** |**N/A** |
|
|Drag window with cursor |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** |**N/A** |
|
||||||
|Resize with cursor |❌ |❌ |✔️ |❌ |**N/A**|**N/A**|**N/A** |**N/A** |
|
|Resize with cursor |✔️ |❌ |✔️ |✔️ |**N/A**|**N/A**|**N/A** |**N/A** |
|
||||||
|
|
||||||
### Pending API Reworks
|
### Pending API Reworks
|
||||||
Changes in the API that have been agreed upon but aren't implemented across all platforms.
|
Changes in the API that have been agreed upon but aren't implemented across all platforms.
|
||||||
|
|
|
@ -46,7 +46,8 @@ use windows_sys::Win32::{
|
||||||
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
||||||
SetCursorPos, SetForegroundWindow, SetWindowDisplayAffinity, SetWindowPlacement,
|
SetCursorPos, SetForegroundWindow, SetWindowDisplayAffinity, SetWindowPlacement,
|
||||||
SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO,
|
SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO,
|
||||||
FLASHW_ALL, FLASHW_STOP, FLASHW_TIMERNOFG, FLASHW_TRAY, GWLP_HINSTANCE, HTCAPTION,
|
FLASHW_ALL, FLASHW_STOP, FLASHW_TIMERNOFG, FLASHW_TRAY, GWLP_HINSTANCE, HTBOTTOM,
|
||||||
|
HTBOTTOMLEFT, HTBOTTOMRIGHT, HTCAPTION, HTLEFT, HTRIGHT, HTTOP, HTTOPLEFT, HTTOPRIGHT,
|
||||||
NID_READY, PM_NOREMOVE, SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE,
|
NID_READY, PM_NOREMOVE, SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE,
|
||||||
SWP_NOZORDER, WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WM_NCLBUTTONDOWN, WNDCLASSEXW,
|
SWP_NOZORDER, WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WM_NCLBUTTONDOWN, WNDCLASSEXW,
|
||||||
},
|
},
|
||||||
|
@ -410,9 +411,7 @@ impl Window {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
unsafe fn handle_os_dragging(&self, wparam: WPARAM) {
|
||||||
pub fn drag_window(&self) -> Result<(), ExternalError> {
|
|
||||||
unsafe {
|
|
||||||
let points = {
|
let points = {
|
||||||
let mut pos = mem::zeroed();
|
let mut pos = mem::zeroed();
|
||||||
GetCursorPos(&mut pos);
|
GetCursorPos(&mut pos);
|
||||||
|
@ -429,17 +428,36 @@ impl Window {
|
||||||
PostMessageW(
|
PostMessageW(
|
||||||
self.hwnd(),
|
self.hwnd(),
|
||||||
WM_NCLBUTTONDOWN,
|
WM_NCLBUTTONDOWN,
|
||||||
HTCAPTION as WPARAM,
|
wparam,
|
||||||
&points as *const _ as LPARAM,
|
&points as *const _ as LPARAM,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn drag_window(&self) -> Result<(), ExternalError> {
|
||||||
|
unsafe {
|
||||||
|
self.handle_os_dragging(HTCAPTION as WPARAM);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn drag_resize_window(&self, _direction: ResizeDirection) -> Result<(), ExternalError> {
|
pub fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), ExternalError> {
|
||||||
Err(ExternalError::NotSupported(NotSupportedError::new()))
|
unsafe {
|
||||||
|
self.handle_os_dragging(match direction {
|
||||||
|
ResizeDirection::East => HTRIGHT,
|
||||||
|
ResizeDirection::North => HTTOP,
|
||||||
|
ResizeDirection::NorthEast => HTTOPRIGHT,
|
||||||
|
ResizeDirection::NorthWest => HTTOPLEFT,
|
||||||
|
ResizeDirection::South => HTBOTTOM,
|
||||||
|
ResizeDirection::SouthEast => HTBOTTOMRIGHT,
|
||||||
|
ResizeDirection::SouthWest => HTBOTTOMLEFT,
|
||||||
|
ResizeDirection::West => HTLEFT,
|
||||||
|
} as WPARAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1299,7 +1299,8 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// Only X11 is supported at this time.
|
/// - **macOS:** Always returns an [`ExternalError::NotSupported`]
|
||||||
|
/// - **iOS / Android / Web / Orbital:** Always returns an [`ExternalError::NotSupported`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), ExternalError> {
|
pub fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), ExternalError> {
|
||||||
self.window.drag_resize_window(direction)
|
self.window.drag_resize_window(direction)
|
||||||
|
|
Loading…
Reference in a new issue