From 6f2f5cc9fca5d36b11744ab4d69c3177b0271f22 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 30 Oct 2012 17:39:31 +0100 Subject: NEWT/OSX getLocationOnScreenImpl(..): Use real OSXUtil.GetLocationOnScreen(..) if onscreen and surface available. --- .../jogamp/newt/driver/macosx/WindowDriver.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index bc83f9540..121c3fa99 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -45,6 +45,7 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; +import jogamp.nativewindow.macosx.OSXUtil; import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; @@ -149,7 +150,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public final void clearFocus() { if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); + System.err.println("MacWindow: clearFocus(), isOffscreenInstance "+isOffscreenInstance); } if(!isOffscreenInstance) { resignFocus0(getWindowHandle()); @@ -236,16 +237,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } protected Point getLocationOnScreenImpl(int x, int y) { - Point p = new Point(x, y); + final NativeWindow parent = getParent(); + final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + + if( !useParent && !isOffscreenInstance && 0 != surfaceHandle) { + return OSXUtil.GetLocationOnScreen(surfaceHandle, true, x, y); + } + + final Point p = new Point(x, y); // min val is 0 p.setX(Math.max(p.getX(), 0)); p.setY(Math.max(p.getY(), 0)); - - final NativeWindow parent = getParent(); - if( null != parent && 0 != parent.getWindowHandle() ) { + if( useParent ) { p.translate(parent.getLocationOnScreen(null)); } - return p; + return p; } private Point getTopLevelLocationOnScreen(int x, int y) { -- cgit v1.2.3