--- old/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java 2012-12-04 16:21:03.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java 2012-12-04 16:21:03.000000000 +0400 @@ -26,8 +26,11 @@ package sun.lwawt.macosx; import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.awt.image.VolatileImage; import sun.awt.CGraphicsConfig; +import sun.awt.CGraphicsEnvironment; import sun.lwawt.LWWindowPeer; import sun.lwawt.macosx.event.NSEvent; @@ -37,6 +40,10 @@ public class CPlatformView extends CFRetainedResource { private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr); + private static native void nativeSetAutoResizable(long awtView, boolean toResize); + private static native int nativeGetNSViewDisplayID(long awtView); + private static native Rectangle2D nativeGetLocationOnScreen(long awtView); + private static native boolean nativeIsViewUnderMouse(long ptr); private LWWindowPeer peer; private SurfaceData surfaceData; @@ -59,7 +66,7 @@ public long getAWTView() { return ptr; - } + } public boolean isOpaque() { return !peer.isTranslucent(); @@ -157,11 +164,47 @@ return 0; } } + + public void setAutoResizable(boolean toResize) { + nativeSetAutoResizable(this.getAWTView(), toResize); + } + + public boolean isUnderMouse() { + return nativeIsViewUnderMouse(getAWTView()); + } + + public GraphicsDevice getGraphicsDevice() { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + CGraphicsEnvironment cge = (CGraphicsEnvironment)ge; + int displayID = nativeGetNSViewDisplayID(getAWTView()); + GraphicsDevice gd = cge.getScreenDevice(displayID); + if (gd == null) { + // this could possibly happen during device removal + // use the default screen device in this case + gd = ge.getDefaultScreenDevice(); + } + return gd; + } + + public Point getLocationOnScreen() { + Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds(); + return new Point(r.x, r.y); + } // ---------------------------------------------------------------------- // NATIVE CALLBACKS // ---------------------------------------------------------------------- + /* + * The callback is called only in the embedded case when the view is + * automatically resized by the superview. + * In normal mode this method is never called. + */ + private void deliverResize(int x, int y, int w, int h) { + peer.notifyReshape(x, y, w, h); + } + + private void deliverMouseEvent(NSEvent event) { int x = event.getX(); int y = getBounds().height - event.getY();