LWJGL
May 21, 2012, 01:12:29 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1] 2
  Print  
Author Topic: Problem with Grabbed Mouse  (Read 9218 times)
Jimmy
Newbie
*
Posts: 15


« on: July 26, 2007, 23:47:47 »

In Windows, using lwjgl in windowed mode, with the mouse grabbed property set, if you click a windows title bar, the window goes flying downward off the screen.  This is presumably because lwjgl is trying to grab the mouse back down inside the window, but ends up pulling the window downward.

Is there a way to prevent this behavior?  If not, a possible solution would just be to check that no mouse buttons are pressed before it pulls the mouse back to prevent the slingshot effect.
Logged
princec
Nerdus Imperius
*****
Posts: 1781



WWW
« Reply #1 on: July 27, 2007, 07:42:26 »

The mouse is not supposed to be visible when it's grabbed though???

Cas Smiley
Logged

Jimmy
Newbie
*
Posts: 15


« Reply #2 on: July 27, 2007, 09:09:08 »

Indeed, you have to alt-tab out of the application for it to become visible.  Then when you click the title bar to refocus on the app, is when this problem occurs.
Logged
Jimmy
Newbie
*
Posts: 15


« Reply #3 on: July 28, 2007, 00:23:00 »

This is a very serious problem.  I have found an easy way for people to reproduce it so that you can see why.

Open the lwjgl input MouseTest demo.

Next, press the Windows key, or Alt-Tab.  You will regain control of your mouse and see your cursor once the application has lost focus.

Now, click the title bar of the application.  If you click it fast enough, you may be able to save it before it goes all the way off the screen, but you won't be able to move it back.  If you try, and prepare to see it fly away to where you will not be able to get it back ever.

Note:  I doubt this will work on any operating system except for Windows.  I personally believe after messing with the source code that this is a problem inside the DirectInput implementation, but I am really stumbling around because I am so unfamiliar with the lwjgl internals.  A little bit of help from any lwjgl developer, or even a user with better knowledge of the lwjgl internals, would be greatly appreciated.

I'll keep investigating, but right now this is the single most serious bug in my game because the users run into it all the time, and it's very aggravating because they have to exit to recenter the window.


********* UPDATE **********

I have figured out why such a critical bug has been able to remain in lwjgl for so long.  On a Windows XP box (or lower I presume), the window only drops itself down about 10 pixels.  However, you will find that even on XP you cannot move the window back up, and if you click it enough times it will eventually go off the screen.  Still, this behavior is much less serious than on the newer Vista, where you will lose the application permanently by clicking the title bar even once.
Logged
elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #4 on: July 28, 2007, 14:24:09 »

This bug should now be fixed in HEAD.

 - elias
Logged

Jimmy
Newbie
*
Posts: 15


« Reply #5 on: July 28, 2007, 14:49:37 »

I can confirm that the new HEAD works perfectly correct now, even on Vista.  Great job guys!
Logged
princec
Nerdus Imperius
*****
Posts: 1781



WWW
« Reply #6 on: July 29, 2007, 07:25:21 »

New release out soon with keyboard & mouse glitches fixed...?

Cas Smiley
Logged

Matzon
Administrator
Demigod
*****
Posts: 2177



« Reply #7 on: July 29, 2007, 08:52:02 »

soon, still issues to fix before new release
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
renanse
Regular nerd
**
Posts: 99


« Reply #8 on: August 10, 2007, 14:42:14 »

Sort of related... Smiley

I've locally updated jME to use lwjgl 1.1.1 and I'm now seeing a few issues with the mouse.  When the mouse is grabbed and I am in windowed mode, if I alt tab out, the mouse still provides input to the window, even though it is not in focus.  By this, I mean that if I move my mouse across the screen and happen to pass over the lwjgl window, mouse events are generated.  It also hides my mouse cursor as I pass across the window.

Even odder, let's say I am running eclipse full screen and I launch a windowed lwjgl app.  It appears centered over the top of eclipse.  I then alt-tab back to eclipse and my mouse appears as expected in the middle of the window, but now it will only move within the boundaries of the GL window that is under the eclipse window.  FWIW, through some experimentation I have discovered I can "unstick" it if the edge of the gl window is showing on screen and I exit over that side.

Any ideas?
Logged
Jimmy
Newbie
*
Posts: 15


« Reply #9 on: August 12, 2007, 02:58:48 »

I can also confirm I've seen this exact same thing happen before many times in 1.1.1.

When this starts happening, I just keep hitting the windows key and alt tab and eventually it seems to release the focus, but definitely something worth checking into in the code.

Another possibly related problem is that sometimes when coming back into the window (after alt tabbing), the position of the cursor internally in the window will be off.  I've had users report (and it happens to me occasionally) that their crosshairs are off.  The solution is dragging the mouse into a corner of the application seems to realign it.
Logged
elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #10 on: August 12, 2007, 16:37:29 »

The cursor should now unstick when alt-tabbing out from an LWJGL window.

The cursor position problem is puzzling. Are you using Mouse.get(Event)X/Y() to fetch cursor positions?

 - elias
Logged

Jimmy
Newbie
*
Posts: 15


« Reply #11 on: August 12, 2007, 17:58:53 »

This is using Mouse.getX/Y to draw the cursors position, and then using the X/Y provided by the generated event for the actual clicking events.  I'm not sure which one is the inaccurate one, but they seem to not be in agreement on occasion
Logged
elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #12 on: August 13, 2007, 02:43:48 »

If you're getting the cursor position while having the cursor grabbed, should should stick to either getX/Y() or getEventX/Y(), but not both. It is generally difficult to guarantee that they always return the same value. If you're not grabbing the cursor, this is probably a bug and I'll need a series of steps to reproduce the bug (you could modify one of the input tests in LWJGL to provide a simple example).

 - elias
Logged

Jimmy
Newbie
*
Posts: 15


« Reply #13 on: August 13, 2007, 03:29:32 »

Understood, I am now getting all of my values from GetX/Y, even for handling mouse clicks.
Logged
renanse
Regular nerd
**
Posts: 99


« Reply #14 on: August 13, 2007, 15:13:34 »

Thanks elias...  jME 1.0rc is due out shortly and I'd like to use an official release of lwjgl...  Any idea when 1.1.2 could be out (so I could include this fix?)
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!