LWJGL
May 22, 2012, 04:52:37 *
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]
  Print  
Author Topic: [FIXED] Mouse.setGrabbed still doesn't work right. I'd pay for it to work right.  (Read 2874 times)
Notch
Newbie
*
Posts: 38


« on: February 02, 2010, 06:00:40 »

I frequently grab/ungrab the mouse in my game. It works great under the right circumstances, but it has a few major disadvantages.

For example, it doesn't work at all if the game is on a secondary monitor. The game just locks up until I release the mouse.
On linux, it sometimes causes the game to not receive any more keyboard events, ever. The actual mouse grabbing problem seems to have been fixed in 2.2.2, though.
Since the mouse is released on a keyboard event, not getting keyboard focus is a bit of a problem.

I switched back to using Robot and MousePointerInfo, but that doesn't play well since it's multithreaded and unpredictable (it sometimes leaks coordinates because it's not synchronized), and it's really slow on some systems.

I'd pay to get this fixed.
Logged
princec
Nerdus Imperius
*****
Posts: 1782



WWW
« Reply #1 on: February 02, 2010, 08:50:43 »

Hmm yes, I have just discovered too that the mouse and keyboard both completely stop working on the secondary monitor.

Cas Smiley
Logged

Matzon
Administrator
Demigod
*****
Posts: 2177



« Reply #2 on: February 02, 2010, 08:57:32 »

Hmm yes, I have just discovered too that the mouse and keyboard both completely stop working on the secondary monitor.

Cas Smiley

so this is a windows and linux issue - what about mac?
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
Notch
Newbie
*
Posts: 38


« Reply #3 on: February 02, 2010, 09:03:05 »

I haven't tried on mac, but I can do so tomorrow.

[edit:]
No, I can't. Oops. :-O
Logged
kappa
Administrator
Nerdus Imperius
*****
Posts: 961



« Reply #4 on: February 02, 2010, 11:53:07 »

From what i can tell this seems like two separate bugs rather then one, since internally they are done pretty differently. (talking about linux and windows only atm)

@Notch can you just clarify a bit:

1) Mouse grab total fails on windows when using second screen.
2) When using linux + second screen it works fine, just that sometimes you are unable to get keyboard focus back.

can i assume that is correct?
Logged
Notch
Newbie
*
Posts: 38


« Reply #5 on: February 02, 2010, 11:56:51 »

From what i can tell this seems like two separate bugs rather then one, since internally they are done pretty differently. (talking about linux and windows only atm)

@Notch can you just clarify a bit:

1) Mouse grab total fails on windows when using second screen.
2) When using linux + second screen it works fine, just that sometimes you are unable to get keyboard focus back.

can i assume that is correct?

1) It grabs the mouse, but nothing gets rendered until the mouse gets released. If the mouse is ungrabbed, the game runs fine on the secondary monitor.
2) I don't know if secondary monitors works on linux. I thought it didn't, but I don't know for sure. When it loses focus by "weird" ways such as task switching while the mouse is grabbed or, in this case, opening an AWT dialog window, it seems to fail to ever get KB focus back.
Logged
kappa
Administrator
Nerdus Imperius
*****
Posts: 961



« Reply #6 on: February 02, 2010, 12:06:56 »

1) It grabs the mouse, but nothing gets rendered until the mouse gets released. If the mouse is ungrabbed, the game runs fine on the secondary monitor.
2) I don't know if secondary monitors works on linux. I thought it didn't, but I don't know for sure. When it loses focus by "weird" ways such as task switching while the mouse is grabbed or, in this case, opening an AWT dialog window, it seems to fail to ever get KB focus back.

Ah excellent and most useful information. Unfortunately can't help you with the second screen monitor problem (since don't have two screens) but i was aware of the linux mouse issue, just couldn't reproduce it, seemed to just happen randomly. I'll try runs some tests (maybe on the weekend but hopefully will get time before that) and see if i can reproduce it using the grabbing thing, hopefully can then try find a fix and patch it.
Logged
kappa
Administrator
Nerdus Imperius
*****
Posts: 961



« Reply #7 on: February 06, 2010, 10:16:56 »

On linux, it sometimes causes the game to not receive any more keyboard events, ever. ...
Since the mouse is released on a keyboard event, not getting keyboard focus is a bit of a problem.

@Notch I investigated this today, think I have a rough idea what it might be but can't be sure, problem is I can't reproduce the bug, been trying to do various things to get the bug to show itself but only got it to trigger once (no idea how it happend). If I had a working version of the bug I could then add debug info to LWJGL source and fix it, would it be possible for you to create a small test case which reproduces this bug?

thx
Logged
Notch
Newbie
*
Posts: 38


« Reply #8 on: February 06, 2010, 13:14:48 »

I don't run linux myself, so I can't verify it.. but here's some pseudocode that shows what my logic looks like:

Code:
boolean grabbed;
Mouse.setGrabbed(grabbed = true);

while (true) {
    if (Keyboard.isDown(Keyboard.KEY_ESCAPE) && grabbed) Mouse.setGrabbed(grabbed = false);
    if (!Display.isActive() && grabbed) Mouse.setGrabbed(grabbed = false);
    if (isWindowClicked() && !grabbed) Mouse.setGrabbed(grabbed = true);
    Display.update();
}

From what I can piece together (and this might be incorrect), it works when pressing escape, but when you task switch directly so it loses focus, it doesn't work. (ie the Keyboard class stops working, like it doesn't have keyboard focus)
Logged
princec
Nerdus Imperius
*****
Posts: 1782



WWW
« Reply #9 on: February 08, 2010, 04:28:59 »

Any ideas about the Windows problem with 2nd monitors? (No mouse / keyboard input at all when window is dragged to other monitor)

Cas Smiley
Logged

kappa
Administrator
Nerdus Imperius
*****
Posts: 961



« Reply #10 on: February 14, 2010, 09:11:08 »

@notch the linux input problems should now be fixed in lwjgl nightly build >#393.

Just the windows input/grab problem left now.
Logged
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #11 on: March 31, 2010, 17:14:58 »

Mouse grabbing on secondary monitor has been fixed on nightly. You owe me a beer Markus. Grin
Logged

Pages: [1]
  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!