| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #include <gdk/gdkx.h> | 9 #include <gdk/gdkx.h> |
| 10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 G_CALLBACK(MouseScrollEvent), host_view); | 59 G_CALLBACK(MouseScrollEvent), host_view); |
| 60 | 60 |
| 61 GtkTargetList* target_list = gtk_target_list_new(NULL, 0); | 61 GtkTargetList* target_list = gtk_target_list_new(NULL, 0); |
| 62 gtk_target_list_add_text_targets(target_list, 0); | 62 gtk_target_list_add_text_targets(target_list, 0); |
| 63 gint num_targets = 0; | 63 gint num_targets = 0; |
| 64 GtkTargetEntry* targets = gtk_target_table_new_from_list(target_list, | 64 GtkTargetEntry* targets = gtk_target_table_new_from_list(target_list, |
| 65 &num_targets); | 65 &num_targets); |
| 66 gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY); | 66 gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY); |
| 67 gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, targets, | 67 gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, targets, |
| 68 num_targets); | 68 num_targets); |
| 69 gtk_target_list_unref(target_list); |
| 69 gtk_target_table_free(targets, num_targets); | 70 gtk_target_table_free(targets, num_targets); |
| 70 | 71 |
| 71 // When X requests the contents of the clipboard, GTK will emit the | 72 // When X requests the contents of the clipboard, GTK will emit the |
| 72 // selection_request_event signal. The default handler would then | 73 // selection_request_event signal. The default handler would then |
| 73 // synchronously emit the selection_get signal. However, we want to | 74 // synchronously emit the selection_get signal. However, we want to |
| 74 // respond to the selection_request_event asynchronously, so we intercept | 75 // respond to the selection_request_event asynchronously, so we intercept |
| 75 // the signal in OnSelectionRequest, request the selection text from the | 76 // the signal in OnSelectionRequest, request the selection text from the |
| 76 // render view, and return TRUE so the default handler won't be called. Then | 77 // render view, and return TRUE so the default handler won't be called. Then |
| 77 // when we get the selection text back from the renderer in | 78 // when we get the selection text back from the renderer in |
| 78 // SetSelectionText() we will call manually the selection_request_event | 79 // SetSelectionText() we will call manually the selection_request_event |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 host_->Send(new ViewMsg_RequestSelectionText(host_->routing_id())); | 467 host_->Send(new ViewMsg_RequestSelectionText(host_->routing_id())); |
| 467 } | 468 } |
| 468 | 469 |
| 469 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 470 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
| 470 const gchar* text, gpointer userdata) { | 471 const gchar* text, gpointer userdata) { |
| 471 RenderWidgetHostViewGtk* host_view = | 472 RenderWidgetHostViewGtk* host_view = |
| 472 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 473 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
| 473 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 474 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
| 474 UTF8ToUTF16(text))); | 475 UTF8ToUTF16(text))); |
| 475 } | 476 } |
| OLD | NEW |