Commit 0fad170a authored by xan@webkit.org's avatar xan@webkit.org

WebCore:

2009-05-13  Holger Hans Peter Freyther  <zecke@selfish.org>

        Reviewed by Xan Lopez.

        https://bugs.webkit.org/show_bug.cgi?id=25685
        [GTK] Middle click paste form the pasteboard

        The kit wants to paste from at least two different
        clipboards. By introducing getCurrentTarget to the
        PasteboardHelper interface we can make this decision
        in the kit.
        Use the new method in PasteboardGtk to get the right
        GdkClipboard for the paste operation.

        * platform/gtk/PasteboardGtk.cpp:
        (WebCore::Pasteboard::documentFragment):
        (WebCore::Pasteboard::plainText):
        * platform/gtk/PasteboardHelper.h:

WebKit/gtk:

2009-05-11  Holger Hans Peter Freyther  <zecke@selfish.org>

        Reviewed by Xan Lopez.

        https://bugs.webkit.org/show_bug.cgi?id=25685
        [GTK] Middle click paste form the pasteboard

        For paste from middle button (button==2) we want to use
        the GDK_PRIMARY_SELECTION. Implement the new getCurrentTarget
        method in PasteboardHelperGtk by asking the WebView which
        clipboard to use.

        * WebCoreSupport/PasteboardHelperGtk.cpp:
        (WebKit::PasteboardHelperGtk::getCurrentTarget):
        * WebCoreSupport/PasteboardHelperGtk.h:
        * webkit/webkitprivate.h:
        * webkit/webkitwebview.cpp:
        (webkit_web_view_button_press_event):
        (webkit_web_view_use_primary_for_paste):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0a818017
2009-05-13 Holger Hans Peter Freyther <zecke@selfish.org>
Reviewed by Xan Lopez.
https://bugs.webkit.org/show_bug.cgi?id=25685
[GTK] Middle click paste form the pasteboard
The kit wants to paste from at least two different
clipboards. By introducing getCurrentTarget to the
PasteboardHelper interface we can make this decision
in the kit.
Use the new method in PasteboardGtk to get the right
GdkClipboard for the paste operation.
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::documentFragment):
(WebCore::Pasteboard::plainText):
* platform/gtk/PasteboardHelper.h:
2009-05-13 Eric Carlson <eric.carlson@apple.com>
Reviewed by Darin Adler.
......@@ -162,7 +162,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
bool allowPlainText, bool& chosePlainText)
{
GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
GtkClipboard* clipboard = m_helper->getClipboard(frame);
GtkClipboard* clipboard = m_helper->getCurrentTarget(frame);
chosePlainText = false;
if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, textHtml)) {
......@@ -195,7 +195,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
String Pasteboard::plainText(Frame* frame)
{
GtkClipboard* clipboard = m_helper->getClipboard(frame);
GtkClipboard* clipboard = m_helper->getCurrentTarget(frame);
gchar* utf8 = gtk_clipboard_wait_for_text(clipboard);
......
/*
* Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com>
* Copyright (C) 2009 Holger Hans Peter Freyther
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
......@@ -37,6 +38,7 @@ class PasteboardHelper {
public:
virtual ~PasteboardHelper() {};
virtual GtkClipboard* getCurrentTarget(Frame*) const = 0;
virtual GtkClipboard* getClipboard(Frame*) const = 0;
virtual GtkClipboard* getPrimary(Frame*) const = 0;
virtual GtkTargetList* getCopyTargetList(Frame*) const = 0;
......
2009-05-11 Holger Hans Peter Freyther <zecke@selfish.org>
Reviewed by Xan Lopez.
https://bugs.webkit.org/show_bug.cgi?id=25685
[GTK] Middle click paste form the pasteboard
For paste from middle button (button==2) we want to use
the GDK_PRIMARY_SELECTION. Implement the new getCurrentTarget
method in PasteboardHelperGtk by asking the WebView which
clipboard to use.
* WebCoreSupport/PasteboardHelperGtk.cpp:
(WebKit::PasteboardHelperGtk::getCurrentTarget):
* WebCoreSupport/PasteboardHelperGtk.h:
* webkit/webkitprivate.h:
* webkit/webkitwebview.cpp:
(webkit_web_view_button_press_event):
(webkit_web_view_use_primary_for_paste):
2009-05-12 Jan Michael Alonzo <jmalonzo@webkit.org>
Reviewed by Holger Freyther.
......
/*
* Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com>
* Copyright (C) 2009 Holger Hans Peter Freyther
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -30,6 +31,16 @@ using namespace WebCore;
namespace WebKit {
GtkClipboard* PasteboardHelperGtk::getCurrentTarget(Frame* frame) const
{
WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame));
if (webkit_web_view_use_primary_for_paste(webView))
return getPrimary(frame);
else
return getClipboard(frame);
}
GtkClipboard* PasteboardHelperGtk::getClipboard(Frame* frame) const
{
WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame));
......
/*
* Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com>
* Copyright (C) 2009 Holger Hans Peter Freyther
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
......@@ -39,6 +40,7 @@ namespace WebKit {
class PasteboardHelperGtk : public PasteboardHelper {
public:
PasteboardHelperGtk() { }
virtual GtkClipboard* getCurrentTarget(Frame*) const;
virtual GtkClipboard* getClipboard(Frame*) const;
virtual GtkClipboard* getPrimary(Frame*) const;
virtual GtkTargetList* getCopyTargetList(Frame*) const;
......
......@@ -118,6 +118,7 @@ extern "C" {
char* customEncoding;
gboolean disposing;
gboolean usePrimaryForPaste;
};
#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
......@@ -211,6 +212,9 @@ extern "C" {
GSList*
webkit_web_settings_get_spell_languages(WebKitWebView* web_view);
bool
webkit_web_view_use_primary_for_paste(WebKitWebView* web_view);
}
#endif
......@@ -474,7 +474,23 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
if (!frame->view())
return FALSE;
return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
gboolean result = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
#if PLATFORM(X11)
/* Copy selection to the X11 selection clipboard */
if (event->button == 2) {
bool primary = webView->priv->usePrimaryForPaste;
webView->priv->usePrimaryForPaste = true;
Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();
result = result || editor->canPaste() || editor->canDHTMLPaste();
editor->paste();
webView->priv->usePrimaryForPaste = primary;
}
#endif
return result;
}
static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
......@@ -2164,6 +2180,11 @@ void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkReque
webkit_download_start(download);
}
bool webkit_web_view_use_primary_for_paste(WebKitWebView* webView)
{
return webView->priv->usePrimaryForPaste;
}
void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* webSettings)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment