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/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } else { | 439 } else { |
440 gtk_widget_set_tooltip_text(view_.get(), WideToUTF8(tooltip_text).c_str()); | 440 gtk_widget_set_tooltip_text(view_.get(), WideToUTF8(tooltip_text).c_str()); |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 void RenderWidgetHostViewGtk::SelectionChanged(const std::string& text) { | 444 void RenderWidgetHostViewGtk::SelectionChanged(const std::string& text) { |
445 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 445 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
446 gtk_clipboard_set_text(x_clipboard, text.c_str(), text.length()); | 446 gtk_clipboard_set_text(x_clipboard, text.c_str(), text.length()); |
447 } | 447 } |
448 | 448 |
449 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( | |
450 const gfx::Size& size) { | |
451 Display* display = x11_util::GetXDisplay(); | |
452 void* visual = x11_util::GetVisualFromGtkWidget(view_.get()); | |
453 XID root_window = x11_util::GetX11RootWindow(); | |
454 bool use_render = x11_util::QueryRenderSupport(display); | |
455 bool use_shared_memory = x11_util::QuerySharedMemorySupport(display); | |
456 int depth = gtk_widget_get_visual(view_.get())->depth; | |
457 | |
458 return new BackingStore(size, display, depth, visual, root_window, | |
459 use_render, use_shared_memory); | |
460 } | |
461 | |
462 void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() { | 449 void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() { |
463 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 450 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
464 gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this); | 451 gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this); |
465 } | 452 } |
466 | 453 |
467 void RenderWidgetHostViewGtk::ShowingContextMenu(bool showing) { | 454 void RenderWidgetHostViewGtk::ShowingContextMenu(bool showing) { |
468 is_showing_context_menu_ = showing; | 455 is_showing_context_menu_ = showing; |
469 // Note that GTK_WIDGET_HAS_FOCUS differs gtom gtk_widget_is_focus() in that | 456 // Note that GTK_WIDGET_HAS_FOCUS differs gtom gtk_widget_is_focus() in that |
470 // the latter doesn't care whether the toplevel has focus. | 457 // the latter doesn't care whether the toplevel has focus. |
471 if (!showing && !GTK_WIDGET_HAS_FOCUS(view_.get())) | 458 if (!showing && !GTK_WIDGET_HAS_FOCUS(view_.get())) |
472 GetRenderWidgetHost()->Blur(); | 459 GetRenderWidgetHost()->Blur(); |
473 } | 460 } |
474 | 461 |
| 462 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( |
| 463 const gfx::Size& size) { |
| 464 return new BackingStore(host_, size, |
| 465 x11_util::GetVisualFromGtkWidget(view_.get()), |
| 466 gtk_widget_get_visual(view_.get())->depth); |
| 467 } |
| 468 |
475 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { | 469 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { |
476 DCHECK(!about_to_validate_and_paint_); | 470 DCHECK(!about_to_validate_and_paint_); |
477 | 471 |
478 invalid_rect_ = damage_rect; | 472 invalid_rect_ = damage_rect; |
479 about_to_validate_and_paint_ = true; | 473 about_to_validate_and_paint_ = true; |
480 BackingStore* backing_store = host_->GetBackingStore(); | 474 BackingStore* backing_store = host_->GetBackingStore(true); |
481 // Calling GetBackingStore maybe have changed |invalid_rect_|... | 475 // Calling GetBackingStore maybe have changed |invalid_rect_|... |
482 about_to_validate_and_paint_ = false; | 476 about_to_validate_and_paint_ = false; |
483 | 477 |
484 GdkWindow* window = view_.get()->window; | 478 GdkWindow* window = view_.get()->window; |
485 if (backing_store) { | 479 if (backing_store) { |
486 // Only render the widget if it is attached to a window; there's a short | 480 // Only render the widget if it is attached to a window; there's a short |
487 // period where this object isn't attached to a window but hasn't been | 481 // period where this object isn't attached to a window but hasn't been |
488 // Destroy()ed yet and it receives paint messages... | 482 // Destroy()ed yet and it receives paint messages... |
489 if (window) { | 483 if (window) { |
490 backing_store->ShowRect( | 484 backing_store->ShowRect( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 535 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
542 const gchar* text, gpointer userdata) { | 536 const gchar* text, gpointer userdata) { |
543 // If there's nothing to paste (|text| is NULL), do nothing. | 537 // If there's nothing to paste (|text| is NULL), do nothing. |
544 if (!text) | 538 if (!text) |
545 return; | 539 return; |
546 RenderWidgetHostViewGtk* host_view = | 540 RenderWidgetHostViewGtk* host_view = |
547 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 541 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
548 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 542 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
549 UTF8ToUTF16(text))); | 543 UTF8ToUTF16(text))); |
550 } | 544 } |
OLD | NEW |