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:
parent
95581ab92f
commit
d35ee0d580
3 changed files with 43 additions and 4 deletions
|
|
@ -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() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue