JFLib

plat/win_plock.rs (Windows)#

Source: lib/plat/win_plock.rs

win_plock -- (G7a) the pointer lock on Windows (the shared part: plock.rs)

  win_plock_set(w, on) -> PointerLock    lock the pointer to window w / let it go
  (window procedure, win_api.rs)
    input(w, lparam)        WM_INPUT of the mouse: raw motion -> plock_motion
    focus_in(w)             WM_SETFOCUS: a request that waited (Pending) takes effect
    release(w)              WM_KILLFOCUS, minimized, WM_DESTROY, Esc: the lock goes
    follow(w)               WM_MOVE / WM_SIZE: the clip follows the window
    locked(w) -> bool       WM_SETCURSOR (no cursor), WM_NCHITTEST (all client: a hidden
                            pointer never drags the title bar), win_set_cursor (kept for later)

Locked: the mouse's Raw Input (usage page 1, usage 2) goes to the window (WM_INPUT, only while
it is in the foreground: no RIDEV_INPUTSINK), the cursor is clipped to one pixel in the middle
of the client area (ClipCursor; again after every move and size) and hidden (WM_SETCURSOR sets
none).  The legacy mouse messages stay (no RIDEV_NOLEGACY): buttons and the wheel come as
before.  Relative devices give counts (lLastX / lLastY); absolute ones (MOUSE_MOVE_ABSOLUTE: a
remote desktop, a tablet, a virtual machine's pointer) positions 0..65535 of the primary
monitor or the whole desktop (MOUSE_VIRTUAL_DESKTOP), whose differences are the motion in
pixels.  The release unregisters the device (RIDEV_REMOVE), lifts the clip and puts the
cursor back where it was before the lock.
  • fn win_plock_set(w: i32, on: bool) -> PointerLock (plock.rs) lock the pointer to window w (on) or let it go -> the state now

Source: docs/API.md in the JFLib repository.