MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / warp_to_center

Function warp_to_center

native/linux/src/lib.rs:305–317  ·  view source on GitHub ↗

Warp the pointer to window center and remember where we put it so the motion handler can compute deltas relative to the warp target.

()

Source from the content-addressed store, hash-verified

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 {

Callers 2

enter_relative_modeFunction · 0.85
poll_eventsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected