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.
()
| 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 { |