Hello Guest

[BUG] Mouse.setGrabbed(true) fails to actually grab the mouse 50% of the time

  • 3 Replies
  • 9512 Views
*

Offline princec

  • *****
  • 1933
    • Puppygames
As per the title. OS: Vista64, LWJGL 2.8.1 (and all previous versions for I don't know how long) for what it's worth. Happens whether using native LWJGL display or AWT Frame/Canvas/setParent jobbie.
Calling setGrabbed(true) again works - it'd be nice to just call it every frame because it eventually just works - but unfortunately this resets the mouse coordinates every time so no mouse movement is possible.

I'm not sure what the best fix would be - probably making sure that implementation.grabMouse actually guarantees to work 100% of the time - but failing that, allowing setGrabbed(true) to be called repeatedly without screwing the mouse would work too.

Cas :)

*

Offline Matzon

  • *****
  • 2242
org.lwjgl.test.input.MouseTest (space to grab/ungrab) works 100% of the time for me? - windows 7, 32bit

*

Offline princec

  • *****
  • 1933
    • Puppygames
It's never worked for me, on any incarnation of windows, for time immemorial. FWIW I've worked around the bug for now by simply calling setGrabbed(true) once a frame for 4 frames just to be sure - so far it hasn't let me down.

I suspect due to the difficult-to-reproduce nature of this bug it is a race condition of some sort.

Cas :)

*

Offline princec

  • *****
  • 1933
    • Puppygames
The workaround is still not 100% reliable. I do notice however that certain applications (eclipse cough cough) appear to cause this problem far more often than anything else. I now actually suspect that it's something to do with window focus.

Cas :)