Jogamp
Bug 1223 OSX: GLWindow loses focus after maximizing - Analysis
authorSven Gothel <sgothel@jausoft.com>
Sat, 26 Sep 2015 01:50:09 +0000 (03:50 +0200)
committerSven Gothel <sgothel@jausoft.com>
Sat, 26 Sep 2015 01:50:09 +0000 (03:50 +0200)
TestGearsES2NEWT reacts on key-press 'n', opening another GLWindow.

Procedure:
[1] Pressing 'n' (2nd GLWindow) and manual re-focus 1st GLWindow

[2] Pressing 'm' (single, alt, shift) on 1st GLWindow maximizes it
    Focus is still on 1st GLWindow!

[3] Pressing ctrl-m un-maximizes ..
    Focus is still on 1st GLWindow!

src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java

index 4e31804..6fb7bab 100644 (file)
@@ -37,6 +37,8 @@ import com.jogamp.newt.NewtFactory;
 import com.jogamp.newt.Screen;
 import com.jogamp.newt.Window;
 import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
 import com.jogamp.newt.event.WindowAdapter;
 import com.jogamp.newt.opengl.GLWindow;
 import com.jogamp.newt.opengl.util.NEWTDemoListener;
@@ -189,11 +191,37 @@ public class TestGearsES2NEWT extends UITestCase {
             }
         });
 
+        final GLWindow[] glWindow2 = { null };
+
         final NEWTDemoListener newtDemoListener = new NEWTDemoListener(glWindow);
         newtDemoListener.quitAdapterEnable(true);
         glWindow.addKeyListener(newtDemoListener);
         glWindow.addMouseListener(newtDemoListener);
         glWindow.addWindowListener(newtDemoListener);
+        glWindow.addKeyListener(new KeyAdapter() {
+            @Override
+            public void keyPressed(final KeyEvent e) {
+                if( e.isAutoRepeat() ) {
+                    return;
+                }
+                if(e.getKeyChar()=='n') {
+                    if( null != glWindow2[0] && glWindow2[0].isNativeValid() ) {
+                        glWindow2[0].destroy();
+                        glWindow2[0] = null;
+                    } else {
+                        glWindow2[0] = GLWindow.create(screen, caps);
+                        glWindow2[0].setTitle("GLWindow2");
+                        glWindow2[0].setPosition(glWindow.getX()+glWindow.getWidth()+64, glWindow.getY());
+                        glWindow2[0].setSize(glWindow.getWidth(), glWindow.getHeight());
+                        glWindow2[0].addGLEventListener(new LineSquareXDemoES2(false));
+                        final Animator animator2 = useAnimator ? new Animator(glWindow2[0]) : null;
+                        if( null != animator2 ) {
+                            animator2.start();
+                        }
+                        glWindow2[0].setVisible(true);
+                    }
+                }
+            } } );
 
         if( useAnimator ) {
             animator.add(glWindow);
@@ -310,6 +338,10 @@ public class TestGearsES2NEWT extends UITestCase {
         }
         Assert.assertEquals(null, glWindow.getExclusiveContextThread());
         glWindow.destroy();
+        if( null != glWindow2[0] && glWindow2[0].isNativeValid() ) {
+            glWindow2[0].destroy();
+            glWindow2[0] = null;
+        }
         if( NativeWindowFactory.isAWTAvailable() ) {
             Assert.assertEquals(true,  AWTRobotUtil.waitForRealized(glWindow, false));
         }
http://JogAmp.org git info: FAQ, tutorial and man pages.