Skip to content

Commit

Permalink
NEWT/OSX getLocationOnScreenImpl(..): Use real OSXUtil.GetLocationOnS…
Browse files Browse the repository at this point in the history
…creen(..) if onscreen and surface available.
  • Loading branch information
sgothel committed Oct 30, 2012
1 parent 24d5fa1 commit 6f2f5cc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
Expand Up @@ -45,6 +45,7 @@
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;
Expand Down Expand Up @@ -149,7 +150,7 @@ protected void requestFocusImpl(boolean force) {

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());
Expand Down Expand Up @@ -236,16 +237,21 @@ protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int
}

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) {
Expand Down

0 comments on commit 6f2f5cc

Please sign in to comment.