summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk
diff options
context:
space:
mode:
authorPraveen Innamuri <pinnamuri>2010-01-11 19:58:29 +0000
committerPraveen Innamuri <pinnamuri>2010-01-11 19:58:29 +0000
commit4d31b031f22f671d3489ec4b4439aa6b6fd64fd2 (patch)
tree28b8a32d96d7cbfaf7b7617756007d3a1e9fc2a5 /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk
parent0e7c8114dcba88700a100accc611254714e88137 (diff)
downloadeclipse.platform.swt-4d31b031f22f671d3489ec4b4439aa6b6fd64fd2.tar.gz
eclipse.platform.swt-4d31b031f22f671d3489ec4b4439aa6b6fd64fd2.tar.xz
eclipse.platform.swt-4d31b031f22f671d3489ec4b4439aa6b6fd64fd2.zip
153809 - [Clipboard] Copy / Cut on Linux is very flakey with 3.2
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ClipboardProxy.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ClipboardProxy.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ClipboardProxy.java
index 6e122cc0ed..69e121b97b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ClipboardProxy.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ClipboardProxy.java
@@ -37,6 +37,7 @@ class ClipboardProxy {
Callback clearFunc;
static String ID = "CLIPBOARD PROXY OBJECT"; //$NON-NLS-1$
+ static int /*long*/ clipboardOwner = OS.gtk_window_new(0);
static ClipboardProxy _getInstance(final Display display) {
ClipboardProxy proxy = (ClipboardProxy) display.getData(ID);
@@ -98,6 +99,7 @@ void dispose () {
clipboardDataTypes = null;
primaryClipboardData = null;
primaryClipboardDataTypes = null;
+ clipboardOwner = 0;
}
/**
@@ -158,23 +160,31 @@ boolean setData(Clipboard owner, Object[] data, Transfer[] dataTypes, int clipbo
offset += GtkTargetEntry.sizeof;
}
if ((clipboards & DND.CLIPBOARD) != 0) {
- if (activeClipboard != null) OS.gtk_clipboard_clear(Clipboard.GTKCLIPBOARD);
clipboardData = data;
clipboardDataTypes = dataTypes;
int /*long*/ getFuncProc = getFunc.getAddress();
int /*long*/ clearFuncProc = clearFunc.getAddress();
- if (!OS.gtk_clipboard_set_with_data(Clipboard.GTKCLIPBOARD, pTargetsList, entries.length, getFuncProc, clearFuncProc, 0)) {
+ /*
+ * Feature in GTK. When the contents are set again, clipboard_set_with_data()
+ * invokes clearFunc and then, getFunc is not sequentially called.
+ * If we clear the content before calling set_with_data(), then there is a fair
+ * chance for other apps like Klipper to claim the ownership of the clipboard.
+ * The fix is to make sure that the content is not cleared before the data is
+ * set again. GTK does not invoke clearFunc for clipboard_set_with_owner()
+ * though we set the data again. So, this API has to be used whenever we
+ * are setting the contents.
+ */
+ if (!OS.gtk_clipboard_set_with_owner (Clipboard.GTKCLIPBOARD, pTargetsList, entries.length, getFuncProc, clearFuncProc, clipboardOwner)) {
return false;
}
activeClipboard = owner;
}
if ((clipboards & DND.SELECTION_CLIPBOARD) != 0) {
- if (activePrimaryClipboard != null) OS.gtk_clipboard_clear(Clipboard.GTKPRIMARYCLIPBOARD);
primaryClipboardData = data;
primaryClipboardDataTypes = dataTypes;
int /*long*/ getFuncProc = getFunc.getAddress();
int /*long*/ clearFuncProc = clearFunc.getAddress();
- if (!OS.gtk_clipboard_set_with_data(Clipboard.GTKPRIMARYCLIPBOARD, pTargetsList, entries.length, getFuncProc, clearFuncProc, 0)) {
+ if (!OS.gtk_clipboard_set_with_owner (Clipboard.GTKPRIMARYCLIPBOARD, pTargetsList, entries.length, getFuncProc, clearFuncProc, clipboardOwner)) {
return false;
}
activePrimaryClipboard = owner;