Title: [106000] trunk/Source/WebKit2
- Revision
- 106000
- Author
- carlo...@webkit.org
- Date
- 2012-01-26 07:03:50 -0800 (Thu, 26 Jan 2012)
Log Message
[GTK][WK2] Primary clipboard should be updated with the current selection in X11 platforms
https://bugs.webkit.org/show_bug.cgi?id=77097
Reviewed by Martin Robinson.
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::respondToChangedSelection): Call
setSelectionPrimaryClipboardIfNeeded() to update primary clipboard
in X11 platforms.
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::collapseSelection): Callback called when clearing
clipboard contents.
(WebKit::WebEditorClient::setSelectionPrimaryClipboardIfNeeded):
Updaye primary clipboard with the current selection.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (105999 => 106000)
--- trunk/Source/WebKit2/ChangeLog 2012-01-26 14:56:34 UTC (rev 105999)
+++ trunk/Source/WebKit2/ChangeLog 2012-01-26 15:03:50 UTC (rev 106000)
@@ -1,3 +1,21 @@
+2012-01-26 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK][WK2] Primary clipboard should be updated with the current selection in X11 platforms
+ https://bugs.webkit.org/show_bug.cgi?id=77097
+
+ Reviewed by Martin Robinson.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::respondToChangedSelection): Call
+ setSelectionPrimaryClipboardIfNeeded() to update primary clipboard
+ in X11 platforms.
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+ * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+ (WebKit::collapseSelection): Callback called when clearing
+ clipboard contents.
+ (WebKit::WebEditorClient::setSelectionPrimaryClipboardIfNeeded):
+ Updaye primary clipboard with the current selection.
+
2012-01-26 Zeno Albisser <z...@webkit.org>
[Qt][WK2] Use QVariant for payload data in application URL schemes.
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (105999 => 106000)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2012-01-26 14:56:34 UTC (rev 105999)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2012-01-26 15:03:50 UTC (rev 106000)
@@ -195,9 +195,11 @@
unsigned start;
unsigned end;
m_page->send(Messages::WebPageProxy::DidChangeCompositionSelection(frame->editor()->getCompositionSelection(start, end)));
+#elif PLATFORM(GTK)
+ setSelectionPrimaryClipboardIfNeeded(frame);
#endif
}
-
+
void WebEditorClient::didEndEditing()
{
DEFINE_STATIC_LOCAL(String, WebViewDidEndEditingNotification, ("WebViewDidEndEditingNotification"));
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (105999 => 106000)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h 2012-01-26 14:56:34 UTC (rev 105999)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h 2012-01-26 15:03:50 UTC (rev 106000)
@@ -121,6 +121,7 @@
#if PLATFORM(GTK)
bool executePendingEditorCommands(WebCore::Frame*, Vector<WTF::String>, bool) OVERRIDE;
void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&) OVERRIDE;
+ void setSelectionPrimaryClipboardIfNeeded(WebCore::Frame*) OVERRIDE;
#endif
TextCheckerClient* textChecker() OVERRIDE { return this; }
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (105999 => 106000)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2012-01-26 14:56:34 UTC (rev 105999)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2012-01-26 15:03:50 UTC (rev 106000)
@@ -25,7 +25,9 @@
#include "WebPage.h"
#include "WebPageProxyMessages.h"
#include "WebProcess.h"
+#include <WebCore/DataObjectGtk.h>
#include <WebCore/KeyboardEvent.h>
+#include <WebCore/PasteboardHelper.h>
#include <WebCore/NotImplemented.h>
using namespace WebCore;
@@ -127,4 +129,38 @@
notImplemented();
}
+#if PLATFORM(X11)
+static Frame* frameSettingClipboard;
+static void collapseSelection(GtkClipboard* clipboard, Frame* frame)
+{
+ if (frameSettingClipboard && frameSettingClipboard == frame)
+ return;
+
+ // Collapse the selection without clearing it.
+ ASSERT(frame);
+ frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity());
}
+#endif
+
+void WebEditorClient::setSelectionPrimaryClipboardIfNeeded(Frame* frame)
+{
+#if PLATFORM(X11)
+ GtkClipboard* clipboard = PasteboardHelper::defaultPasteboardHelper()->getPrimarySelectionClipboard(frame);
+ DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
+
+ if (!frame->selection()->isRange())
+ return;
+
+ dataObject->clearAll();
+ dataObject->setRange(frame->selection()->toNormalizedRange());
+
+ frameSettingClipboard = frame;
+ GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0);
+ g_closure_set_marshal(callback, g_cclosure_marshal_VOID__VOID);
+ PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard, PasteboardHelper::DoNotIncludeSmartPaste, callback);
+ frameSettingClipboard = 0;
+#endif
+}
+
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes