Mercurial > hg > release > icedtea7-forest-2.5 > jdk
changeset 8213:47e45e175f60
8029868: Fix KSS issues in sun.lwawt.macosx
Reviewed-by: anthony, serb
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CClipboard.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CClipboard.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,20 +40,23 @@ * sun.awt.datatransfer.DataTransferer. */ -public class CClipboard extends SunClipboard { +final class CClipboard extends SunClipboard { public CClipboard(String name) { super(name); } + @Override public long getID() { return 0; } + @Override protected void clearNativeContext() { // Leaving Empty, as WClipboard.clearNativeContext is empty as well. } + @Override protected void setContentsNative(Transferable contents) { FlavorTable flavorMap = getDefaultFlavorTable(); // Don't use delayed Clipboard rendering for the Transferable's data. @@ -89,6 +92,39 @@ notifyChanged(); } + @Override + protected native long[] getClipboardFormats(); + @Override + protected native byte[] getClipboardData(long format) throws IOException; + + // 1.5 peer method + @Override + protected void unregisterClipboardViewerChecked() { + // no-op because we lack OS support. This requires 4048791, which requires 4048792 + } + + // 1.5 peer method + @Override + protected void registerClipboardViewerChecked() { + // no-op because we lack OS support. This requires 4048791, which requires 4048792 + } + + // 1.5 peer method + // no-op. This appears to be win32 specific. Filed 4048790 for investigation + //protected Transferable createLocaleTransferable(long[] formats) throws IOException; + + private native void declareTypes(long[] formats, SunClipboard newOwner); + private native void setData(byte[] data, long format); + + /** + * Invokes native check whether a change count on the general pasteboard is different + * than when we set it. The different count value means the current owner lost + * pasteboard ownership and someone else put data on the clipboard. + * @since 1.7 + */ + native void checkPasteboard(); + + /*** Native Callbacks ***/ private void notifyLostOwnership() { lostOwnershipImpl(); } @@ -100,32 +136,4 @@ } clipboard.checkChange(clipboard.getClipboardFormats()); } - - protected native long[] getClipboardFormats(); - protected native byte[] getClipboardData(long format) throws IOException; - - // 1.5 peer method - protected void unregisterClipboardViewerChecked() { - // no-op because we lack OS support. This requires 4048791, which requires 4048792 - } - - // 1.5 peer method - protected void registerClipboardViewerChecked() { - // no-op because we lack OS support. This requires 4048791, which requires 4048792 - } - - // 1.5 peer method - // no-op. This appears to be win32 specific. Filed 4048790 for investigation - //protected Transferable createLocaleTransferable(long[] formats) throws IOException; - - public native void declareTypes(long[] formats, SunClipboard newOwner); - public native void setData(byte[] data, long format); - - /** - * Invokes native check whether a change count on the general pasteboard is different - * than when we set it. The different count value means the current owner lost - * pasteboard ownership and someone else put data on the clipboard. - * @since 1.7 - */ - public native void checkPasteboard(); }
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Fri Jul 03 18:58:03 2015 +0100 @@ -28,7 +28,6 @@ import sun.lwawt.LWToolkit; import sun.lwawt.LWWindowPeer; import sun.lwawt.macosx.CocoaConstants; -import sun.lwawt.macosx.event.NSEvent; import sun.awt.EmbeddedFrame;
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ import sun.awt.SunToolkit; import sun.lwawt.LWWindowPeer; -import sun.lwawt.macosx.event.NSEvent; import java.awt.*; import java.awt.event.MouseEvent;
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsEnvironment; import sun.lwawt.LWWindowPeer; -import sun.lwawt.macosx.event.NSEvent; import sun.java2d.SurfaceData; import sun.java2d.opengl.CGLLayer;
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import sun.java2d.*; import sun.print.*; -public class CPrinterJob extends RasterPrinterJob { +final class CPrinterJob extends RasterPrinterJob { // NOTE: This uses RasterPrinterJob as a base, but it doesn't use // all of the RasterPrinterJob functions. RasterPrinterJob will // break down printing to pieces that aren't necessary under MacOSX @@ -84,6 +84,7 @@ * returns true. * @see java.awt.GraphicsEnvironment#isHeadless */ + @Override public boolean printDialog() throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); @@ -118,6 +119,7 @@ * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.2 */ + @Override public PageFormat pageDialog(PageFormat page) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); @@ -139,12 +141,14 @@ * @return clone of <code>page</code>, altered to describe a default * <code>PageFormat</code>. */ + @Override public PageFormat defaultPage(PageFormat page) { PageFormat newPage = (PageFormat)page.clone(); getDefaultPage(newPage); return newPage; } + @Override protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException { if (attributes != null) { PageRanges pageRangesAttr = @@ -186,7 +190,7 @@ } } - + @Override public void print(PrintRequestAttributeSet attributes) throws PrinterException { // NOTE: Some of this code is copied from RasterPrinterJob. @@ -302,6 +306,7 @@ * Returns the resolution in dots per inch across the width * of the page. */ + @Override protected double getXRes() { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -311,6 +316,7 @@ * Returns the resolution in dots per inch down the height * of the page. */ + @Override protected double getYRes() { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -321,6 +327,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableX(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -331,6 +338,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableY(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -341,6 +349,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableWidth(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -351,6 +360,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPrintableHeight(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -361,6 +371,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPageWidth(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -371,6 +382,7 @@ * Value is in device pixels. * Not adjusted for orientation of the paper. */ + @Override protected double getPhysicalPageHeight(Paper p) { // NOTE: This is not used in the CPrinterJob code path. return 0; @@ -388,6 +400,7 @@ /** * End a page. */ + @Override protected void endPage(PageFormat format, Printable painter, int index) throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); @@ -400,6 +413,7 @@ * page. The width and height of the band is * specified by the caller. */ + @Override protected void printBand(byte[] data, int x, int y, int width, int height) throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); @@ -409,6 +423,7 @@ * Called by the print() method at the start of * a print job. */ + @Override protected void startDoc() throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); @@ -418,12 +433,14 @@ * Called by the print() method at the end of * a print job. */ + @Override protected void endDoc() throws PrinterException { // NOTE: This is not used in the CPrinterJob code path. throw new PrinterException(sShouldNotReachHere); } /* Called by cancelDoc */ + @Override protected native void abortDoc(); /** @@ -461,10 +478,12 @@ /** * validate the paper size against the current printer. */ + @Override protected native void validatePaper(Paper origPaper, Paper newPaper ); // The following methods are CPrinterJob specific. + @Override protected void finalize() { if (fNSPrintInfo != -1) { dispose(fNSPrintInfo);
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import java.awt.*; import java.awt.print.*; -public class CPrinterJobDialog extends CPrinterDialog { +final class CPrinterJobDialog extends CPrinterDialog { private Pageable fPageable; private boolean fAllowPrintToFile; @@ -39,5 +39,6 @@ fAllowPrintToFile = allowPrintToFile; } + @Override protected native boolean showDialog(); }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import java.awt.*; import java.awt.print.*; -public class CPrinterPageDialog extends CPrinterDialog { +final class CPrinterPageDialog extends CPrinterDialog { private PageFormat fPage; private Printable fPainter; @@ -39,5 +39,6 @@ fPainter = painter; } + @Override protected native boolean showDialog(); }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,11 +40,11 @@ // public static final SurfaceType IntArgbPQ = SurfaceType.IntArgb.deriveSubType(DESC_INT_ARGB_PQ); public static final SurfaceType IntRgbPQ = SurfaceType.IntRgb.deriveSubType(DESC_INT_RGB_PQ); - public static SurfaceData createData(PageFormat pf, long context) { + static SurfaceData createData(PageFormat pf, long context) { return new CPrinterSurfaceData(CPrinterGraphicsConfig.getConfig(pf), context); } - public CPrinterSurfaceData(GraphicsConfiguration gc, long context) { + private CPrinterSurfaceData(GraphicsConfiguration gc, long context) { super(IntRgbPQ, gc.getColorModel(), gc, gc.getBounds()); initOps(context, this.fGraphicsStates, this.fGraphicsStatesObject, gc.getBounds().width, gc.getBounds().height); }
--- a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package sun.lwawt.macosx; import sun.awt.SunToolkit; -import sun.lwawt.macosx.event.NSEvent; import javax.swing.*; import java.awt.*;
--- a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java Fri Jul 03 18:58:03 2015 +0100 @@ -25,63 +25,64 @@ package sun.lwawt.macosx; -public final class CWrapper { +final class CWrapper { private CWrapper() { } - public static final class NSWindow { + static final class NSWindow { // NSWindowOrderingMode - public static final int NSWindowAbove = 1; - public static final int NSWindowBelow = -1; - public static final int NSWindowOut = 0; + static final int NSWindowAbove = 1; + static final int NSWindowBelow = -1; + static final int NSWindowOut = 0; // Window level constants // The number of supported levels: (we'll use more in the future) - public static final int MAX_WINDOW_LEVELS = 2; + static final int MAX_WINDOW_LEVELS = 3; // The levels: (these are NOT real constants, these are keys. See native code.) - public static final int NSNormalWindowLevel = 0; - public static final int NSFloatingWindowLevel = 1; + static final int NSNormalWindowLevel = 0; + static final int NSFloatingWindowLevel = 1; // 'level' is one of the keys defined above - public static native void setLevel(long window, int level); + static native void setLevel(long window, int level); - public static native void makeKeyAndOrderFront(long window); - public static native void makeKeyWindow(long window); - public static native void makeMainWindow(long window); - public static native boolean canBecomeMainWindow(long window); - public static native boolean isKeyWindow(long window); + static native void makeKeyAndOrderFront(long window); + static native void makeKeyWindow(long window); + static native void makeMainWindow(long window); + static native boolean canBecomeMainWindow(long window); + static native boolean isKeyWindow(long window); - public static native void orderFront(long window); - public static native void orderFrontRegardless(long window); - public static native void orderWindow(long window, int ordered, long relativeTo); - public static native void orderOut(long window); + static native void orderFront(long window); + static native void orderFrontRegardless(long window); + static native void orderWindow(long window, int ordered, long relativeTo); + static native void orderOut(long window); - public static native void addChildWindow(long parent, long child, int ordered); - public static native void removeChildWindow(long parent, long child); + static native void addChildWindow(long parent, long child, int ordered); + static native void removeChildWindow(long parent, long child); - public static native void setAlphaValue(long window, float alpha); - public static native void setOpaque(long window, boolean opaque); - public static native void setBackgroundColor(long window, long color); + static native void setAlphaValue(long window, float alpha); + static native void setOpaque(long window, boolean opaque); + static native void setBackgroundColor(long window, long color); - public static native void miniaturize(long window); - public static native void deminiaturize(long window); - public static native boolean isZoomed(long window); - public static native void zoom(long window); + static native void miniaturize(long window); + static native void deminiaturize(long window); + static native boolean isZoomed(long window); + static native void zoom(long window); - public static native void makeFirstResponder(long window, long responder); + static native void makeFirstResponder(long window, long responder); } - public static final class NSView { - public static native void addSubview(long view, long subview); - public static native void removeFromSuperview(long view); + static final class NSView { + static native void addSubview(long view, long subview); + static native void removeFromSuperview(long view); - public static native void setFrame(long view, int x, int y, int w, int h); - public static native long window(long view); + static native void setFrame(long view, int x, int y, int w, int h); + static native long window(long view); - public static native void setToolTip(long view, String msg); - public static native void setHidden(long view, boolean hidden); + static native void setHidden(long view, boolean hidden); + + static native void setToolTip(long view, String msg); } - public static final class NSColor { - public static native long clearColor(); + static final class NSColor { + static native long clearColor(); } }
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Fri Jul 03 18:58:03 2015 +0100 @@ -143,25 +143,14 @@ return new AppleSpecificColor(color); } + // This is only called from native code. static void systemColorsChanged() { - // This is only called from native code. - EventQueue.invokeLater(new Runnable() { - public void run() { - AccessController.doPrivileged (new PrivilegedAction<Object>() { - public Object run() { - try { - final Method updateColorsMethod = SystemColor.class.getDeclaredMethod("updateSystemColors", new Class[0]); - updateColorsMethod.setAccessible(true); - updateColorsMethod.invoke(null, new Object[0]); - } catch (final Throwable e) { - e.printStackTrace(); - // swallow this if something goes horribly wrong - } - return null; - } - }); - } - }); + EventQueue.invokeLater(() -> { + AccessController.doPrivileged ((PrivilegedAction<Object>) () -> { + AWTAccessor.getSystemColorAccessor().updateSystemColors(); + return null; + }); + }); } public static LWCToolkit getLWCToolkit() { @@ -698,7 +687,7 @@ /* * Returns true if the application (one of its windows) owns keyboard focus. */ - public native boolean isApplicationActive(); + native boolean isApplicationActive(); /************************ * Native methods section
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/macosx/classes/sun/lwawt/macosx/NSEvent.java Fri Jul 03 18:58:03 2015 +0100 @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.lwawt.macosx; + +import java.awt.event.*; + +/** + * A class representing Cocoa NSEvent class with the fields only necessary for + * JDK functionality. + */ +final class NSEvent { + private int type; + private int modifierFlags; + + // Mouse event information + private int clickCount; + private int buttonNumber; + private int x; + private int y; + private double scrollDeltaY; + private double scrollDeltaX; + private int absX; + private int absY; + + // Key event information + private short keyCode; + private String charactersIgnoringModifiers; + + // Called from native + NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) { + this.type = type; + this.modifierFlags = modifierFlags; + this.keyCode = keyCode; + this.charactersIgnoringModifiers = charactersIgnoringModifiers; + } + + // Called from native + NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, + int x, int y, int absX, int absY, + double scrollDeltaY, double scrollDeltaX) { + this.type = type; + this.modifierFlags = modifierFlags; + this.clickCount = clickCount; + this.buttonNumber = buttonNumber; + this.x = x; + this.y = y; + this.absX = absX; + this.absY = absY; + this.scrollDeltaY = scrollDeltaY; + this.scrollDeltaX = scrollDeltaX; + } + + int getType() { + return type; + } + + int getModifierFlags() { + return modifierFlags; + } + + int getClickCount() { + return clickCount; + } + + int getButtonNumber() { + return buttonNumber; + } + + int getX() { + return x; + } + + int getY() { + return y; + } + + double getScrollDeltaY() { + return scrollDeltaY; + } + + double getScrollDeltaX() { + return scrollDeltaX; + } + + int getAbsX() { + return absX; + } + + int getAbsY() { + return absY; + } + + short getKeyCode() { + return keyCode; + } + + String getCharactersIgnoringModifiers() { + return charactersIgnoringModifiers; + } + + @Override + public String toString() { + return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," + + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," + + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ," + + getCharactersIgnoringModifiers() + "]"; + } + + /* + * Converts an NSEvent button number to a MouseEvent constant. + */ + static int nsToJavaButton(int buttonNumber) { + int jbuttonNumber = buttonNumber + 1; + switch (buttonNumber) { + case CocoaConstants.kCGMouseButtonLeft: + jbuttonNumber = MouseEvent.BUTTON1; + break; + case CocoaConstants.kCGMouseButtonRight: + jbuttonNumber = MouseEvent.BUTTON3; + break; + case CocoaConstants.kCGMouseButtonCenter: + jbuttonNumber = MouseEvent.BUTTON2; + break; + } + return jbuttonNumber; + } + + /* + * Converts NPCocoaEvent types to AWT event types. + */ + static int npToJavaEventType(int npEventType) { + int jeventType = 0; + switch (npEventType) { + case CocoaConstants.NPCocoaEventMouseDown: + jeventType = MouseEvent.MOUSE_PRESSED; + break; + case CocoaConstants.NPCocoaEventMouseUp: + jeventType = MouseEvent.MOUSE_RELEASED; + break; + case CocoaConstants.NPCocoaEventMouseMoved: + jeventType = MouseEvent.MOUSE_MOVED; + break; + case CocoaConstants.NPCocoaEventMouseEntered: + jeventType = MouseEvent.MOUSE_ENTERED; + break; + case CocoaConstants.NPCocoaEventMouseExited: + jeventType = MouseEvent.MOUSE_EXITED; + break; + case CocoaConstants.NPCocoaEventMouseDragged: + jeventType = MouseEvent.MOUSE_DRAGGED; + break; + case CocoaConstants.NPCocoaEventKeyDown: + jeventType = KeyEvent.KEY_PRESSED; + break; + case CocoaConstants.NPCocoaEventKeyUp: + jeventType = KeyEvent.KEY_RELEASED; + break; + } + return jeventType; + } + + /* + * Converts NSEvent types to AWT event types. + */ + static int nsToJavaEventType(int nsEventType) { + int jeventType = 0; + switch (nsEventType) { + case CocoaConstants.NSLeftMouseDown: + case CocoaConstants.NSRightMouseDown: + case CocoaConstants.NSOtherMouseDown: + jeventType = MouseEvent.MOUSE_PRESSED; + break; + case CocoaConstants.NSLeftMouseUp: + case CocoaConstants.NSRightMouseUp: + case CocoaConstants.NSOtherMouseUp: + jeventType = MouseEvent.MOUSE_RELEASED; + break; + case CocoaConstants.NSMouseMoved: + jeventType = MouseEvent.MOUSE_MOVED; + break; + case CocoaConstants.NSLeftMouseDragged: + case CocoaConstants.NSRightMouseDragged: + case CocoaConstants.NSOtherMouseDragged: + jeventType = MouseEvent.MOUSE_DRAGGED; + break; + case CocoaConstants.NSMouseEntered: + jeventType = MouseEvent.MOUSE_ENTERED; + break; + case CocoaConstants.NSMouseExited: + jeventType = MouseEvent.MOUSE_EXITED; + break; + case CocoaConstants.NSScrollWheel: + jeventType = MouseEvent.MOUSE_WHEEL; + break; + case CocoaConstants.NSKeyDown: + jeventType = KeyEvent.KEY_PRESSED; + break; + case CocoaConstants.NSKeyUp: + jeventType = KeyEvent.KEY_RELEASED; + break; + } + return jeventType; + } + + /* + * Converts NSEvent mouse modifiers to AWT mouse modifiers. + */ + static native int nsToJavaMouseModifiers(int buttonNumber, + int modifierFlags); + + /* + * Converts NSEvent key modifiers to AWT key modifiers. + */ + static native int nsToJavaKeyModifiers(int modifierFlags); + + /* + * Converts NSEvent key info to AWT key info. + */ + static native boolean nsToJavaKeyInfo(int[] in, int[] out); + + /* + * Converts NSEvent key modifiers to AWT key info. + */ + static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out); + + /* + * There is a small number of NS characters that need to be converted + * into other characters before we pass them to AWT. + */ + static native char nsToJavaChar(char nsChar, int modifierFlags); + + static boolean isPopupTrigger(int jmodifiers) { + final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0); + final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0); + final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0); + return isRightButtonDown || (isControlDown && isLeftButtonDown); + } +}
--- a/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java Fri Jul 03 17:47:52 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.lwawt.macosx.event; - -import sun.lwawt.macosx.CocoaConstants; -import java.awt.event.*; - -/** - * A class representing Cocoa NSEvent class with the fields only necessary for - * JDK functionality. - */ -public final class NSEvent { - private int type; - private int modifierFlags; - - // Mouse event information - private int clickCount; - private int buttonNumber; - private int x; - private int y; - private double scrollDeltaY; - private double scrollDeltaX; - private int absX; - private int absY; - - // Key event information - private short keyCode; - private String characters; - private String charactersIgnoringModifiers; - - public NSEvent(int type, int modifierFlags, short keyCode, String characters, String charactersIgnoringModifiers) { - this.type = type; - this.modifierFlags = modifierFlags; - this.keyCode = keyCode; - this.characters = characters; - this.charactersIgnoringModifiers = charactersIgnoringModifiers; - } - - public NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber, - int x, int y, int absX, int absY, - double scrollDeltaY, double scrollDeltaX) { - this.type = type; - this.modifierFlags = modifierFlags; - this.clickCount = clickCount; - this.buttonNumber = buttonNumber; - this.x = x; - this.y = y; - this.absX = absX; - this.absY = absY; - this.scrollDeltaY = scrollDeltaY; - this.scrollDeltaX = scrollDeltaX; - } - - public int getType() { - return type; - } - - public int getModifierFlags() { - return modifierFlags; - } - - public int getClickCount() { - return clickCount; - } - - public int getButtonNumber() { - return buttonNumber; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public double getScrollDeltaY() { - return scrollDeltaY; - } - - public double getScrollDeltaX() { - return scrollDeltaX; - } - - public int getAbsX() { - return absX; - } - - public int getAbsY() { - return absY; - } - - public short getKeyCode() { - return keyCode; - } - - public String getCharactersIgnoringModifiers() { - return charactersIgnoringModifiers; - } - - public String getCharacters() { - return characters; - } - - @Override - public String toString() { - return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," - + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," - + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ," - + getCharacters() + " ," + getCharactersIgnoringModifiers() + "]"; - } - - /* - * Converts an NSEvent button number to a MouseEvent constant. - */ - public static int nsToJavaButton(int buttonNumber) { - int jbuttonNumber = buttonNumber + 1; - switch (buttonNumber) { - case CocoaConstants.kCGMouseButtonLeft: - jbuttonNumber = MouseEvent.BUTTON1; - break; - case CocoaConstants.kCGMouseButtonRight: - jbuttonNumber = MouseEvent.BUTTON3; - break; - case CocoaConstants.kCGMouseButtonCenter: - jbuttonNumber = MouseEvent.BUTTON2; - break; - } - return jbuttonNumber; - } - - /* - * Converts NPCocoaEvent types to AWT event types. - */ - public static int npToJavaEventType(int npEventType) { - int jeventType = 0; - switch (npEventType) { - case CocoaConstants.NPCocoaEventMouseDown: - jeventType = MouseEvent.MOUSE_PRESSED; - break; - case CocoaConstants.NPCocoaEventMouseUp: - jeventType = MouseEvent.MOUSE_RELEASED; - break; - case CocoaConstants.NPCocoaEventMouseMoved: - jeventType = MouseEvent.MOUSE_MOVED; - break; - case CocoaConstants.NPCocoaEventMouseEntered: - jeventType = MouseEvent.MOUSE_ENTERED; - break; - case CocoaConstants.NPCocoaEventMouseExited: - jeventType = MouseEvent.MOUSE_EXITED; - break; - case CocoaConstants.NPCocoaEventMouseDragged: - jeventType = MouseEvent.MOUSE_DRAGGED; - break; - case CocoaConstants.NPCocoaEventKeyDown: - jeventType = KeyEvent.KEY_PRESSED; - break; - case CocoaConstants.NPCocoaEventKeyUp: - jeventType = KeyEvent.KEY_RELEASED; - break; - } - return jeventType; - } - - /* - * Converts NSEvent types to AWT event types. - */ - public static int nsToJavaEventType(int nsEventType) { - int jeventType = 0; - switch (nsEventType) { - case CocoaConstants.NSLeftMouseDown: - case CocoaConstants.NSRightMouseDown: - case CocoaConstants.NSOtherMouseDown: - jeventType = MouseEvent.MOUSE_PRESSED; - break; - case CocoaConstants.NSLeftMouseUp: - case CocoaConstants.NSRightMouseUp: - case CocoaConstants.NSOtherMouseUp: - jeventType = MouseEvent.MOUSE_RELEASED; - break; - case CocoaConstants.NSMouseMoved: - jeventType = MouseEvent.MOUSE_MOVED; - break; - case CocoaConstants.NSLeftMouseDragged: - case CocoaConstants.NSRightMouseDragged: - case CocoaConstants.NSOtherMouseDragged: - jeventType = MouseEvent.MOUSE_DRAGGED; - break; - case CocoaConstants.NSMouseEntered: - jeventType = MouseEvent.MOUSE_ENTERED; - break; - case CocoaConstants.NSMouseExited: - jeventType = MouseEvent.MOUSE_EXITED; - break; - case CocoaConstants.NSScrollWheel: - jeventType = MouseEvent.MOUSE_WHEEL; - break; - case CocoaConstants.NSKeyDown: - jeventType = KeyEvent.KEY_PRESSED; - break; - case CocoaConstants.NSKeyUp: - jeventType = KeyEvent.KEY_RELEASED; - break; - } - return jeventType; - } - - /* - * Converts NSEvent mouse modifiers to AWT mouse modifiers. - */ - public static native int nsToJavaMouseModifiers(int buttonNumber, - int modifierFlags); - - /* - * Converts NSEvent key modifiers to AWT key modifiers. - */ - public static native int nsToJavaKeyModifiers(int modifierFlags); - - /* - * Converts NSEvent key info to AWT key info. - */ - public static native boolean nsToJavaKeyInfo(int[] in, int[] out); - - /* - * Converts NSEvent key modifiers to AWT key info. - */ - public static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out); - - /* - * There is a small number of NS characters that need to be converted - * into other characters before we pass them to AWT. - */ - public static native char nsToJavaChar(char nsChar, int modifierFlags); - - public static boolean isPopupTrigger(int jmodifiers) { - final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0); - final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0); - final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0); - return isRightButtonDown || (isControlDown && isLeftButtonDown); - } -}
--- a/src/macosx/native/sun/awt/AWTEvent.m Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/native/sun/awt/AWTEvent.m Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1019,12 +1019,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaMouseModifiers * Signature: (II)I */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaMouseModifiers +Java_sun_lwawt_macosx_NSEvent_nsToJavaMouseModifiers (JNIEnv *env, jclass cls, jint buttonNumber, jint modifierFlags) { jint jmodifiers = 0; @@ -1039,12 +1039,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaKeyModifiers * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyModifiers +Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyModifiers (JNIEnv *env, jclass cls, jint modifierFlags) { jint jmodifiers = 0; @@ -1059,12 +1059,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaKeyInfo * Signature: ([I[I)Z */ JNIEXPORT jboolean JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyInfo +Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyInfo (JNIEnv *env, jclass cls, jintArray inData, jintArray outData) { BOOL postsTyped = NO; @@ -1101,12 +1101,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsKeyModifiersToJavaKeyInfo * Signature: ([I[I)V */ JNIEXPORT void JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsKeyModifiersToJavaKeyInfo +Java_sun_lwawt_macosx_NSEvent_nsKeyModifiersToJavaKeyInfo (JNIEnv *env, jclass cls, jintArray inData, jintArray outData) { JNF_COCOA_ENTER(env); @@ -1139,12 +1139,12 @@ } /* - * Class: sun_lwawt_macosx_event_NSEvent + * Class: sun_lwawt_macosx_NSEvent * Method: nsToJavaChar * Signature: (CI)C */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar +Java_sun_lwawt_macosx_NSEvent_nsToJavaChar (JNIEnv *env, jclass cls, char nsChar, jint modifierFlags) { jchar javaChar = 0;
--- a/src/macosx/native/sun/awt/AWTView.m Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/native/sun/awt/AWTView.m Fri Jul 03 18:58:03 2015 +0100 @@ -364,7 +364,7 @@ clickCount = [event clickCount]; } - static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V"); jobject jEvent = JNFNewObject(env, jctor_NSEvent, [event type], @@ -381,7 +381,7 @@ } static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); - static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent); } @@ -431,7 +431,7 @@ charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]); } - static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;Ljava/lang/String;)V"); jobject jevent = JNFNewObject(env, jctor_NSEvent, [event type], @@ -442,7 +442,7 @@ static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView, - "deliverKeyEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + "deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent); if (characters != NULL) {
--- a/src/macosx/native/sun/awt/CTrayIcon.m Fri Jul 03 17:47:52 2015 +0100 +++ b/src/macosx/native/sun/awt/CTrayIcon.m Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,7 +135,7 @@ clickCount = [event clickCount]; - static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V"); jobject jEvent = JNFNewObject(env, jctor_NSEvent, [event type], @@ -152,7 +152,7 @@ } static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon"); - static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent); }
--- a/src/share/classes/java/awt/SystemColor.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/share/classes/java/awt/SystemColor.java Fri Jul 03 18:58:03 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ */ package java.awt; +import sun.awt.AWTAccessor; + import java.io.ObjectStreamException; /** @@ -457,7 +459,13 @@ }; static { - updateSystemColors(); + AWTAccessor.setSystemColorAccessor( + new AWTAccessor.SystemColorAccessor() { + public void updateSystemColors() { + SystemColor.updateSystemColors(); + } + }); + updateSystemColors(); } /**
--- a/src/share/classes/sun/awt/AWTAccessor.java Fri Jul 03 17:47:52 2015 +0100 +++ b/src/share/classes/sun/awt/AWTAccessor.java Fri Jul 03 18:58:03 2015 +0100 @@ -737,6 +737,13 @@ } /* + * An accessor object for the SystemColor class + */ + public interface SystemColorAccessor { + void updateSystemColors(); + } + + /* * Accessor instances are initialized in the static initializers of * corresponding AWT classes by using setters defined below. */ @@ -764,6 +771,7 @@ private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor; private static SequencedEventAccessor sequencedEventAccessor; private static InvocationEventAccessor invocationEventAccessor; + private static SystemColorAccessor systemColorAccessor; private static ToolkitAccessor toolkitAccessor; private static AccessibleContextAccessor accessibleContextAccessor; @@ -1193,6 +1201,24 @@ return invocationEventAccessor; } + /* + * Get the accessor object for the java.awt.SystemColor class. + */ + public static SystemColorAccessor getSystemColorAccessor() { + if (systemColorAccessor == null) { + unsafe.ensureClassInitialized(SystemColor.class); + } + + return systemColorAccessor; + } + + /* + * Set the accessor object for the java.awt.SystemColor class. + */ + public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) { + AWTAccessor.systemColorAccessor = systemColorAccessor; + } + /* * Get the accessor object for the javax.accessibility.AccessibleContext class.