[FIXED] setGrabbed(false) behavior

Started by renanse, March 09, 2010, 02:13:07

Previous topic - Next topic

renanse


Hey folks.  On different platforms, it appears that Mouse.setGrabbed does not work the same way...  On linux/osx, if I grab and then "ungrab" the mouse, the cursor does not change position, however if I do the same on windows, the cursor jumps to the middle of the screen.  Is there a way to get the windows version to behave in the same way (aside from using some platform based trick like Robot, etc.)  Is this something that is just not workable on windows and thus the platform difference?

Matzon

a quick glance through the code seems to reveal that there is definately centering going on, on windows - but also some cursor positioning on linux (didn't check mac).
technically, I think that ungrabbing the mouse should position the mouse at some defined location - but of course all platforms should do it the same place.
I dont have a fix for this right now, since I can't test all platforms.

thecookie

I've run into this issue. After ungrabbing the mouse I want to position the cursor at the position the cursor was grabbed at. You can get this behavior through saving the cursor position at grab, and reset it at not_grabbed. But as you have to set the cursor position after setting not_grabbed (due to the centering happening at not_grabbed), the cursor can sometime flicker a bit at center and then to the "correct" position.

Any solution to get rid of the flickering would be awesome.

thecookie


kappa

there was some discussion regarding this on the #lwjgl irc channel on Sunday. We sort of came to the conclusion that the default behaviour should simply be that the mouse is centered on all platforms when the mouse is ungrabbed (as it is on windows atm). Not sure if any progress was made on actually implementing it yet.

thecookie

Thanks for the update!

Sorry to hear about the conclusion. I need to implement this in the application level then. Thanks :)

Edit:

My issue with grab was that I want the cursor to be where it was when it was grabbed when you ungrab. If it is centered on ungrab, I have to move it to the old cursor postion after that. I get a flicker at center at each ungrab. Just to clarify why I would need to implement this in the application level. :)

kappa

Quote from: thecookie on March 17, 2010, 10:18:56
Thanks for the update!

Sorry to hear about the conclusion. I need to implement this in the application level then. Thanks :)

Edit:

My issue with grab was that I want the cursor to be where it was when it was grabbed when you ungrab. If it is centered on ungrab, I have to move it to the old cursor postion after that. I get a flicker at center at each ungrab. Just to clarify why I would need to implement this in the application level. :)

Well the only reason we decided to go for centering mouse on ungrab method was because it seems like the easiest method to implement. The method you mention (restoring the mouse where it was grabbed from) while not difficult to implement, it has a bit more to it for example when grabbing mouse outside the LWJGL Display do we restore it to the same place outside the Display?

As its still not implemented yet the issue is still up for discussion, if you have some good points on why we should position the mouse where we grab from on release or why centering the mouse on release is not good feel free to point them out.

Whichever method the majority of the LWJGL community prefers will likely get implemented.

thecookie

Can't it be settable some how? The behavior you would like. At least between centering and keep the cursor at same spot.

Is someone using grabbing outside of the display?

kappa

Quote from: thecookie on March 17, 2010, 20:13:04
Is someone using grabbing outside of the display?

yes anyone who uses lwjgl in windowed mode and has keyboard input to grab the mouse.

thecookie

I see. I would say that resetting the cursor to the grab position for that would work too, wouldn't it?

I have the window in focus, cursor outside, press space to go into grabbed mode, move around the camera a bit. Release space, and the cursor is back at where it was before. At least for me that's the most natural thing.

Fool Running

What about having the option on ungrabbed to set the location of the mouse to a specific point? This would, of course, need a new method, but it would handle both cases (center the mouse in normal circumstances, but have the option to ungrab at a specific location). This would allow for fancy mousework like grabbing the mouse to show a software cursor, then ungrabbing to show the hardware mouse at the same location (don't know why you would ever do that, though :P)
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

kappa

this issue is now fixed and added to svn, it should be part of LWJGL 2.4. The mouse will now be at the same location as it was grabbed from when it is ungrabbed. Consistent on all platforms.

kappa

Further update on this, you can now set the location of where you want the mouse to be when its ungrabbed using Mouse.setCursorLocation(x,y) while mouse is grabbed. Default behaviour is still that the mouse will ungrab at the location it was grabbed. We now have the best of both worlds, users can have the mouse where ever he wants on ungrab without the need for any new api :)