aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-01-02 04:44:19 +0100
committerSven Gothel <[email protected]>2020-01-02 04:44:19 +0100
commit999e1ca3ec1a406d3dba65f0bae79054580fb287 (patch)
tree5e0d8cb6d40ad9c4a51b3e5bff74e6b6518601e9 /src
parentef2600134f07902dd32cf6524d9c947bdc915b45 (diff)
Bug 1393: MacOS: getLocationOnScreen w/ JAWT Parent: Use parent's unblocking specialization
On MacOS, commit 12eed5d38616d23b6e8e2e5b497dfc2f54d90c90 replaced all parent.getLocationOnScreen(..) calls with OSXUtil.GetLocationOnScreen(parentHandle, ..) avoiding the EDT + Appkit Deadlock with native parenting. On MacOS AWT and JAWT are using offscreen CALayer since Java >= 1.7.0, therefor the MacOSXJAWTWindow's native window handle can't be used to gather the screen position via OSXUtil. However, the JAWT Window specialization MacOSXJAWTWindow implements a non-locking code-path and we can decide to use it by querying the general interface OffscreenLayerOption.
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java18
2 files changed, 22 insertions, 10 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 53e05d8a0..18d1ebafa 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -39,6 +39,7 @@ import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
import com.jogamp.nativewindow.GraphicsConfigurationFactory;
import com.jogamp.nativewindow.NativeWindow;
import com.jogamp.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.OffscreenLayerOption;
import com.jogamp.nativewindow.MutableSurface;
import com.jogamp.nativewindow.ScalableSurface;
import com.jogamp.nativewindow.VisualIDHolder;
@@ -523,6 +524,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
private Point getLocationOnScreenByParent(final int x, final int y, final NativeWindow parent) {
// return new Point(x, y).translate( parent.getLocationOnScreen(null) ); // Bug 1393: deadlock AppKit + EDT
+
+ // If parent is JAWT on OSX (offscreen), we need to query its non-blocking position
+ if( parent instanceof OffscreenLayerOption && ((OffscreenLayerOption)parent).isOffscreenLayerSurfaceEnabled() ) {
+ return new Point(x, y).translate( parent.getLocationOnScreen(null) ); // uses non-blocking specialization
+ }
return new Point(x, y).translate( OSXUtil.GetLocationOnScreen(parent.getWindowHandle(), 0, 0) ); // non-blocking
}
@@ -542,7 +548,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
// screen position -> rel child window position
final Point absPos = new Point(newX, newY);
// final Point parentOnScreen = parent.getLocationOnScreen(null); // Bug 1393: deadlock AppKit + EDT
- final Point parentOnScreen = OSXUtil.GetLocationOnScreen(parent.getWindowHandle(), 0, 0); // non-blocking
+ final Point parentOnScreen;
+ if( parent instanceof OffscreenLayerOption && ((OffscreenLayerOption)parent).isOffscreenLayerSurfaceEnabled() ) {
+ // If parent is JAWT on OSX (offscreen), we need to query its non-blocking position
+ parentOnScreen = parent.getLocationOnScreen(null); // uses non-blocking specialization
+ } else {
+ parentOnScreen = OSXUtil.GetLocationOnScreen(parent.getWindowHandle(), 0, 0); // non-blocking
+ }
absPos.translate( parentOnScreen.scale(-1, -1) );
if(DEBUG_IMPLEMENTATION) {
System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java
index 5f88d1c6f..3be7a96dc 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java
@@ -388,7 +388,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
// pay more attention to the NEWT event modifier stuff.
@Test(timeout=180000) // TO 3 min
- public void testSingleButtonPressAndRelease() throws Exception {
+ public void test01SingleButtonPressAndRelease() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -398,7 +398,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
}
@Test(timeout=180000) // TO 3 min
- public void testSingleButtonPressAndReleaseWithShift() throws Exception {
+ public void test02SingleButtonPressAndReleaseWithShift() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -408,7 +408,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
}
@Test(timeout=180000) // TO 3 min
- public void testSingleButtonPressAndReleaseWithCtrl() throws Exception {
+ public void test03SingleButtonPressAndReleaseWithCtrl() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -421,7 +421,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
* The META and ALT tests get too tied up with functions of the window system on X11,
* so it's probably best to leave them commented out.
@Test(timeout=180000) // TO 3 min
- public void testSingleButtonPressAndReleaseWithMeta() throws Exception {
+ public void test04SingleButtonPressAndReleaseWithMeta() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -431,7 +431,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
}
@Test(timeout=180000) // TO 3 min
- public void testSingleButtonPressAndReleaseWithAlt() throws Exception {
+ public void test05SingleButtonPressAndReleaseWithAlt() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -448,7 +448,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
* My US keyboard doesn't have an AltGr key, so maybe X is smart
* enough to not let this modifier slip through (?).
@Test
- public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception {
+ public void test06SingleButtonPressAndReleaseWithAltGraph() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -461,7 +461,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
////////////////////////////////////////////////////////////////////////////
@Test(timeout=180000) // TO 3 min
- public void testHoldOneButtonAndPressAnother() throws Exception {
+ public void test10HoldOneButtonAndPressAnother() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -471,7 +471,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
}
@Test(timeout=180000) // TO 3 min
- public void testPressAllButtonsInSequence() throws Exception {
+ public void test20PressAllButtonsInSequence() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {
@@ -481,7 +481,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase {
}
@Test(timeout=180000) // TO 3 min
- public void testSingleButtonClickAndDrag() throws Exception {
+ public void test30SingleButtonClickAndDrag() throws Exception {
execOffThreadWithOnThreadEventDispatch(new Runnable() {
public void run() {
try {