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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } else { | 430 } else { |
431 gtk_widget_set_tooltip_text(view_.get(), WideToUTF8(tooltip_text).c_str()); | 431 gtk_widget_set_tooltip_text(view_.get(), WideToUTF8(tooltip_text).c_str()); |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 void RenderWidgetHostViewGtk::SelectionChanged(const std::string& text) { | 435 void RenderWidgetHostViewGtk::SelectionChanged(const std::string& text) { |
436 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 436 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
437 gtk_clipboard_set_text(x_clipboard, text.c_str(), text.length()); | 437 gtk_clipboard_set_text(x_clipboard, text.c_str(), text.length()); |
438 } | 438 } |
439 | 439 |
440 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( | |
441 const gfx::Size& size) { | |
442 Display* display = x11_util::GetXDisplay(); | |
443 void* visual = x11_util::GetVisualFromGtkWidget(view_.get()); | |
444 XID root_window = x11_util::GetX11RootWindow(); | |
445 bool use_render = x11_util::QueryRenderSupport(display); | |
446 bool use_shared_memory = x11_util::QuerySharedMemorySupport(display); | |
447 int depth = gtk_widget_get_visual(view_.get())->depth; | |
448 | |
449 return new BackingStore(size, display, depth, visual, root_window, | |
450 use_render, use_shared_memory); | |
451 } | |
452 | |
453 void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() { | 440 void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() { |
454 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 441 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
455 gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this); | 442 gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this); |
456 } | 443 } |
457 | 444 |
| 445 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( |
| 446 const gfx::Size& size) { |
| 447 return new BackingStore(host_, size, |
| 448 x11_util::GetVisualFromGtkWidget(view_.get()), |
| 449 gtk_widget_get_visual(view_.get())->depth); |
| 450 } |
| 451 |
458 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { | 452 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { |
459 DCHECK(!about_to_validate_and_paint_); | 453 DCHECK(!about_to_validate_and_paint_); |
460 | 454 |
461 invalid_rect_ = damage_rect; | 455 invalid_rect_ = damage_rect; |
462 about_to_validate_and_paint_ = true; | 456 about_to_validate_and_paint_ = true; |
463 BackingStore* backing_store = host_->GetBackingStore(); | 457 BackingStore* backing_store = host_->GetBackingStore(true); |
464 // Calling GetBackingStore maybe have changed |invalid_rect_|... | 458 // Calling GetBackingStore maybe have changed |invalid_rect_|... |
465 about_to_validate_and_paint_ = false; | 459 about_to_validate_and_paint_ = false; |
466 | 460 |
467 GdkWindow* window = view_.get()->window; | 461 GdkWindow* window = view_.get()->window; |
468 if (backing_store) { | 462 if (backing_store) { |
469 // Only render the widget if it is attached to a window; there's a short | 463 // Only render the widget if it is attached to a window; there's a short |
470 // period where this object isn't attached to a window but hasn't been | 464 // period where this object isn't attached to a window but hasn't been |
471 // Destroy()ed yet and it receives paint messages... | 465 // Destroy()ed yet and it receives paint messages... |
472 if (window) { | 466 if (window) { |
473 backing_store->ShowRect( | 467 backing_store->ShowRect( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 518 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
525 const gchar* text, gpointer userdata) { | 519 const gchar* text, gpointer userdata) { |
526 // If there's nothing to paste (|text| is NULL), do nothing. | 520 // If there's nothing to paste (|text| is NULL), do nothing. |
527 if (!text) | 521 if (!text) |
528 return; | 522 return; |
529 RenderWidgetHostViewGtk* host_view = | 523 RenderWidgetHostViewGtk* host_view = |
530 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 524 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
531 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 525 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
532 UTF8ToUTF16(text))); | 526 UTF8ToUTF16(text))); |
533 } | 527 } |
OLD | NEW |