Posted July 18, 2025 by YellowAfterlife
A few people asked about this over years and the Linux API is kind of similar, so there’s this.
XGrabPointer
) can only lock the mouse to the window (not a specific screen region), so display_mouse_lock
’s arguments will be ignored on Linux.display_mouse_unlock
works as usual.display_mouse_lock_auto()
function to auto-lock to window region for consistency between Windows/Linux.display_mouse_bounds
will return undefined
on Linux.Anyway, the following will work both on Windows and Linux:
if (window_has_focus()) {
display_mouse_lock_auto();
} else {
display_mouse_unlock();
}
As far as I can tell, CGAssociateMouseAndMouseCursorPosition
is the closest approximation of mouse locking on Mac OS, which is what window_mouse_set_locked
uses. There’s no benefit to me re-implementing it in an extension.