From 27f3d73d16b6b041e06a39451d2cda51562ce1c6 Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Tue, 21 Jul 2009 01:21:54 +0000 Subject: Support pasting text from a clipboard that has no published targets. BUG=16887 TEST=paste from intellij into chrome render view Review URL: http://codereview.chromium.org/159107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21142 0039d316-1c4b-4281-b951-d872f2087c98 --- tools/gtk_clipboard_dump/gtk_clipboard_dump.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc index f0f6016..a064792 100644 --- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc +++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc @@ -11,9 +11,17 @@ namespace { void PrintClipboardContents(GtkClipboard* clip) { GdkAtom* targets; int num_targets = 0; - gtk_clipboard_wait_for_targets(clip, &targets, &num_targets); - printf("Available targets:\n---------------\n"); + // This call is bugged, the cache it checks is often stale; see + // . + // gtk_clipboard_wait_for_targets(clip, &targets, &num_targets); + + GtkSelectionData* target_data = + gtk_clipboard_wait_for_contents(clip, + gdk_atom_intern("TARGETS", false)); + gtk_selection_data_get_targets(target_data, &targets, &num_targets); + + printf("%d available targets:\n---------------\n", num_targets); for (int i = 0; i < num_targets; i++) { printf(" [format: %s", gdk_atom_name(targets[i])); @@ -41,6 +49,15 @@ void PrintClipboardContents(GtkClipboard* clip) { } printf("\n\n"); } + + if (num_targets <= 0) { + printf("No targets advertised. Text is: "); + gchar* text = gtk_clipboard_wait_for_text(clip); + printf("%s\n", text ? text : "NULL"); + g_free(text); + } + + g_free(targets); } } -- cgit v1.1