| Index: chrome/browser/renderer_host/render_widget_host_view_gtk.cc
|
| diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
|
| index 5b9de43ba69ca9685311bff7cf6c34632e70e291..0ed331b01a963bbf12d93066b00c0c342062f2da 100644
|
| --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
|
| +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
|
| @@ -511,72 +511,12 @@ void RenderWidgetHostViewGtk::InitAsChild() {
|
|
|
| void RenderWidgetHostViewGtk::InitAsPopup(
|
| RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
|
| - parent_host_view_ = parent_host_view;
|
| - parent_ = parent_host_view->GetNativeView();
|
| - GtkWidget* popup = gtk_window_new(GTK_WINDOW_POPUP);
|
| - view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this));
|
| - // |im_context_| must be created after creating |view_| widget.
|
| - im_context_.reset(new GtkIMContextWrapper(this));
|
| - // |key_bindings_handler_| must be created after creating |view_| widget.
|
| - key_bindings_handler_.reset(new GtkKeyBindingsHandler(view_.get()));
|
| - plugin_container_manager_.set_host_widget(view_.get());
|
| -
|
| -#if defined(OS_CHROMEOS)
|
| - tooltip_window_.reset(new views::TooltipWindowGtk(view_.get()));
|
| -#endif // defined(OS_CHROMEOS)
|
| -
|
| - gtk_container_add(GTK_CONTAINER(popup), view_.get());
|
| -
|
| - requested_size_ = gfx::Size(std::min(pos.width(), kMaxWindowWidth),
|
| - std::min(pos.height(), kMaxWindowHeight));
|
| - host_->WasResized();
|
| - gtk_widget_set_size_request(view_.get(), requested_size_.width(),
|
| - requested_size_.height());
|
| -
|
| - gtk_window_set_default_size(GTK_WINDOW(popup), -1, -1);
|
| - // Don't allow the window to be resized. This also forces the window to
|
| - // shrink down to the size of its child contents.
|
| - gtk_window_set_resizable(GTK_WINDOW(popup), FALSE);
|
| - gtk_window_move(GTK_WINDOW(popup), pos.x(), pos.y());
|
| - gtk_widget_show_all(popup);
|
| -
|
| - // If we are not activatable, we don't want to grab keyboard input,
|
| - // and webkit will manage our destruction.
|
| - // For unknown reason, calling gtk_grab_add() before realizing the widget may
|
| - // cause an assertion failure. See http://crbug.com/51834. So we do it after
|
| - // showing the popup.
|
| - if (NeedsInputGrab()) {
|
| - // Grab all input for the app. If a click lands outside the bounds of the
|
| - // popup, WebKit will notice and destroy us. Before doing this we need
|
| - // to ensure that the the popup is added to the browser's window group,
|
| - // to allow for the grabs to work correctly.
|
| - gtk_window_group_add_window(gtk_window_get_group(
|
| - GTK_WINDOW(gtk_widget_get_toplevel(parent_))), GTK_WINDOW(popup));
|
| - gtk_grab_add(view_.get());
|
| -
|
| - // We need for the application to do an X grab as well. However if the app
|
| - // already has an X grab (as in the case of extension popup), an app grab
|
| - // will suffice.
|
| - do_x_grab_ = !gdk_pointer_is_grabbed();
|
| -
|
| - // Now grab all of X's input.
|
| - if (do_x_grab_) {
|
| - gdk_pointer_grab(
|
| - parent_->window,
|
| - TRUE, // Only events outside of the window are reported with respect
|
| - // to |parent_->window|.
|
| - static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK |
|
| - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
|
| - NULL,
|
| - NULL,
|
| - GDK_CURRENT_TIME);
|
| - // We grab keyboard events too so things like alt+tab are eaten.
|
| - gdk_keyboard_grab(parent_->window, TRUE, GDK_CURRENT_TIME);
|
| - }
|
| - }
|
| + DoInitAsPopup(parent_host_view, GTK_WINDOW_POPUP, pos, false);
|
| +}
|
|
|
| - // TODO(brettw) possibly enable out-of-process painting here as well
|
| - // (see InitAsChild).
|
| +void RenderWidgetHostViewGtk::InitAsFullscreen(
|
| + RenderWidgetHostView* parent_host_view) {
|
| + DoInitAsPopup(parent_host_view, GTK_WINDOW_TOPLEVEL, gfx::Rect(), true);
|
| }
|
|
|
| void RenderWidgetHostViewGtk::DidBecomeSelected() {
|
| @@ -1034,6 +974,94 @@ void RenderWidgetHostViewGtk::ShowCurrentCursor() {
|
| gdk_cursor_unref(gdk_cursor);
|
| }
|
|
|
| +void RenderWidgetHostViewGtk::DoInitAsPopup(
|
| + RenderWidgetHostView* parent_host_view,
|
| + GtkWindowType window_type,
|
| + const gfx::Rect& pos,
|
| + bool is_fullscreen) {
|
| + // If we are not a popup, then popup will be leaked.
|
| + DCHECK(IsPopup());
|
| +
|
| + parent_host_view_ = parent_host_view;
|
| + parent_ = parent_host_view->GetNativeView();
|
| + GtkWidget* popup = gtk_window_new(window_type);
|
| + gtk_window_set_decorated(GTK_WINDOW(popup), FALSE);
|
| + view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this));
|
| + // |im_context_| must be created after creating |view_| widget.
|
| + im_context_.reset(new GtkIMContextWrapper(this));
|
| + // |key_bindings_handler_| must be created after creating |view_| widget.
|
| + key_bindings_handler_.reset(new GtkKeyBindingsHandler(view_.get()));
|
| + plugin_container_manager_.set_host_widget(view_.get());
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| + tooltip_window_.reset(new views::TooltipWindowGtk(view_.get()));
|
| +#endif // defined(OS_CHROMEOS)
|
| +
|
| + gtk_container_add(GTK_CONTAINER(popup), view_.get());
|
| +
|
| + if (is_fullscreen) {
|
| + // Set the request size to the size of the screen.
|
| + // TODO(boliu): Make sure this works for multi-monitor set ups and move this
|
| + // to some utility function.
|
| + GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(popup));
|
| + requested_size_ = gfx::Size(
|
| + std::min(gdk_screen_get_width(screen), kMaxWindowWidth),
|
| + std::min(gdk_screen_get_height(screen), kMaxWindowHeight));
|
| + } else {
|
| + requested_size_ = gfx::Size(std::min(pos.width(), kMaxWindowWidth),
|
| + std::min(pos.height(), kMaxWindowHeight));
|
| + }
|
| + host_->WasResized();
|
| +
|
| + gtk_widget_set_size_request(view_.get(), requested_size_.width(),
|
| + requested_size_.height());
|
| + // Don't allow the window to be resized. This also forces the window to
|
| + // shrink down to the size of its child contents.
|
| + gtk_window_set_resizable(GTK_WINDOW(popup), FALSE);
|
| + gtk_window_set_default_size(GTK_WINDOW(popup), -1, -1);
|
| + gtk_window_move(GTK_WINDOW(popup), pos.x(), pos.y());
|
| + if (is_fullscreen) {
|
| + gtk_window_fullscreen(GTK_WINDOW(popup));
|
| + }
|
| +
|
| + gtk_widget_show_all(popup);
|
| +
|
| + // If we are not activatable, we don't want to grab keyboard input,
|
| + // and webkit will manage our destruction.
|
| + // For unknown reason, calling gtk_grab_add() before realizing the widget may
|
| + // cause an assertion failure. See http://crbug.com/51834. So we do it after
|
| + // showing the popup.
|
| + if (NeedsInputGrab()) {
|
| + // Grab all input for the app. If a click lands outside the bounds of the
|
| + // popup, WebKit will notice and destroy us. Before doing this we need
|
| + // to ensure that the the popup is added to the browser's window group,
|
| + // to allow for the grabs to work correctly.
|
| + gtk_window_group_add_window(gtk_window_get_group(
|
| + GTK_WINDOW(gtk_widget_get_toplevel(parent_))), GTK_WINDOW(popup));
|
| + gtk_grab_add(view_.get());
|
| +
|
| + // We need for the application to do an X grab as well. However if the app
|
| + // already has an X grab (as in the case of extension popup), an app grab
|
| + // will suffice.
|
| + do_x_grab_ = !gdk_pointer_is_grabbed();
|
| +
|
| + // Now grab all of X's input.
|
| + if (do_x_grab_) {
|
| + gdk_pointer_grab(
|
| + parent_->window,
|
| + TRUE, // Only events outside of the window are reported with respect
|
| + // to |parent_->window|.
|
| + static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK |
|
| + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
|
| + NULL,
|
| + NULL,
|
| + GDK_CURRENT_TIME);
|
| + // We grab keyboard events too so things like alt+tab are eaten.
|
| + gdk_keyboard_grab(parent_->window, TRUE, GDK_CURRENT_TIME);
|
| + }
|
| + }
|
| +}
|
| +
|
| void RenderWidgetHostViewGtk::CreatePluginContainer(
|
| gfx::PluginWindowHandle id) {
|
| plugin_container_manager_.CreatePluginContainer(id);
|
|
|