summaryrefslogtreecommitdiff
path: root/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-03-09 21:29:57 +0000
committerMark Wielaard <mark@klomp.org>2006-03-09 21:29:57 +0000
commit232161582a6d0a1a6971a69e6e8bf928ae2fe2d8 (patch)
tree1c787e5351757d71f6953bd19f32f658d08d95de /gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
parent818ac8d746bf3fdbd58519c5990f5277e11ed5f1 (diff)
downloadclasspath-232161582a6d0a1a6971a69e6e8bf928ae2fe2d8.tar.gz
* gnu/java/awt/peer/gtk/GtkClipboard.java (clipboard, selection):
New static field. (stringMimeType, imageMimeType, filesMimeType): Initialize directly. (canCache): Likewise. (GtkClipboard): Take String argument. (getInstance): Removed. (getClipboardInstance, getSelectionInstance): New static methods. (setSystemContents): Make synchronized. Takes boolean argument. (initNativeState): Add clipboard and selection. * gnu/java/awt/peer/gtk/GtkClipboardNotifier.java (announceClipboardChange, announcePrimaryChange): New static field. (announce): Take GtkClipboard as argument. (run): Check which clipboard to announce change for. * gnu/java/awt/peer/gtk/GtkSelection.java (clipboard): New final boolean field. (GtkSelection): Take GtkClipboard as argument. (requestText, requestImage, requestURIs, requestBytes): Add boolean clipboard argument. (requestMimeTypes): Likewise. * gnu/java/awt/peer/gtk/GtkToolkit.java (getSystemSelection): New method. * java/awt/Toolkit.java (getSystemSelection): Document. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c (cp_gtk_selection_instance): New var. (current_selection, owner): Removed. (clipboard_owner_change_cb): Use clipboard argument. (initNativeState): Store clipboard and selection instances. Cache setSystemContentsID, provideContentID, provideTextID, provideImageID, and provideURIsID. (clipboard_get_func): Use clipboard argument. (clipboard_clear_func): Likewise. Always call method. (advertiseContent): Don't cache method ids here. Check whether to use clpboard or selection. Don't set owner or current_selection. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkSelection.c (requestText, requestImage, requestURIs, requestBytes): Use extra boolean argument to select clipboard. * native/jni/gtk-peer/gtkpeer.h (cp_gtk_selection): New extern. (cp_gtk_clipboard_instance, cp_gtk_selection_instance): Likewise. * include/gnu_java_awt_peer_gtk_GtkClipboard.h: Regenerate. * include/gnu_java_awt_peer_gtk_GtkSelection.h: Likewise.
Diffstat (limited to 'gnu/java/awt/peer/gtk/GtkClipboardNotifier.java')
-rw-r--r--gnu/java/awt/peer/gtk/GtkClipboardNotifier.java36
1 files changed, 28 insertions, 8 deletions
diff --git a/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java b/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
index a470fe171..fdc7d50c5 100644
--- a/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
+++ b/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
@@ -39,11 +39,15 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.datatransfer.*;
+import java.util.*;
class GtkClipboardNotifier extends Thread
{
- /** Whether or not to announce a GtkSelection change. */
- private static boolean announceChange;
+ /** Whether to announce a new GtkSelection has been set for CLIPBOARD. */
+ static private boolean announceClipboardChange;
+
+ /** Whether to announce a new GtkSelection has been set for PRIMARY. */
+ static private boolean announcePrimaryChange;
/**
* The one and only instance. All operations are synchronized on
@@ -64,24 +68,30 @@ class GtkClipboardNotifier extends Thread
/**
* Notifies that a new GtkSelection has to be announced.
+ *
+ * @param clipboard either the GtkClipboard.clipboard or the
+ * GtkClipboard.selection.
*/
- static void announce()
+ static void announce(GtkClipboard clipboard)
{
synchronized (notifier)
{
- announceChange = true;
+ if (clipboard == GtkClipboard.clipboard)
+ announceClipboardChange = true;
+ else
+ announcePrimaryChange = true;
notifier.notifyAll();
}
}
public void run()
{
- final GtkClipboard clipboard = GtkClipboard.getInstance();
+ GtkClipboard clipboard;
while (true)
{
synchronized (this)
{
- while (!announceChange)
+ while (! announceClipboardChange && ! announcePrimaryChange)
{
try
{
@@ -92,14 +102,24 @@ class GtkClipboardNotifier extends Thread
// ignore
}
}
- announceChange = false;
+
+ if (announceClipboardChange)
+ {
+ clipboard = GtkClipboard.clipboard;
+ announceClipboardChange = false;
+ }
+ else
+ {
+ clipboard = GtkClipboard.selection;
+ announcePrimaryChange = false;
+ }
}
// Do the actual announcement without the lock held. We will
// notice a new change after this notification has finished.
try
{
- clipboard.setContents(new GtkSelection(), null);
+ clipboard.setContents(new GtkSelection(clipboard), null);
}
catch (Throwable t)
{