Warp the pointer to window center and remember where we put it so the motion handler can compute deltas relative to the warp target.
()
| 303 | /// Warp the pointer to window center and remember where we put it so |
| 304 | /// the motion handler can compute deltas relative to the warp target. |
| 305 | pub fn warp_to_center() { |
| 306 | unsafe { |
| 307 | if DISPLAY.is_null() || X11_WINDOW == 0 { return; } |
| 308 | let mut attrs: x11::xlib::XWindowAttributes = std::mem::zeroed(); |
| 309 | x11::xlib::XGetWindowAttributes(DISPLAY, X11_WINDOW, &mut attrs); |
| 310 | let cx = attrs.width / 2; |
| 311 | let cy = attrs.height / 2; |
| 312 | x11::xlib::XWarpPointer(DISPLAY, 0, X11_WINDOW, 0, 0, 0, 0, cx, cy); |
| 313 | x11::xlib::XFlush(DISPLAY); |
| 314 | WARP_CENTER_X = cx; |
| 315 | WARP_CENTER_Y = cy; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | pub fn enter_relative_mode() { |
| 320 | unsafe { |
no outgoing calls
no test coverage detected