Keyboard doesn't release when display loses focus

To preface with my specs: Running on RedHat 9 using lwjgl 0.5

So, I noticed recently that if the Display is initialized in windowed mode and then the Keyboard is created, all keystrokes are consumed by the application, even if the window loses focus. Most notably, this makes debugging with NetBeans difficult, as I can’t hit the keystrokes to step through the code!

I think the obvious fix for this would be to simply a method to the Display object such as: boolean hasFocus(). Then within my app I could test this during the main loop, and release the Keyboard when it is false and reclaim the keyboard when it’s true.

What do you mean - losing focus? The only “supported” way of releasing focus is by pressing alt+tab while the input is grabbed

Well, in this case I lost focus because my debugger insisted on grabbing it when it reached a break point in the code. Some other apps might do something similar as well, like an IM client. Or, what if I simply clicked from one window to the other (again, this isn’t fullscreen mode that I’m talking about).

Currently I do see the support for the case where the window is minimized (in Display.isMinimized()), but not for the case when other windows are simply brought to the foreground, leaving the lwjgl window still on screen, but not having focus.

The 0.6 pre is out, could you test again? (including the no glx-case of yours)

  • elias

In fact, I just fixed an issue with input focus on linux so could you test with these libs instead:

http://odense.kollegienet.dk/~naur/lwjgl-rel06-take2-rh8.zip

and Matzon, you can grab it too, along with

http://odense.kollegienet.dk/~naur/lwjgl-rel06-take2-suse81.zip

for the release.

  • elias

I’ve played with this a bit more, and the problem seems to be actually specific to debugging using NetBeans IDE. I can load up an app that uses lwjgl for keyboard input and a text editor, and switch between them and have them react just fine. It’s only when debugging in NetBeans that all hell seems to break loose. I’m getting behavior that ranges from the debugger simply ignoring key presses to the mouse completely bugging out and flashing all over the screen making the computer useless until I kill both processes (the debugger and the app being debugged).

Anyway, I will try to nail down exactly what causes the problem. But for now, it seems such an isolated issue it shouldn’t be too hard to work around. I could just use a lot of System.out.printlns instead of the interactive debugger.

What about your segfault when GLX is disabled, did the new libs fix it?

  • elias

Aw, you’re confusing me now jumping topics from one forum to the other. I won’t get a chance to test the GLX issue again until I’m at work on Monday, as it’s that machine that I’ve been finding the error on. When I get to test it, I will post my results on the fourm titled “Running and Distributing in Linux”.

If I can narrow my issue with debugging in NetBeans, I will post the info regarding that here.