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 16 matching lines...) Expand all Loading... |
27 static const int kMaxWindowWidth = 4000; | 27 static const int kMaxWindowWidth = 4000; |
28 static const int kMaxWindowHeight = 4000; | 28 static const int kMaxWindowHeight = 4000; |
29 | 29 |
30 using WebKit::WebInputEventFactory; | 30 using WebKit::WebInputEventFactory; |
31 | 31 |
32 // This class is a simple convenience wrapper for Gtk functions. It has only | 32 // This class is a simple convenience wrapper for Gtk functions. It has only |
33 // static methods. | 33 // static methods. |
34 class RenderWidgetHostViewGtkWidget { | 34 class RenderWidgetHostViewGtkWidget { |
35 public: | 35 public: |
36 static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) { | 36 static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) { |
37 GtkWidget* widget = gtk_drawing_area_new(); | 37 GtkWidget* widget = gtk_fixed_new(); |
| 38 gtk_fixed_set_has_window(GTK_FIXED(widget), true); |
38 gtk_widget_set_double_buffered(widget, FALSE); | 39 gtk_widget_set_double_buffered(widget, FALSE); |
39 #if defined(NDEBUG) | 40 #if defined(NDEBUG) |
40 gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkWhite); | 41 gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkWhite); |
41 #else | 42 #else |
42 gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkGreen); | 43 gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkGreen); |
43 #endif | 44 #endif |
44 | 45 |
45 gtk_widget_add_events(widget, GDK_EXPOSURE_MASK | | 46 gtk_widget_add_events(widget, GDK_EXPOSURE_MASK | |
46 GDK_POINTER_MOTION_MASK | | 47 GDK_POINTER_MOTION_MASK | |
47 GDK_BUTTON_PRESS_MASK | | 48 GDK_BUTTON_PRESS_MASK | |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 369 } |
369 | 370 |
370 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { | 371 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { |
371 if (im_context_) | 372 if (im_context_) |
372 g_object_unref(im_context_); | 373 g_object_unref(im_context_); |
373 view_.Destroy(); | 374 view_.Destroy(); |
374 } | 375 } |
375 | 376 |
376 void RenderWidgetHostViewGtk::InitAsChild() { | 377 void RenderWidgetHostViewGtk::InitAsChild() { |
377 view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this)); | 378 view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this)); |
| 379 plugin_container_host_.set_host_widget(view_.get()); |
378 gtk_widget_show(view_.get()); | 380 gtk_widget_show(view_.get()); |
379 } | 381 } |
380 | 382 |
381 void RenderWidgetHostViewGtk::InitAsPopup( | 383 void RenderWidgetHostViewGtk::InitAsPopup( |
382 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 384 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
383 parent_host_view_ = parent_host_view; | 385 parent_host_view_ = parent_host_view; |
384 parent_ = parent_host_view->GetNativeView(); | 386 parent_ = parent_host_view->GetNativeView(); |
385 GtkWidget* popup = gtk_window_new(GTK_WINDOW_POPUP); | 387 GtkWidget* popup = gtk_window_new(GTK_WINDOW_POPUP); |
386 view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this)); | 388 view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this)); |
| 389 plugin_container_host_.set_host_widget(view_.get()); |
387 gtk_container_add(GTK_CONTAINER(popup), view_.get()); | 390 gtk_container_add(GTK_CONTAINER(popup), view_.get()); |
388 | 391 |
389 // If we are not activatable, we don't want to grab keyboard input, | 392 // If we are not activatable, we don't want to grab keyboard input, |
390 // and webkit will manage our destruction. | 393 // and webkit will manage our destruction. |
391 if (activatable()) { | 394 if (activatable()) { |
392 // Grab all input for the app. If a click lands outside the bounds of the | 395 // Grab all input for the app. If a click lands outside the bounds of the |
393 // popup, WebKit will notice and destroy us. | 396 // popup, WebKit will notice and destroy us. |
394 gtk_grab_add(view_.get()); | 397 gtk_grab_add(view_.get()); |
395 // Now grab all of X's input. | 398 // Now grab all of X's input. |
396 gdk_pointer_grab( | 399 gdk_pointer_grab( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 } | 469 } |
467 | 470 |
468 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { | 471 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { |
469 return view_.get(); | 472 return view_.get(); |
470 } | 473 } |
471 | 474 |
472 void RenderWidgetHostViewGtk::MovePluginWindows( | 475 void RenderWidgetHostViewGtk::MovePluginWindows( |
473 const std::vector<WebPluginGeometry>& plugin_window_moves) { | 476 const std::vector<WebPluginGeometry>& plugin_window_moves) { |
474 if (plugin_window_moves.empty()) | 477 if (plugin_window_moves.empty()) |
475 return; | 478 return; |
476 | 479 for (unsigned int i = 0; i < plugin_window_moves.size(); ++i) { |
477 NOTIMPLEMENTED(); | 480 plugin_container_host_.MovePluginContainer(plugin_window_moves[i]); |
| 481 } |
478 } | 482 } |
479 | 483 |
480 void RenderWidgetHostViewGtk::Focus() { | 484 void RenderWidgetHostViewGtk::Focus() { |
481 gtk_widget_grab_focus(view_.get()); | 485 gtk_widget_grab_focus(view_.get()); |
482 } | 486 } |
483 | 487 |
484 void RenderWidgetHostViewGtk::Blur() { | 488 void RenderWidgetHostViewGtk::Blur() { |
485 // TODO(estade): We should be clearing native focus as well, but I know of no | 489 // TODO(estade): We should be clearing native focus as well, but I know of no |
486 // way to do that without focusing another widget. | 490 // way to do that without focusing another widget. |
487 // TODO(estade): it doesn't seem like the CanBlur() check should be necessary | 491 // TODO(estade): it doesn't seem like the CanBlur() check should be necessary |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx, | 570 void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx, |
567 int dy) { | 571 int dy) { |
568 if (is_hidden_) | 572 if (is_hidden_) |
569 return; | 573 return; |
570 | 574 |
571 Paint(rect); | 575 Paint(rect); |
572 } | 576 } |
573 | 577 |
574 void RenderWidgetHostViewGtk::RenderViewGone() { | 578 void RenderWidgetHostViewGtk::RenderViewGone() { |
575 Destroy(); | 579 Destroy(); |
| 580 plugin_container_host_.set_host_widget(NULL); |
576 } | 581 } |
577 | 582 |
578 void RenderWidgetHostViewGtk::Destroy() { | 583 void RenderWidgetHostViewGtk::Destroy() { |
579 // If |parent_| is non-null, we are a popup and we must disconnect from our | 584 // If |parent_| is non-null, we are a popup and we must disconnect from our |
580 // parent and destroy the popup window. | 585 // parent and destroy the popup window. |
581 if (parent_) { | 586 if (parent_) { |
582 if (activatable()) { | 587 if (activatable()) { |
583 GdkDisplay *display = gtk_widget_get_display(parent_); | 588 GdkDisplay *display = gtk_widget_get_display(parent_); |
584 gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); | 589 gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); |
585 gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); | 590 gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 705 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
701 const gchar* text, gpointer userdata) { | 706 const gchar* text, gpointer userdata) { |
702 // If there's nothing to paste (|text| is NULL), do nothing. | 707 // If there's nothing to paste (|text| is NULL), do nothing. |
703 if (!text) | 708 if (!text) |
704 return; | 709 return; |
705 RenderWidgetHostViewGtk* host_view = | 710 RenderWidgetHostViewGtk* host_view = |
706 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 711 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
707 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 712 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
708 UTF8ToUTF16(text))); | 713 UTF8ToUTF16(text))); |
709 } | 714 } |
| 715 |
| 716 gfx::PluginWindowHandle RenderWidgetHostViewGtk::CreatePluginContainer() { |
| 717 return plugin_container_host_.CreatePluginContainer(); |
| 718 } |
| 719 |
| 720 void RenderWidgetHostViewGtk::DestroyPluginContainer( |
| 721 gfx::PluginWindowHandle container) { |
| 722 plugin_container_host_.DestroyPluginContainer(container); |
| 723 } |
OLD | NEW |