From: <eli...@us...> - 2008-08-12 17:05:32
|
Revision: 3112 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3112&view=rev Author: elias_naur Date: 2008-08-12 17:05:26 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Linux: Avoid unneccessary mode switching in LinuxDisplay.resetDisplayMode (patch by buggs) 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 2008-08-12 12:53:03 UTC (rev 3111) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-08-12 17:05:26 UTC (rev 3112) @@ -548,7 +548,8 @@ public void resetDisplayMode() { lockAWT(); try { - switchDisplayMode(saved_mode); + if(current_mode != saved_mode) + switchDisplayMode(saved_mode); if (isXF86VidModeSupported()) doSetGamma(saved_gamma); } catch (LWJGLException e) { @@ -645,7 +646,7 @@ current_mode = saved_mode; saved_gamma = getCurrentGammaRamp(); current_gamma = saved_gamma; - return saved_mode; + return current_mode; } finally { unlockAWT(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-03-09 21:53:15
|
Revision: 3175 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3175&view=rev Author: kappa1 Date: 2009-03-09 21:53:11 +0000 (Mon, 09 Mar 2009) Log Message: ----------- fixed focus loop when using Display.setParent() on linux, this caused input keys to be missed as the focus shifted from parent to Display and back again. 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 2009-03-09 21:07:38 UTC (rev 3174) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2009-03-09 21:53:11 UTC (rev 3175) @@ -860,7 +860,7 @@ return; if (focused) { if (xembedded && !parent_focused && parent_focus_window_valid) { - if (nGetInputFocus(getDisplay()) == current_window) { + if (nGetInputFocus(getDisplay()) != current_window) { setInputFocusUnsafe(parent_focus_window); parent_focus_changed = false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-03-11 21:05:32
|
Revision: 3177 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3177&view=rev Author: kappa1 Date: 2009-03-11 21:05:05 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Improved focus handling for Display.setParent() on linux. Focus is now released from Display when X fires a focus change event. 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 2009-03-10 15:34:38 UTC (rev 3176) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2009-03-11 21:05:05 UTC (rev 3177) @@ -125,8 +125,6 @@ private long current_cursor; private long blank_cursor; private Canvas parent; - private long parent_focus_window; - private boolean parent_focus_window_valid; private long parent_window; private boolean xembedded; private boolean parent_focused; @@ -432,7 +430,6 @@ mapRaised(getDisplay(), current_window); xembedded = parent != null && isAncestorXEmbedded(parent_window); blank_cursor = createBlankCursor(); - parent_focus_window_valid = false; current_cursor = None; focused = false; input_released = false; @@ -858,22 +855,14 @@ private void checkInput() { if (parent == null || !parent_focus_changed) return; - if (focused) { - if (xembedded && !parent_focused && parent_focus_window_valid) { - if (nGetInputFocus(getDisplay()) != current_window) { - setInputFocusUnsafe(parent_focus_window); - parent_focus_changed = false; - } + + if (!focused && parent_focused) { + if (xembedded) { + // disable parent from taking focus back from Display when it is clicked + parent.setFocusable(false); } - } else { - if (parent_focused) { - if (xembedded) { - parent_focus_window = nGetInputFocus(getDisplay()); - parent_focus_window_valid = true; - } - setInputFocusUnsafe(getWindow()); - parent_focus_changed = false; - } + setInputFocusUnsafe(getWindow()); + parent_focus_changed = false; } } @@ -881,10 +870,21 @@ if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot) return; focused = got_focus; + + if (parent != null && xembedded && focused != parent.hasFocus()) { + return; + } + if (focused) { acquireInput(); } 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. |
From: <ka...@us...> - 2009-11-24 20:13:19
|
Revision: 3254 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3254&view=rev Author: kappa1 Date: 2009-11-24 20:13:12 +0000 (Tue, 24 Nov 2009) Log Message: ----------- Mouse Grab Bug on Linux Fixed when LWJGL is run as an applet. 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 2009-11-20 23:28:37 UTC (rev 3253) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2009-11-24 20:13:12 UTC (rev 3254) @@ -871,13 +871,15 @@ return; focused = got_focus; + if (focused) { + acquireInput(); + } + if (parent != null && xembedded && focused != parent.hasFocus()) { return; } - if (focused) { - acquireInput(); - } else { + if (!focused) { releaseInput(); if (parent != null && xembedded) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <ka...@us...> - 2010-04-10 18:07:57
|
Revision: 3317 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3317&view=rev Author: kappa1 Date: 2010-04-10 18:07:50 +0000 (Sat, 10 Apr 2010) Log Message: ----------- fix infinite focus loop when using Display.setParent() + JWS + Linux. 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-04-09 23:57:40 UTC (rev 3316) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-04-10 18:07:50 UTC (rev 3317) @@ -846,7 +846,7 @@ if (parent_focus) { setInputFocusUnsafe(current_window); } - else { + else if (xembedded) { setInputFocusUnsafe(0); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2010-07-09 18:44:37
|
Revision: 3368 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3368&view=rev Author: spasi Date: 2010-07-09 18:44:31 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Compiz LFS improvements. 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-07-08 21:12:20 UTC (rev 3367) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-07-09 18:44:31 UTC (rev 3368) @@ -53,6 +53,9 @@ import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; final class LinuxDisplay implements DisplayImplementation { /* X11 constants */ @@ -455,7 +458,7 @@ private static native void mapRaised(long display, long window); private static native void reparentWindow(long display, long window, long parent, int x, int y); - private boolean isAncestorXEmbedded(long window) throws LWJGLException { + private static boolean isAncestorXEmbedded(long window) throws LWJGLException { long xembed_atom = internAtom("_XEMBED_INFO", true); if (xembed_atom != None) { long w = window; @@ -1249,16 +1252,19 @@ } /** - * Helper class for managing Compiz's workarounds. + * Helper class for managing Compiz's workarounds. We need this to enable Legacy + * Fullscreen Support in Compiz, else we'll have trouble with fullscreen windows + * when Compiz effects are enabled. + * + * Implementation Note: This code is probably too much for an inner class, but + * keeping it here until we're sure we cannot find a better solution. */ private static final class Compiz { - private static final String LEGACY_FULLSCREEN_SUPPORT = "/org/freedesktop/compiz/workarounds/allscreens/legacy_fullscreen"; + private static boolean applyFix; - private static boolean dbusAvailable; + private static Provider provider; - private static boolean legacyFullscreenSupport; - private Compiz() { } @@ -1269,24 +1275,110 @@ AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - legacyFullscreenSupport = getBoolean(LEGACY_FULLSCREEN_SUPPORT); - dbusAvailable = true; + // Check if Compiz is active + if ( !isProcessActive("compiz") ) + return null; + + provider = null; + + String providerName = null; + + // Check if Dbus is available + if ( isProcessActive("dbus-daemon") ) { + providerName = "Dbus"; + provider = new Provider() { + + private static final String KEY = "/org/freedesktop/compiz/workarounds/allscreens/legacy_fullscreen"; + + public boolean hasLegacyFullscreenSupport() throws LWJGLException { + final List output = Compiz.run(new String[] { + "dbus-send", "--print-reply", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.get" + }); + + if ( output == null || output.size() < 2 ) + throw new LWJGLException("Invalid Dbus reply."); + + String line = (String)output.get(0); + + if ( !line.startsWith("method return") ) + throw new LWJGLException("Invalid Dbus reply."); + + line = ((String)output.get(1)).trim(); // value + if ( !line.startsWith("boolean") || line.length() < 12) + throw new LWJGLException("Invalid Dbus reply."); + + return "true".equalsIgnoreCase(line.substring("boolean".length() + 1)); + } + + public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException { + if ( Compiz.run(new String[] { + "dbus-send", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.set", "boolean:" + Boolean.toString(state) + }) == null ) + throw new LWJGLException("Failed to apply Compiz LFS workaround."); + } + }; + } else { + try { + // Check if Gconf is available + Runtime.getRuntime().exec("gconftool"); + + providerName = "gconftool"; + provider = new Provider() { + + private static final String KEY = "/apps/compiz/plugins/workarounds/allscreens/options/legacy_fullscreen"; + + public boolean hasLegacyFullscreenSupport() throws LWJGLException { + final List output = Compiz.run(new String[] { + "gconftool", "-g", KEY + }); + + if ( output == null || output.size() == 0 ) + throw new LWJGLException("Invalid gconftool reply."); + + return Boolean.parseBoolean(((String)output.get(0)).trim()); + } + + public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException { + if ( Compiz.run(new String[] { + "gconftool", "-s", KEY, "-s", Boolean.toString(state), "-t", "bool" + }) == null ) + throw new LWJGLException("Failed to apply Compiz LFS workaround."); + + try { + // gconftool will not apply the workaround immediately, sleep a bit + // to make sure it will be ok when we create the window. + Thread.sleep(200); // 100 is too low, 150 works, set to 200 to be safe. + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }; + } catch (IOException e) { + // Ignore + } + } + + if ( provider != null && !provider.hasLegacyFullscreenSupport() ) { // No need to do anything is LFS is already enabled. + applyFix = true; + LWJGLUtil.log("Using " + providerName + " to apply Compiz LFS workaround."); + } } catch (LWJGLException e) { - LWJGLUtil.log("Compiz Dbus communication failed. Reason: " + e.getMessage()); + // Ignore + } finally { + return null; } - return null; } }); } static void setLegacyFullscreenSupport(final boolean enabled) { - if ( !dbusAvailable || legacyFullscreenSupport ) + if ( !applyFix ) return; AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - setBoolean(LEGACY_FULLSCREEN_SUPPORT, enabled); + provider.setLegacyFullscreenSupport(enabled); } catch (LWJGLException e) { LWJGLUtil.log("Failed to change Compiz Legacy Fullscreen Support. Reason: " + e.getMessage()); } @@ -1295,48 +1387,54 @@ }); } - private static boolean getBoolean(final String option) throws LWJGLException { + private static List run(final String[] command) throws LWJGLException { + final List output = new ArrayList(); + try { - final Process p = Runtime.getRuntime().exec(new String[] { - "dbus-send", "--print-reply", "--type=method_call", "--dest=org.freedesktop.compiz", option, "org.freedesktop.compiz.get" - }); - final int exitValue = p.waitFor(); - if ( exitValue != 0 ) - throw new LWJGLException("Dbus error."); + final Process p = Runtime.getRuntime().exec(command); + try { + final int exitValue = p.waitFor(); + if ( exitValue != 0 ) + return null; + } catch (InterruptedException e) { + throw new LWJGLException("Process interrupted.", e); + } final BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); - String reply = br.readLine(); // header - if ( !reply.startsWith("method return") ) - throw new LWJGLException("Invalid Dbus reply."); + String line; + while ( (line = br.readLine()) != null ) + output.add(line); - reply = br.readLine().trim(); // value - if ( !reply.startsWith("boolean") ) - throw new LWJGLException("Invalid Dbus reply."); + br.close(); + } catch (final IOException e) { + throw new LWJGLException("Process failed.", e); + } - return "true".equalsIgnoreCase(reply.substring("boolean".length() + 1)); - } catch (IOException e) { - throw new LWJGLException("Dbus command failed.", e); - } catch (InterruptedException e) { - throw new LWJGLException("Dbus command failed.", e); - } + return output; } - private static void setBoolean(final String option, final boolean value) throws LWJGLException { - try { - final Process p = Runtime.getRuntime().exec(new String[] { - "dbus-send", "--type=method_call", "--dest=org.freedesktop.compiz", option, "org.freedesktop.compiz.set", "boolean:" + Boolean.toString(value) - }); - final int exitValue = p.waitFor(); - if ( exitValue != 0 ) - throw new LWJGLException("Dbus error."); - } catch (IOException e) { - throw new LWJGLException("Dbus command failed.", e); - } catch (InterruptedException e) { - throw new LWJGLException("Dbus command failed.", e); + private static boolean isProcessActive(final String processName) throws LWJGLException { + final List output = run(new String[] { "ps", "-C", processName }); + if ( output == null ) + return false; + + for ( Iterator iter = output.iterator(); iter.hasNext(); ) { + final String line = (String)iter.next(); + if ( line.contains(processName) ); + return true; } + + return false; } + private interface Provider { + + boolean hasLegacyFullscreenSupport() throws LWJGLException; + + void setLegacyFullscreenSupport(boolean state) throws LWJGLException; + + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2010-07-09 21:46:33
|
Revision: 3370 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3370&view=rev Author: spasi Date: 2010-07-09 21:46:27 +0000 (Fri, 09 Jul 2010) Log Message: ----------- 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-07-09 19:37:14 UTC (rev 3369) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-07-09 21:46:27 UTC (rev 3370) @@ -1344,12 +1344,14 @@ }) == null ) throw new LWJGLException("Failed to apply Compiz LFS workaround."); - try { - // gconftool will not apply the workaround immediately, sleep a bit - // to make sure it will be ok when we create the window. - Thread.sleep(200); // 100 is too low, 150 works, set to 200 to be safe. - } catch (InterruptedException e) { - e.printStackTrace(); + if ( state ) { + try { + // gconftool will not apply the workaround immediately, sleep a bit + // to make sure it will be ok when we create the window. + Thread.sleep(200); // 100 is too low, 150 works, set to 200 to be safe. + } catch (InterruptedException e) { + e.printStackTrace(); + } } } }; @@ -1358,7 +1360,7 @@ } } - if ( provider != null && !provider.hasLegacyFullscreenSupport() ) { // No need to do anything is LFS is already enabled. + if ( provider != null && !provider.hasLegacyFullscreenSupport() ) { // No need to do anything if LFS is already enabled. applyFix = true; LWJGLUtil.log("Using " + providerName + " to apply Compiz LFS workaround."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-07-11 20:25:30
|
Revision: 3376 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3376&view=rev Author: kappa1 Date: 2010-07-11 20:25:24 +0000 (Sun, 11 Jul 2010) Log Message: ----------- fix: Keyboard focus handling broken when using Display.setParent() applets on Ubunutu (strangly worked on OpenSuse), hopefully should be fixed now. 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-07-11 15:26:33 UTC (rev 3375) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-07-11 20:25:24 UTC (rev 3376) @@ -880,12 +880,12 @@ setInputFocusUnsafe(current_window); } else if (xembedded) { - setInputFocusUnsafe(0); + setInputFocusUnsafe(1); } } - else if (parent_focus && !focused) { - setInputFocusUnsafe(current_window); - } + //else if (parent_focus && !focused && !xembedded) { + // setInputFocusUnsafe(current_window); + //} } private void setFocused(boolean got_focus, int focus_detail) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-10-08 20:19:50
|
Revision: 3434 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3434&view=rev Author: kappa1 Date: 2010-10-08 20:19:44 +0000 (Fri, 08 Oct 2010) Log Message: ----------- fix for focus issues with Display.setParent on linux when using it as a non applet. Thx to MatthiasM for finding this and providing a small test case. 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-10-07 20:38:50 UTC (rev 3433) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-10-08 20:19:44 UTC (rev 3434) @@ -894,9 +894,11 @@ if (focused) { acquireInput(); + if (!xembedded) parent.setFocusable(false); } else { releaseInput(); + if (!xembedded) 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. |
From: <ka...@us...> - 2010-10-13 21:26:32
|
Revision: 3448 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3448&view=rev Author: kappa1 Date: 2010-10-13 21:26:25 +0000 (Wed, 13 Oct 2010) Log Message: ----------- fix null pointer exception when creating Display on linux. 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-10-13 21:16:56 UTC (rev 3447) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-10-13 21:26:25 UTC (rev 3448) @@ -894,11 +894,11 @@ if (focused) { acquireInput(); - if (!xembedded) parent.setFocusable(false); + if (parent != null && !xembedded) parent.setFocusable(false); } else { releaseInput(); - if (!xembedded) parent.setFocusable(true); + if (parent != null && !xembedded) 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. |
From: <ka...@us...> - 2011-06-09 22:27:59
|
Revision: 3544 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3544&view=rev Author: kappa1 Date: 2011-06-09 22:27:53 +0000 (Thu, 09 Jun 2011) Log Message: ----------- LinuxDisplay: run setFocusable(boolean) on the EDT 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 2011-06-09 07:48:25 UTC (rev 3543) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-06-09 22:27:53 UTC (rev 3544) @@ -45,6 +45,7 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.lang.reflect.InvocationTargetException; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; @@ -901,13 +902,26 @@ if (focused) { acquireInput(); - if (parent != null && !xembedded) parent.setFocusable(false); + if (parent != null && !xembedded) edtSetCanvasFocus(false); } else { releaseInput(); - if (parent != null && !xembedded) parent.setFocusable(true); + if (parent != null && !xembedded) edtSetCanvasFocus(true); } } + + private void edtSetCanvasFocus(final boolean focus) { + try { + java.awt.EventQueue.invokeAndWait(new Runnable() { + public void run() { + parent.setFocusable(focus); + } + }); + } catch (InterruptedException e) { + } catch (InvocationTargetException e) { + } + } + static native long nGetInputFocus(long display); private static void setInputFocusUnsafe(long window) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-06-26 01:42:40
|
Revision: 3552 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3552&view=rev Author: kappa1 Date: 2011-06-26 01:42:34 +0000 (Sun, 26 Jun 2011) Log Message: ----------- Proper fix for Linux focus handling with setParent(Canvas), no more hacks or messing with EDT. Side effect being LWJGL applet focus handling should work perfectly now. 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 2011-06-24 18:34:10 UTC (rev 3551) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-06-26 01:42:34 UTC (rev 3552) @@ -39,6 +39,9 @@ */ import java.awt.Canvas; +import java.awt.event.FocusListener; +import java.awt.event.FocusEvent; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -141,6 +144,23 @@ private LinuxKeyboard keyboard; private LinuxMouse mouse; + + private final FocusListener focus_listener = new FocusListener() { + public void focusGained(FocusEvent e) { + synchronized (GlobalLock.lock) { + nGrabKeyboard(getDisplay(), current_window); + focused = true; + input_released = false; + } + } + public void focusLost(FocusEvent e) { + synchronized (GlobalLock.lock) { + nUngrabKeyboard(getDisplay()); + focused = false; + input_released = true; + } + } + }; private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { lockAWT(); @@ -441,6 +461,14 @@ grab = false; minimized = false; dirty = true; + if (parent != null) { + parent.addFocusListener(focus_listener); + if (parent.isFocusOwner()) { + nGrabKeyboard(getDisplay(), current_window); + focused = true; + input_released = false; + } + } } finally { peer_info.unlock(); } @@ -795,7 +823,6 @@ lockAWT(); try { processEvents(); - checkInput(); } finally { unlockAWT(); } @@ -877,64 +904,21 @@ } } - private void checkInput() { - if (parent == null) return; - - if (parent_focus != parent.hasFocus()) { - parent_focus = parent.hasFocus(); - - if (parent_focus) { - setInputFocusUnsafe(current_window); - } - else if (xembedded) { - setInputFocusUnsafe(1); - } - } - //else if (parent_focus && !focused && !xembedded) { - // setInputFocusUnsafe(current_window); - //} - } - private void setFocused(boolean got_focus, int focus_detail) { - if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot) + if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null) return; focused = got_focus; if (focused) { acquireInput(); - if (parent != null && !xembedded) edtSetCanvasFocus(false); } else { releaseInput(); - if (parent != null && !xembedded) edtSetCanvasFocus(true); } } - private void edtSetCanvasFocus(final boolean focus) { - try { - java.awt.EventQueue.invokeAndWait(new Runnable() { - public void run() { - parent.setFocusable(focus); - } - }); - } catch (InterruptedException e) { - } catch (InvocationTargetException e) { - } - } - static native long nGetInputFocus(long display); - private static void setInputFocusUnsafe(long window) { - try { - setInputFocus(getDisplay(), window, CurrentTime); - sync(getDisplay(), false); - } catch (LWJGLException e) { - // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore - LWJGLUtil.log("Got exception while trying to focus: " + e); - } - } - private static native void sync(long display, boolean throw_away_events) throws LWJGLException; - private void releaseInput() { if (isLegacyFullscreen() || input_released) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-06-26 11:50:29
|
Revision: 3554 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3554&view=rev Author: kappa1 Date: 2011-06-26 11:50:23 +0000 (Sun, 26 Jun 2011) Log Message: ----------- Fix small race condition in LinuxDisplay when focusing in and out really fast. 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 2011-06-26 02:18:53 UTC (rev 3553) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-06-26 11:50:23 UTC (rev 3554) @@ -148,16 +148,12 @@ private final FocusListener focus_listener = new FocusListener() { public void focusGained(FocusEvent e) { synchronized (GlobalLock.lock) { - nGrabKeyboard(getDisplay(), current_window); focused = true; - input_released = false; } } public void focusLost(FocusEvent e) { synchronized (GlobalLock.lock) { - nUngrabKeyboard(getDisplay()); focused = false; - input_released = true; } } }; @@ -823,6 +819,7 @@ lockAWT(); try { processEvents(); + checkInput(); } finally { unlockAWT(); } @@ -904,6 +901,21 @@ } } + private void checkInput() { + if (parent == null) return; + + if (focused != keyboard_grabbed) { + if (focused) { + grabKeyboard(); + input_released = false; + } + else { + ungrabKeyboard(); + input_released = true; + } + } + } + private void setFocused(boolean got_focus, int focus_detail) { if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-09-25 21:57:55
|
Revision: 3640 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3640&view=rev Author: kappa1 Date: 2011-09-25 21:57:49 +0000 (Sun, 25 Sep 2011) Log Message: ----------- Fix issues with LWJGL Applets when dragging or switching browser tabs 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 2011-09-20 19:46:33 UTC (rev 3639) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-09-25 21:57:49 UTC (rev 3640) @@ -142,7 +142,7 @@ private Canvas parent; private long parent_window; - private boolean xembedded; + private static boolean xembedded; private long parent_proxy_focus_window; private boolean parent_focused; private long last_window_focus = 0; @@ -299,6 +299,8 @@ private static native void synchronize(long display, boolean synchronize); private static int globalErrorHandler(long display, long event_ptr, long error_display, long serial, long error_code, long request_code, long minor_code) throws LWJGLException { + if (xembedded) return 0; // ignore X errors in xembeded mode to fix browser issues like dragging or switching tabs + if (display == getDisplay()) { String error_msg = getErrorText(display, error_code); throw new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code); @@ -924,12 +926,6 @@ if (xembedded) { long current_focus_window = 0; - try { - current_focus_window = nGetInputFocus(getDisplay()); - } catch (LWJGLException e) { - return; // fail silently as it can fail whilst splitting browser tabs - } - if (last_window_focus != current_focus_window || parent_focused != focused) { if (isParentWindowActive(current_focus_window)) { if (parent_focused) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-09-26 20:04:06
|
Revision: 3641 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3641&view=rev Author: kappa1 Date: 2011-09-26 20:03:59 +0000 (Mon, 26 Sep 2011) Log Message: ----------- limit scope of fix for Display.setParent when running in xembedded mode. 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 2011-09-25 21:57:49 UTC (rev 3640) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-09-26 20:03:59 UTC (rev 3641) @@ -299,7 +299,7 @@ private static native void synchronize(long display, boolean synchronize); private static int globalErrorHandler(long display, long event_ptr, long error_display, long serial, long error_code, long request_code, long minor_code) throws LWJGLException { - if (xembedded) return 0; // ignore X errors in xembeded mode to fix browser issues like dragging or switching tabs + if (xembedded && request_code == 42) return 0; // ignore X error in xembeded mode to fix a browser issue when dragging or switching tabs if (display == getDisplay()) { String error_msg = getErrorText(display, error_code); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2011-09-27 22:38:39
|
Revision: 3642 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3642&view=rev Author: kappa1 Date: 2011-09-27 22:38:32 +0000 (Tue, 27 Sep 2011) Log Message: ----------- LinuxDisplay use proper constant name (X_SetInputFocus) for xembedded fix 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 2011-09-26 20:03:59 UTC (rev 3641) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-09-27 22:38:32 UTC (rev 3642) @@ -85,6 +85,8 @@ private static final int SetModeInsert = 0; private static final int SaveSetRoot = 1; private static final int SaveSetUnmap = 1; + + private static final int X_SetInputFocus = 42; /** Window mode enum */ private static final int FULLSCREEN_LEGACY = 1; @@ -299,7 +301,7 @@ private static native void synchronize(long display, boolean synchronize); private static int globalErrorHandler(long display, long event_ptr, long error_display, long serial, long error_code, long request_code, long minor_code) throws LWJGLException { - if (xembedded && request_code == 42) return 0; // ignore X error in xembeded mode to fix a browser issue when dragging or switching tabs + if (xembedded && request_code == X_SetInputFocus) return 0; // ignore X error in xembeded mode to fix a browser issue when dragging or switching tabs if (display == getDisplay()) { String error_msg = getErrorText(display, error_code); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2012-01-22 18:02:41
|
Revision: 3728 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3728&view=rev Author: kappa1 Date: 2012-01-22 18:02:34 +0000 (Sun, 22 Jan 2012) Log Message: ----------- fix for Display.isActive() so that it works as it should on Linux when using Display.setParent() 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 2012-01-18 12:19:52 UTC (rev 3727) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2012-01-22 18:02:34 UTC (rev 3728) @@ -800,10 +800,10 @@ relayEventToParent(event_buffer, KeyPressMask); break; case LinuxEvent.ButtonPress: - relayEventToParent(event_buffer, KeyPressMask); + if (xembedded) relayEventToParent(event_buffer, KeyPressMask); break; case LinuxEvent.ButtonRelease: - relayEventToParent(event_buffer, KeyPressMask); + if (xembedded) relayEventToParent(event_buffer, KeyPressMask); break; default: break; @@ -1038,7 +1038,7 @@ } private void setFocused(boolean got_focus, int focus_detail) { - if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null) + if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || xembedded) return; focused = got_focus; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2012-01-22 20:16:47
|
Revision: 3729 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3729&view=rev Author: kappa1 Date: 2012-01-22 20:16:41 +0000 (Sun, 22 Jan 2012) Log Message: ----------- Small tweak to the Linux Display.isActive() fix. 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 2012-01-22 18:02:34 UTC (rev 3728) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2012-01-22 20:16:41 UTC (rev 3729) @@ -800,10 +800,10 @@ relayEventToParent(event_buffer, KeyPressMask); break; case LinuxEvent.ButtonPress: - if (xembedded) relayEventToParent(event_buffer, KeyPressMask); + if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask); break; case LinuxEvent.ButtonRelease: - if (xembedded) relayEventToParent(event_buffer, KeyPressMask); + if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask); break; default: break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |