From: <ka...@us...> - 2010-02-14 17:06:22
|
Revision: 3273 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3273&view=rev Author: kappa1 Date: 2010-02-14 17:06:15 +0000 (Sun, 14 Feb 2010) Log Message: ----------- Complete overhaul of the linux focus system when using Display.setParent(). This should fix the input problems with applets (on linux) due to Display not being able to gain focus. Also now works perfectly in all browsers, previously input focus was not restored to other browser components when requested (like firefox's address bar). Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-02-10 11:22:16 UTC (rev 3272) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-02-14 17:06:15 UTC (rev 3273) @@ -127,27 +127,11 @@ private Canvas parent; private long parent_window; private boolean xembedded; - private boolean parent_focused; - private boolean parent_focus_changed; + private boolean parent_focus; private LinuxKeyboard keyboard; private LinuxMouse mouse; - private final FocusListener focus_listener = new FocusListener() { - public void focusGained(FocusEvent e) { - synchronized (GlobalLock.lock) { - parent_focused = true; - parent_focus_changed = true; - } - } - public void focusLost(FocusEvent e) { - synchronized (GlobalLock.lock) { - parent_focused = false; - parent_focus_changed = true; - } - } - }; - private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { lockAWT(); try { @@ -439,11 +423,6 @@ grab = false; minimized = false; dirty = true; - if (parent != null) { - parent.addFocusListener(focus_listener); - parent_focused = parent.isFocusOwner(); - parent_focus_changed = true; - } } finally { peer_info.unlock(); } @@ -494,8 +473,6 @@ public void destroyWindow() { lockAWT(); try { - if (parent != null) - parent.removeFocusListener(focus_listener); try { setNativeCursor(null); } catch (LWJGLException e) { @@ -853,17 +830,21 @@ } private void checkInput() { - if (parent == null || !parent_focus_changed) - return; + if (parent == null) return; - if (!focused && parent_focused) { - if (xembedded) { - // disable parent from taking focus back from Display when it is clicked - parent.setFocusable(false); + if (parent_focus != parent.hasFocus()) { + parent_focus = parent.hasFocus(); + + if (parent_focus) { + setInputFocusUnsafe(current_window); } - setInputFocusUnsafe(getWindow()); - parent_focus_changed = false; + else { + setInputFocusUnsafe(0); + } } + else if (parent_focus && !focused) { + setInputFocusUnsafe(current_window); + } } private void setFocused(boolean got_focus, int focus_detail) { @@ -874,19 +855,8 @@ if (focused) { acquireInput(); } - - if (parent != null && xembedded && focused != parent.hasFocus()) { - return; - } - - if (!focused) { + else { releaseInput(); - - if (parent != null && xembedded) { - setInputFocusUnsafe(0); - // re-enable parent focus to detect click on window - parent.setFocusable(true); - } } } static native long nGetInputFocus(long display); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |