src/macosx/classes/sun/lwawt/macosx/CClipboard.java
Print this page
@@ -55,10 +55,22 @@
protected void clearNativeContext() {
// Leaving Empty, as WClipboard.clearNativeContext is empty as well.
}
@Override
+ public synchronized Transferable getContents(Object requestor) {
+ checkPasteboardAndNotify();
+ return super.getContents(requestor);
+ }
+
+ @Override
+ protected synchronized Transferable getContextContents() {
+ checkPasteboardAndNotify();
+ return super.getContextContents();
+ }
+
+ @Override
protected void setContentsNative(Transferable contents) {
FlavorTable flavorMap = getDefaultFlavorTable();
// Don't use delayed Clipboard rendering for the Transferable's data.
// If we did that, we would call Transferable.getTransferData on
// the Toolkit thread, which is a security hole.
@@ -114,17 +126,24 @@
//protected Transferable createLocaleTransferable(long[] formats) throws IOException;
private native void declareTypes(long[] formats, SunClipboard newOwner);
private native void setData(byte[] data, long format);
+ void checkPasteboardAndNotify() {
+ if (checkPasteboardWithoutNotification()) {
+ notifyChanged();
+ lostOwnershipNow(null);
+ }
+ }
+
/**
* 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 boolean checkPasteboardWithoutNotification();
/*** Native Callbacks ***/
private void notifyLostOwnership() {
lostOwnershipImpl();
}