Bug 730

Summary: Dragging a frame with a GLCanvas from one screen to another does not work as expected
Product: [JogAmp] Jogl Reporter: Bart Adams <bart.adams>
Component: awtAssignee: Sven Gothel <sgothel>
Status: RESOLVED INVALID    
Severity: normal CC: gouessej
Priority: ---    
Version: 2   
Hardware: All   
OS: linux   
Type: --- SCM Refs:
Workaround: ---
Attachments: Video illustrating the problem.

Description Bart Adams 2013-05-07 10:32:41 CEST
Created attachment 461 [details]
Video illustrating the problem.

This is a GLCanvas issue with dual screen setups on linux when ran with Java 7. The issue does not happen when ran with Java 6. It also does not happen with GLJPanel or with a regular Canvas, only with GLCanvas.

The issue is as follows: when dragging a frame with a GLCanvas from the left screen to the right, the frame with the canvas jumps from the left screen to the right as soon as it's just halfway over the border of the left screen. The expected behavior would be that the frame can be dragged smoothly from the left to the right screen (without the discontinuous jump).

In attachment is a sample application that creates 3 frames: one with a GLCanvas, one with a GLJPanel, and one with a Canvas. Only the frame with the GLCanvas exhibits the bad behavior.

Code used to reproduce the problem:

import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.awt.GLJPanel;
import javax.swing.JFrame;
import java.awt.Canvas;

/**
 * Drag each frame from the first monitor to the second.
 * Notice how the GLCanvas one does not behave correctly.
 */
public class GLCanvasVersusGLJPanel {

  public static void main(String[] args) {
    JFrame frame1 = new JFrame("GLCanvas");
    frame1.add( new GLCanvas() );
    frame1.setSize( 400,300 );
    frame1.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    JFrame frame2 = new JFrame("GLJPanel");
    frame2.add( new GLJPanel() );
    frame2.setSize( 400,300 );
    frame2.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    JFrame frame3 = new JFrame("Canvas");
    frame3.add( new Canvas() );
    frame3.setSize( 400,300 );
    frame3.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    frame1.setVisible( true );
    frame2.setVisible( true );
    frame3.setVisible( true );

  }
}
Comment 1 Sven Gothel 2013-05-07 11:35:18 CEST
This is a Java7 issue, not a JOGL one!

See my test results below.

It is not in our control when Java7's AWT impl.
pulls the native peer of the GLCanvas issuing a 
pair of removeNotify() / addNotify().

+++

Test: Run unit/demo and move it across multiple monitors:

++

OpenJDK6 and X11 here:
  java version "1.6.0_27"
  OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-1)
  OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

- GLCanvas works flawless
    - com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT

++

OpenJDK7 and X11 here:
  java version "1.7.0_03"
  OpenJDK Runtime Environment (IcedTea7 2.1.6) (7u3-2.1.6-1)
  OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)

- GLCanvas: a small 'jump' is noticed when crossing monitors
    - com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT
    - when crossing monitors:
      - small 'jump' noticed
      - GLCanvas dispose and init is being performed
        due to destruction of it's underlying native peer!
        This is not within our control, but an AWT impl. detail.
    
- NEWT works flawless
    - com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT

- NewtCanvasAWT works flawless
    - com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT

- NewtCanvasSWT works flawless
    - com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT

- .. and last but not least, even SWT works flawless
    - com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT
Comment 2 Bart Adams 2013-05-07 13:01:52 CEST
Sven, thanks for the detailed analysis. 

Can you comment on the difference between the test with a Canvas and a GLCanvas.

With a Canvas there is no jump, with a GLCanvas there is.
Comment 3 Julien Gouesse 2013-05-11 18:24:36 CEST
(In reply to comment #2)
> Sven, thanks for the detailed analysis. 
> 
> Can you comment on the difference between the test with a Canvas and a
> GLCanvas.
> 
> With a Canvas there is no jump, with a GLCanvas there is.

Use NEWT, it's under our control and we can do your best to make it work as expected. The results are not surprising. In your case, maybe you can use NewtCanvasAWT.