mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 15:13:13 -04:00
Fix hovering the mouse over the active window creating an endless stream of CursorMoved events (#1170)
* Fix hovering the mouse over the active window creating an endless stream of CursorMoved events * Format
This commit is contained in:
@@ -141,6 +141,16 @@ pub fn set_cursor_hidden(hidden: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_cursor_clip() -> Result<RECT, io::Error> {
|
||||
unsafe {
|
||||
let mut rect: RECT = mem::zeroed();
|
||||
win_to_err(|| winuser::GetClipCursor(&mut rect)).map(|_| rect)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the cursor's clip rect.
|
||||
///
|
||||
/// Note that calling this will automatically dispatch a `WM_MOUSEMOVE` event.
|
||||
pub fn set_cursor_clip(rect: Option<RECT>) -> Result<(), io::Error> {
|
||||
unsafe {
|
||||
let rect_ptr = rect
|
||||
@@ -151,6 +161,19 @@ pub fn set_cursor_clip(rect: Option<RECT>) -> Result<(), io::Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_desktop_rect() -> RECT {
|
||||
unsafe {
|
||||
let left = winuser::GetSystemMetrics(winuser::SM_XVIRTUALSCREEN);
|
||||
let top = winuser::GetSystemMetrics(winuser::SM_YVIRTUALSCREEN);
|
||||
RECT {
|
||||
left,
|
||||
top,
|
||||
right: left + winuser::GetSystemMetrics(winuser::SM_CXVIRTUALSCREEN),
|
||||
bottom: top + winuser::GetSystemMetrics(winuser::SM_CYVIRTUALSCREEN),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_focused(window: HWND) -> bool {
|
||||
window == unsafe { winuser::GetActiveWindow() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user