diff options
author | Sven Gothel <[email protected]> | 2019-04-09 21:33:17 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-04-09 21:33:17 +0200 |
commit | 705c7f7b3fb36c1d654f5d9b9016859506d93764 (patch) | |
tree | 748499abcd2d1f36ba20fb173317f39ee51ce740 /src | |
parent | ca3bf988bfad6adac9ad9ac240f3c15b129ef85e (diff) |
Bug 1362: Minimal action required: setBackground of the parent canvas before reparenting!
Bug 1362 fix or workaround: Seems SWT/GTK3 at least performs lazy initialization
Minimal action required: setBackground of the parent canvas before reparenting!
Diffstat (limited to 'src')
3 files changed, 12 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 58b5bbcb9..a34c8648a 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -62,6 +62,7 @@ import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; @@ -381,6 +382,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS drawable = null; context = null; + // Bug 1362 fix or workaround: Seems SWT/GTK3 at least performs lazy initialization + // Minimal action required: setBackground of the parent canvas before reparenting! + setBackground(new Color(parent.getDisplay(), 255, 255, 255)); + final Listener listener = new Listener () { @Override public void handleEvent (final Event event) { diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index d1bd638d8..d30dbe6dc 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -41,7 +41,6 @@ import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.NativeWindowHolder; import com.jogamp.nativewindow.SurfaceUpdatedListener; import com.jogamp.nativewindow.WindowClosingProtocol; -import com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode; import com.jogamp.nativewindow.util.Insets; import com.jogamp.nativewindow.util.InsetsImmutable; import com.jogamp.nativewindow.util.Point; @@ -54,6 +53,7 @@ import jogamp.newt.Debug; import jogamp.newt.swt.SWTEDTUtil; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; @@ -139,6 +139,10 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC setNEWTChild(child); } + // Bug 1362 fix or workaround: Seems SWT/GTK3 at least performs lazy initialization + // Minimal action required: setBackground of the parent canvas before reparenting! + setBackground(new Color(parent.getDisplay(), 255, 255, 255)); + final Listener listener = new Listener () { @Override public void handleEvent (final Event event) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java index dafd8f07a..6694df65a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java @@ -160,19 +160,9 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase { SWTAccessor.invoke(true, new Runnable() { public void run() { canvas[0] = new Canvas (composite, SWT.NO_BACKGROUND); - // Bug 1362 fix or workaround: Seems GTK3 at least performs lazy initialization - // Minimal action required: setBackground + fillRectangle of some space in canvas ONCE before reparenting! - final boolean paintedOnce[] = { false }; + // Bug 1362 fix or workaround: Seems SWT/GTK3 at least performs lazy initialization + // Minimal action required: setBackground of the parent canvas before reparenting! canvas[0].setBackground(new Color(display, 255, 255, 255)); - canvas[0].addPaintListener (new PaintListener() { - public void paintControl(final PaintEvent e) { - if( !paintedOnce[0] ) { - paintedOnce[0] = true; - final Rectangle r = canvas[0].getClientArea(); - e.gc.fillRectangle(0, 0, r.width, r.height); - canvas[0].removePaintListener(this); - } - }}); shell.setText( getClass().getName() ); shell.setBounds( 0, 0, 700, 700 ); shell.open(); |