diff options
author | Sven Gothel <[email protected]> | 2013-11-17 04:55:33 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-11-17 04:55:33 +0100 |
commit | 0be87f241c0f0b2f5881d9a602ce12378b8e453d (patch) | |
tree | 801449f6fac0253b2fcd0982dc4dfcc435f2867f | |
parent | 88f6e0012b36ca69dedaadb4e403e2a424b20cbf (diff) |
Fix Bug 879 - Threads deadlock in native keyboardfocus calls made form multiple threads; Fix Bug 892: Reduce Focus Hopping
Since we manage focus key traversal ourselves w/o requiring the AWT
component to have the focus[1],
we simply can drop requesting the focus for 'focus hopping' NEWT -> AWT -> NEWT[2].
Further more, 'MenuSelectionManager.defaultManager().clearSelectedPath()'
must be performed on AWT-EDT w/o blocking. Otherwise it may perform blocking tasks on AWT-EDT.
[1] Commit cb7118fc875b6722803e4b11d5681671962a8d3a
introduced function to query the next or previous 'to be focused' component:
AWTMisc.getNextFocus(..) .. etc.
[2] Focus hopping is also addressed in Bug 892
-rwxr-xr-x | make/scripts/tests-win.bat | 4 | ||||
-rw-r--r-- | make/scripts/tests.sh | 8 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 |
3 files changed, 17 insertions, 18 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 90e736188..8008e959f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -139,7 +139,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslu REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ed3a91f99..aab20980d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -192,14 +192,14 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -319,7 +319,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -610,7 +610,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # # Misc Utils diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 70157fe4b..9611cc960 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -190,23 +190,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.FocusAction: "+Display.getThreadName()+", isOnscreen "+isOnscreen+", hasFocus "+hasFocus()+", isParent "+isParent+", isFS "+isFullscreen); } - if(isParent && !isFullscreen) { - // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - if(isOnscreen) { - // Remove the AWT focus in favor of the native NEWT focus - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); - } + if( isParent && !isFullscreen && isOnscreen ) { + // Remove the AWT focus in favor of the native NEWT focus + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); } return false; // NEWT shall proceed requesting the native focus } } private final FocusAction focusAction = new FocusAction(); - WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { + /** Must run on AWT-EDT non-blocking, since it invokes tasks on AWT-EDT w/ waiting otherwise. */ + private final Runnable awtClearSelectedMenuPath = new Runnable() { + public void run() { + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + }; + private final WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override public void windowResized(WindowEvent e) { updateLayoutSize(); @@ -214,7 +213,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void windowGainedFocus(WindowEvent arg0) { if( isParent() && !isFullscreen() ) { - MenuSelectionManager.defaultManager().clearSelectedPath(); + AWTEDTExecutor.singleton.invoke(false, awtClearSelectedMenuPath); } } }; |