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> |
11 #include <cairo/cairo.h> | 11 #include <cairo/cairo.h> |
12 | 12 |
13 #include "base/gfx/gtk_util.h" | 13 #include "base/gfx/gtk_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/task.h" | 17 #include "base/task.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "chrome/common/native_web_keyboard_event.h" | 19 #include "chrome/common/native_web_keyboard_event.h" |
20 #include "chrome/common/render_messages.h" | 20 #include "chrome/common/render_messages.h" |
21 #include "chrome/common/x11_util.h" | 21 #include "chrome/common/x11_util.h" |
22 #include "chrome/browser/renderer_host/backing_store.h" | 22 #include "chrome/browser/renderer_host/backing_store.h" |
23 #include "chrome/browser/renderer_host/render_widget_host.h" | 23 #include "chrome/browser/renderer_host/render_widget_host.h" |
24 #include "webkit/api/public/gtk/WebInputEventFactory.h" | 24 #include "webkit/api/public/gtk/WebInputEventFactory.h" |
25 #include "webkit/glue/webcursor_gtk_data.h" | 25 #include "webkit/glue/webcursor_gtk_data.h" |
26 | 26 |
| 27 static const int kMaxPopupWidth = 2000; |
| 28 static const int kMaxPopupHeight = 2000; |
| 29 |
27 using WebKit::WebInputEventFactory; | 30 using WebKit::WebInputEventFactory; |
28 | 31 |
29 // 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 |
30 // static methods. | 33 // static methods. |
31 class RenderWidgetHostViewGtkWidget { | 34 class RenderWidgetHostViewGtkWidget { |
32 public: | 35 public: |
33 static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) { | 36 static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) { |
34 GtkWidget* widget = gtk_drawing_area_new(); | 37 GtkWidget* widget = gtk_drawing_area_new(); |
35 gtk_widget_set_double_buffered(widget, FALSE); | 38 gtk_widget_set_double_buffered(widget, FALSE); |
36 #if defined(NDEBUG) | 39 #if defined(NDEBUG) |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 NULL, | 270 NULL, |
268 GDK_CURRENT_TIME); | 271 GDK_CURRENT_TIME); |
269 // We grab keyboard events too so things like alt+tab are eaten. | 272 // We grab keyboard events too so things like alt+tab are eaten. |
270 gdk_keyboard_grab(parent_->window, TRUE, GDK_CURRENT_TIME); | 273 gdk_keyboard_grab(parent_->window, TRUE, GDK_CURRENT_TIME); |
271 | 274 |
272 // Our parent widget actually keeps GTK focus within its window, but we have | 275 // Our parent widget actually keeps GTK focus within its window, but we have |
273 // to make the webkit selection box disappear to maintain appearances. | 276 // to make the webkit selection box disappear to maintain appearances. |
274 parent_host_view->Blur(); | 277 parent_host_view->Blur(); |
275 } | 278 } |
276 | 279 |
277 gtk_widget_set_size_request(view_.get(), pos.width(), pos.height()); | 280 gtk_widget_set_size_request(view_.get(), |
| 281 std::min(pos.width(), kMaxPopupWidth), |
| 282 std::min(pos.height(), kMaxPopupHeight)); |
278 | 283 |
279 gtk_window_set_default_size(GTK_WINDOW(popup), -1, -1); | 284 gtk_window_set_default_size(GTK_WINDOW(popup), -1, -1); |
280 // Don't allow the window to be resized. This also forces the window to | 285 // Don't allow the window to be resized. This also forces the window to |
281 // shrink down to the size of its child contents. | 286 // shrink down to the size of its child contents. |
282 gtk_window_set_resizable(GTK_WINDOW(popup), FALSE); | 287 gtk_window_set_resizable(GTK_WINDOW(popup), FALSE); |
283 gtk_window_move(GTK_WINDOW(popup), pos.x(), pos.y()); | 288 gtk_window_move(GTK_WINDOW(popup), pos.x(), pos.y()); |
284 gtk_widget_show_all(popup); | 289 gtk_widget_show_all(popup); |
285 } | 290 } |
286 | 291 |
287 void RenderWidgetHostViewGtk::DidBecomeSelected() { | 292 void RenderWidgetHostViewGtk::DidBecomeSelected() { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 541 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
537 const gchar* text, gpointer userdata) { | 542 const gchar* text, gpointer userdata) { |
538 // If there's nothing to paste (|text| is NULL), do nothing. | 543 // If there's nothing to paste (|text| is NULL), do nothing. |
539 if (!text) | 544 if (!text) |
540 return; | 545 return; |
541 RenderWidgetHostViewGtk* host_view = | 546 RenderWidgetHostViewGtk* host_view = |
542 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 547 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
543 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 548 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
544 UTF8ToUTF16(text))); | 549 UTF8ToUTF16(text))); |
545 } | 550 } |
OLD | NEW |