diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-18 17:29:21 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-18 17:29:21 +0000 |
| commit | 64089cc9f030d8ef7972adb5d117e0b23f47d62b (patch) | |
| tree | 9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java | |
| parent | 96034e28360d660d7a7708807fcbc4b519574d8e (diff) | |
| download | ppe42-gcc-64089cc9f030d8ef7972adb5d117e0b23f47d62b.tar.gz ppe42-gcc-64089cc9f030d8ef7972adb5d117e0b23f47d62b.zip | |
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113887 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java')
| -rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java | 97 |
1 files changed, 63 insertions, 34 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java index a502e1fd6ef..f520fe224b1 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboard.java @@ -1,5 +1,5 @@ /* GtkClipboard.java - Copyright (C) 1999, 2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,59 +48,85 @@ import java.util.Iterator; public class GtkClipboard extends Clipboard { + /** + * The one and only gtk+ clipboard instance for the CLIPBOARD selection. + */ + final static GtkClipboard clipboard = new GtkClipboard("System Clipboard"); + + /** + * The one and only gtk+ clipboard instance for the PRIMARY selection. + */ + final static GtkClipboard selection = new GtkClipboard("System Selection"); // Given to the native side so it can signal special targets that // can be converted to one of the special predefined DataFlavors. - static final String stringMimeType; - static final String imageMimeType; - static final String filesMimeType; + static final String stringMimeType + = DataFlavor.stringFlavor.getMimeType(); + static final String imageMimeType + = DataFlavor.imageFlavor.getMimeType(); + static final String filesMimeType + = DataFlavor.javaFileListFlavor.getMimeType(); // Indicates whether the results of the clipboard selection can be // cached by GtkSelection. True if // gdk_display_supports_selection_notification. - static final boolean canCache; - - static - { - stringMimeType = DataFlavor.stringFlavor.getMimeType(); - imageMimeType = DataFlavor.imageFlavor.getMimeType(); - filesMimeType = DataFlavor.javaFileListFlavor.getMimeType(); - - canCache = initNativeState(stringMimeType, imageMimeType, filesMimeType); - } - - /** - * The one and only gtk+ clipboard instance. - */ - private static GtkClipboard instance = new GtkClipboard(); + static final boolean canCache = initNativeState(clipboard, selection, + stringMimeType, + imageMimeType, + filesMimeType); /** * Creates the clipboard and sets the initial contents to the * current gtk+ selection. */ - private GtkClipboard() + private GtkClipboard(String name) { - super("System Clipboard"); - setContents(new GtkSelection(), null); + super(name); + setContents(new GtkSelection(this), null); } /** - * Returns the one and only GtkClipboard instance. + * Returns the one and only GtkClipboard instance for the CLIPBOARD + * selection. */ + static GtkClipboard getClipboardInstance() + { + return clipboard; + } - static GtkClipboard getInstance() + /** + * Returns the one and only GtkClipboard instance for the PRIMARY + * selection. + */ + static GtkClipboard getSelectionInstance() { - return instance; + return selection; } /** * Sets the GtkSelection facade as new contents of the clipboard. * Called from gtk+ when another application grabs the clipboard and * we loose ownership. + * + * @param cleared If true this is a clear event (someone takes the + * clipboard from us) otherwise it is an owner changed event. */ - private static void setSystemContents() + private synchronized void setSystemContents(boolean cleared) { - GtkClipboardNotifier.announce(); + // We need to notify clipboard owner listeners when we were the + // owner (the selection was explictly set) and someone takes the + // clipboard away from us and asks us the clear any held storage, + // or if we weren't the owner of the clipboard to begin with, but + // the clipboard contents changed. We could refine this and check + // whether the actual available formats did in fact change, but we + // assume listeners will check for that anyway (and if possible we + // ask to cache the available formats so even if multiple + // listeners check after a notification the overhead should be + // minimal). + boolean owner = ! (contents instanceof GtkSelection); + boolean needNotification = (cleared && owner) || (! cleared && ! owner); + if (needNotification) + GtkClipboardNotifier.announce(this); } /** @@ -146,15 +172,12 @@ public class GtkClipboard extends Clipboard || flavor.isRepresentationClassReader()) text = true; - // XXX - We only support automatic image conversion for - // GtkImages at the moment. So explicitly check that we have - // one. if (! images && flavors[i].equals(DataFlavor.imageFlavor)) { try { Object o = contents.getTransferData(DataFlavor.imageFlavor); - if (o instanceof GtkImage) + if (o instanceof Image) images = true; } catch (UnsupportedFlavorException ufe) @@ -265,7 +288,11 @@ public class GtkClipboard extends Clipboard try { - return (GtkImage) contents.getTransferData(DataFlavor.imageFlavor); + Object o = contents.getTransferData(DataFlavor.imageFlavor); + if( o instanceof GtkImage ) + return (GtkImage) o; + else + return new GtkImage(((Image)o).getSource()); } catch (UnsupportedFlavorException ufe) { @@ -384,11 +411,13 @@ public class GtkClipboard extends Clipboard } /** - * Initializes the gtk+ clipboard and caches any native side + * Initializes the gtk+ clipboards and caches any native side * structures needed. Returns whether or not the contents of the * Clipboard can be cached (gdk_display_supports_selection_notification). */ - private static native boolean initNativeState(String stringTarget, + private static native boolean initNativeState(GtkClipboard clipboard, + GtkClipboard selection, + String stringTarget, String imageTarget, String filesTarget); } |

