From 78fcb8228d4a391054501aef16eb0462322ba39d Mon Sep 17 00:00:00 2001 From: Petros Koutsolampros Date: Mon, 24 Feb 2014 16:37:01 +0000 Subject: A more wholesome solution to the windowing problems in OSX. As described in bug https://jogamp.org/bugzilla/show_bug.cgi?id=969 --- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 34 +++++++++++++++------- src/newt/classes/jogamp/newt/WindowImpl.java | 3 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 43e56c874..dbb5c13bc 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -146,9 +146,6 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.setSize(clientArea.width, clientArea.height); postSetSize = false; } - if( SWTAccessor.isOSX ) { - newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); - } newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } } @@ -166,7 +163,18 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { addListener (SWT.Paint, listener); addListener (SWT.Dispose, listener); } - + @Override + public void setBounds(int x, int y, int w, int h) { + // propagate the setBounds method coming from parent elements to this element + // and force newtChild to update its position in OSX + super.setBounds(x,y,w,h); + if(SWTAccessor.isOSX) { + newtChild.setPosition(x, y); + clientArea.width = w; + clientArea.height = h; + updateSizeCheck(); + } + } /** assumes nativeWindow == null ! */ protected final boolean validateNative() { updateSizeCheck(); @@ -199,6 +207,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { nativeWindow = new SWTNativeWindow(config, nativeWindowHandle); reparentWindow( true ); + if(SWTAccessor.isOSX) { + // initial positioning for OSX, called when the window is created + newtChild.setPosition(getLocation().x, getLocation().y); + } } return null != nativeWindow; @@ -255,9 +267,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { nativeWindow = null; super.dispose(); } - - private Rectangle getSWTCanvasPosition() { - return super.getBounds(); + + private Point getParentLocationOnScreen() { + org.eclipse.swt.graphics.Point parentLoc = getParent().toDisplay(0,0); + return new Point(parentLoc.x,parentLoc.y); } /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ public NativeWindow getNativeWindow() { return nativeWindow; } @@ -506,10 +519,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public Point getLocationOnScreen(Point point) { final Point los; // client window location on screen if( SWTAccessor.isOSX ) { - los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); - // top-level position -> client window position: OSX needs to add SWT parent position incl. insets - final Rectangle swtCanvasPosition = getSWTCanvasPosition(); - los.translate(swtCanvasPosition.x + insets.getLeftWidth(), swtCanvasPosition.y + insets.getTopHeight()); + // let getLOS provide the point where the child window may be placed + // from, as taken from SWT Control.toDisplay(); + los = getParentLocationOnScreen(); } else if (SWTAccessor.isX11) { final AbstractGraphicsScreen s = config.getScreen(); los = X11Lib.GetRelativeLocation(s.getDevice().getHandle(), s.getIndex(), nativeWindowHandle, 0 /*root win*/, 0, 0); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 7f7cb61a9..5a5e0cc3d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2107,7 +2107,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window setPosition: "+getX()+"/"+getY()+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)); } - if ( !isFullscreen() && ( getX() != x || getY() != y ) ) { + // let the window be resized as long as the parent is there + if ( !isFullscreen() && ( getX() != x || getY() != y || null != getParent()) ) { if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible())); -- cgit v1.2.3 From ac7de4a7b2cc939312cbeb88dd709a297c96c13c Mon Sep 17 00:00:00 2001 From: Xerxes RĂ„nby Date: Tue, 25 Feb 2014 14:36:22 +0100 Subject: Bug 927: Try fix deadlock. (14:15:13) sgothel: @Xerxes: In doResume .. do a 'while( !isActive && !shallPause && isRunning ) {' (14:15:52) sgothel: doPause: while( isActive && !shallPause && isRunning ) (14:31:55) sgothel: doPause only: while( isActive && isRunning ) { --- src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 7cea51dc8..6a0e0061f 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -1127,7 +1127,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( isBlocked && isActive ) { this.interrupt(); } - while( isActive ) { + while( isActive && isRunning ) { try { this.wait(); // wait until paused } catch (InterruptedException e) { @@ -1141,7 +1141,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( isRunning && !isActive ) { shallPause = false; if( Thread.currentThread() != this ) { - while( !isActive ) { + while( !isActive && !shallPause && isRunning ) { this.notifyAll(); // wake-up pause-block try { this.wait(); // wait until resumed -- cgit v1.2.3 From 083e430a76586347e87f4e2a25d92ac00cdcc61a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Feb 2014 16:53:10 +0100 Subject: Bug 937 : Fix regression of commit 071bdd6ce9f8c41ccecdbf8bc74f276ccd7ff651 (which disables print if !isShowing()) Commit 071bdd6ce9f8c41ccecdbf8bc74f276ccd7ff651 uses 'isShowing' state to determine whether to display or not. It also uses 'isShowing' instead of 'isVisible' for printing, which is a regression, since not showing elements offscreen shall be able to be printed. --- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 4 ++-- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 6 +++--- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index abf670c95..09589080f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -818,9 +818,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printActive = false; return; // not yet available .. } - if( !isShowing ) { + if( !isVisible() ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable valid, canvas not showing"); + System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, canvas not visible"); } printActive = false; return; // not yet available .. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index adc0a0d23..fbd923a3b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -437,7 +437,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void display() { - if( isShowing ) { + if( isShowing || ( printActive && isVisible() ) ) { if (EventQueue.isDispatchThread()) { // Want display() to be synchronous, so call paintImmediately() paintImmediately(0, 0, getWidth(), getHeight()); @@ -627,9 +627,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printActive = false; return; // not yet available .. } - if( !isShowing ) { + if( !isVisible() ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable valid, panel not showing"); + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, panel not visible"); } printActive = false; return; // not yet available .. diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 1ed628435..f0cc68903 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -621,9 +621,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printActive = false; return; // not yet available .. } - if( !isShowing() ) { + if( !isVisible() ) { if(DEBUG) { - System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable valid, canvas not showing"); + System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, canvas not visible"); } printActive = false; return; // not yet available .. -- cgit v1.2.3 From c2e6233c57f47c067dbb24f4a6a127fbaedf7a08 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Feb 2014 17:16:47 +0100 Subject: Fix whitespaces of commit 78fcb8228d4a391054501aef16eb0462322ba39d and WindowImpl comment --- src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 12 ++++++------ src/newt/classes/jogamp/newt/WindowImpl.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index dbb5c13bc..6f4be75f5 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -163,13 +163,13 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { addListener (SWT.Paint, listener); addListener (SWT.Dispose, listener); } - @Override + @Override public void setBounds(int x, int y, int w, int h) { // propagate the setBounds method coming from parent elements to this element // and force newtChild to update its position in OSX super.setBounds(x,y,w,h); if(SWTAccessor.isOSX) { - newtChild.setPosition(x, y); + newtChild.setPosition(x, y); clientArea.width = w; clientArea.height = h; updateSizeCheck(); @@ -208,8 +208,8 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { nativeWindow = new SWTNativeWindow(config, nativeWindowHandle); reparentWindow( true ); if(SWTAccessor.isOSX) { - // initial positioning for OSX, called when the window is created - newtChild.setPosition(getLocation().x, getLocation().y); + // initial positioning for OSX, called when the window is created + newtChild.setPosition(getLocation().x, getLocation().y); } } @@ -267,7 +267,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { nativeWindow = null; super.dispose(); } - + private Point getParentLocationOnScreen() { org.eclipse.swt.graphics.Point parentLoc = getParent().toDisplay(0,0); return new Point(parentLoc.x,parentLoc.y); @@ -519,7 +519,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public Point getLocationOnScreen(Point point) { final Point los; // client window location on screen if( SWTAccessor.isOSX ) { - // let getLOS provide the point where the child window may be placed + // let getLOS provide the point where the child window may be placed // from, as taken from SWT Control.toDisplay(); los = getParentLocationOnScreen(); } else if (SWTAccessor.isX11) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 5a5e0cc3d..9593d4faa 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2107,7 +2107,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window setPosition: "+getX()+"/"+getY()+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)); } - // let the window be resized as long as the parent is there + // Let the window be positioned if !fullscreen and position changed or being a child window. if ( !isFullscreen() && ( getX() != x || getY() != y || null != getParent()) ) { if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system -- cgit v1.2.3