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

Function ensure_hidden_cursor

native/linux/src/lib.rs:273–282  ·  view source on GitHub ↗

Build (once) a 1x1 fully-transparent cursor — the standard X11 trick for "hide the cursor". Subsequent calls reuse the cached cursor since X11 leaks Cursor handles otherwise.

()

Source from the content-addressed store, hash-verified

271 /// trick for "hide the cursor". Subsequent calls reuse the cached
272 /// cursor since X11 leaks Cursor handles otherwise.
273 unsafe fn ensure_hidden_cursor() -> x11::xlib::Cursor {
274 if HIDDEN_CURSOR != 0 { return HIDDEN_CURSOR; }
275 let pixmap = x11::xlib::XCreatePixmap(DISPLAY, X11_WINDOW, 1, 1, 1);
276 let mut color: x11::xlib::XColor = std::mem::zeroed();
277 let cursor = x11::xlib::XCreatePixmapCursor(
278 DISPLAY, pixmap, pixmap, &mut color, &mut color, 0, 0);
279 x11::xlib::XFreePixmap(DISPLAY, pixmap);
280 HIDDEN_CURSOR = cursor;
281 cursor
282 }
283
284 pub fn hide_cursor() {
285 unsafe {

Callers 1

hide_cursorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected