summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-09 20:05:26 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-09 20:05:26 +0000
commitb595ba77947ee0881ae8ce16ee92b47d1c48f10a (patch)
tree3a7961e315229ec247fdb3f520d2aeb8034eb2d7 /webkit
parent977471dac3b804a8a2408586c5e76f592b87b219 (diff)
downloadchromium_src-b595ba77947ee0881ae8ce16ee92b47d1c48f10a.zip
chromium_src-b595ba77947ee0881ae8ce16ee92b47d1c48f10a.tar.gz
chromium_src-b595ba77947ee0881ae8ce16ee92b47d1c48f10a.tar.bz2
This changes the approach for our webkit widget area, from using a custom GtkContainer to a GtkFixed container.
Our previous custom container did not track its children, which meant it couldn't propagate size-request and size-allocate. In some ways this is what we wanted, however it prevented GtkSocket from running some important code. Specifically an expose event wouldn't trigger initially on the GtkSocket, leaving the widget window unpainted. Instead of writing / copying container code to manage children, it is much easier if we can reuse an existing container. This changes makes the drawing area a GtkFixed backed by a GdkWindow, and we paint into its window. We implement a small custom widget around GtkSocket, which allows us to control the size requisition phase. This solves the problem of controlling the GtkSocket layout within the container. Plugins are now painted correctly, without having to jiggle the scrollbar. This change additionally groups all of the widget code in a class of statics. GtkFixedSocket implements the GtkSocket with custom size requisition. WebWidgetHostGtkWidget is just a GtkFixed with a window, along with the signal connection handlers. This also means we'll have no custom container implementation to share across test_shell and the browser. It seems we still don't handle keyboard focus exactly right, and youtube videos still need mouse events to repaint. I believe these are subtle issues, and can be solved while keeping the GtkFixed container approach. Review URL: http://codereview.chromium.org/20128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc61
-rw-r--r--webkit/tools/test_shell/webview_host_gtk.cc4
-rw-r--r--webkit/tools/test_shell/webwidget_host.h3
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc394
4 files changed, 237 insertions, 225 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 741ba99..58207c6 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -21,6 +21,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#include "base/basictypes.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/process_util.h"
@@ -241,13 +242,60 @@ void WebPluginDelegateImpl::WindowedUpdateGeometry(
namespace {
+// This is just a GtkSocket, with size_request overridden, so that we always
+// control the size of the widget.
+class GtkFixedSocket {
+ public:
+ // Create a new instance of our GTK widget object.
+ static GtkWidget* CreateNewWidget() {
+ return GTK_WIDGET(g_object_new(GetType(), NULL));
+ }
+
+ private:
+ // Create and register our custom container type with GTK.
+ static GType GetType() {
+ static GType type = 0; // We only want to register our type once.
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof(GtkSocketClass),
+ NULL, NULL,
+ static_cast<GClassInitFunc>(&ClassInit),
+ NULL, NULL,
+ sizeof(GtkSocket), // We are identical to a GtkSocket.
+ 0, NULL,
+ };
+ type = g_type_register_static(GTK_TYPE_SOCKET,
+ "GtkFixedSocket",
+ &info,
+ static_cast<GTypeFlags>(0));
+ }
+ return type;
+ }
+
+ // Implementation of the class initializer.
+ static void ClassInit(gpointer klass, gpointer class_data_unusued) {
+ GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(klass);
+ widget_class->size_request = &HandleSizeRequest;
+ }
+
+ // Report our allocation size during size requisition. This means we control
+ // the size, from calling gtk_widget_size_allocate in WindowedReposition().
+ static void HandleSizeRequest(GtkWidget* widget,
+ GtkRequisition* requisition) {
+ requisition->width = widget->allocation.width;
+ requisition->height = widget->allocation.height;
+ }
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(GtkFixedSocket);
+};
+
gboolean PlugRemovedCallback(GtkSocket* socket) {
// This is called when the other side of the socket goes away.
// We return TRUE to indicate that we don't want to destroy our side.
return TRUE;
}
-}
+} // namespace
bool WebPluginDelegateImpl::WindowedCreatePlugin() {
DCHECK(!windowed_handle_);
@@ -260,16 +308,18 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
return false;
}
- windowed_handle_ = gtk_socket_new();
- gtk_widget_set_parent(windowed_handle_, parent_);
+ windowed_handle_ = GtkFixedSocket::CreateNewWidget();
g_signal_connect(GTK_SOCKET(windowed_handle_), "plug-removed",
G_CALLBACK(PlugRemovedCallback), NULL);
+ gtk_container_add(GTK_CONTAINER(parent_), windowed_handle_);
// TODO(evanm): connect to signals on the socket, like when the other side
// goes away.
+ gtk_widget_show(windowed_handle_);
+ gtk_widget_realize(windowed_handle_);
+
window_.window = GINT_TO_POINTER(
gtk_socket_get_id(GTK_SOCKET(windowed_handle_)));
- gtk_widget_show(windowed_handle_);
NPSetWindowCallbackStruct* extra = new NPSetWindowCallbackStruct;
extra->display = GDK_WINDOW_XDISPLAY(windowed_handle_->window);
@@ -303,6 +353,9 @@ bool WebPluginDelegateImpl::WindowedReposition(
// Clipping is handled by WebPlugin.
GtkAllocation allocation = { window_rect.x(), window_rect.y(),
window_rect.width(), window_rect.height() };
+ // Tell our parent GtkFixed container where to place the widget.
+ gtk_fixed_move(
+ GTK_FIXED(parent_), windowed_handle_, window_rect.x(), window_rect.y());
gtk_widget_size_allocate(windowed_handle_, &allocation);
window_rect_ = window_rect;
diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc
index 81753f6..d15c152 100644
--- a/webkit/tools/test_shell/webview_host_gtk.cc
+++ b/webkit/tools/test_shell/webview_host_gtk.cc
@@ -13,13 +13,13 @@
#include "webkit/glue/webinputevent.h"
#include "webkit/glue/webview.h"
-/*static*/
+// static
WebViewHost* WebViewHost::Create(GtkWidget* parent_view,
WebViewDelegate* delegate,
const WebPreferences& prefs) {
WebViewHost* host = new WebViewHost();
- host->view_ = WebWidgetHost::CreateWindow(parent_view, host);
+ host->view_ = WebWidgetHost::CreateWidget(parent_view, host);
g_object_set_data(G_OBJECT(host->view_), "webwidgethost", host);
host->webwidget_ = WebView::Create(delegate, prefs);
diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h
index fd7f4d9..216c0b1 100644
--- a/webkit/tools/test_shell/webwidget_host.h
+++ b/webkit/tools/test_shell/webwidget_host.h
@@ -82,7 +82,8 @@ class WebWidgetHost {
// parent: a GtkBox to pack the new widget at the end of
// host: a pointer to a WebWidgetHost (or subclass thereof)
// ---------------------------------------------------------------------------
- static gfx::NativeView CreateWindow(gfx::NativeView parent_view, void* host);
+ static gfx::NativeView CreateWidget(gfx::NativeView parent_view,
+ WebWidgetHost* host);
void WindowDestroyed();
void Resize(const gfx::Size& size);
#endif
diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc
index e1f83f1..8693cf1 100644
--- a/webkit/tools/test_shell/webwidget_host_gtk.cc
+++ b/webkit/tools/test_shell/webwidget_host_gtk.cc
@@ -17,118 +17,6 @@
namespace {
-// The web contents are completely drawn and handled by WebKit, except that
-// windowed plugins are GtkSockets on top of it. GtkSockets are unhappy
-// if they cannot be put within a parent container, so what we want is basically
-// a GtkDrawingArea that is also a GtkContainer. The existing Gtk classes for
-// this sort of thing (reasonably) assume that the positioning of the children
-// will be handled by the parent, which isn't the case for us where WebKit
-// drives everything. So we create a custom widget that is just a GtkContainer
-// that contains a native window. This class is just a collection of static
-// methods, which implement the GTK functions for the container.
-class CustomGtkContainer {
- public:
- // Create a new instance of our GTK widget object.
- static GtkWidget* CreateNewWidget() {
- return GTK_WIDGET(g_object_new(GetType(), NULL));
- }
-
- private:
- // Create and register our custom container type with GTK.
- static GType GetType() {
- static GType type = 0; // We only want to register our type once.
- if (!type) {
- static const GTypeInfo info = {
- sizeof(GtkContainerClass),
- NULL, NULL,
- static_cast<GClassInitFunc>(&ClassInit),
- NULL, NULL,
- sizeof(GtkContainer), // We are identical in memory to a GtkContainer.
- 0, NULL,
- };
- type = g_type_register_static(GTK_TYPE_CONTAINER, "WebWidgetHostGtk",
- &info, static_cast<GTypeFlags>(0));
- }
- return type;
- }
-
- // Implementation of the class initializer.
- static void ClassInit(gpointer klass, gpointer class_data_unusued) {
- GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(klass);
- GtkContainerClass* container_class =
- reinterpret_cast<GtkContainerClass*>(klass);
-
- widget_class->realize = &HandleRealize;
- widget_class->size_allocate = &HandleSizeAllocate;
- container_class->remove = &HandleRemove;
- }
-
- // Implementation of the "realize" event. Creates an X window.
- // (Nearly identical to GtkDrawingArea code.)
- static void HandleRealize(GtkWidget* widget) {
- GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
-
- GdkWindowAttr attributes;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual(widget);
- attributes.colormap = gtk_widget_get_colormap(widget);
- attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
- int attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data(widget->window, widget);
-
- SendConfigureMessage(widget);
- }
-
- // Implementation of the "size-allocate" event. Resizes the window.
- // (Nearly identical to GtkDrawingArea code.)
- static void HandleSizeAllocate(GtkWidget* widget,
- GtkAllocation* allocation) {
- widget->allocation = *allocation;
- if (!GTK_WIDGET_REALIZED(widget)) {
- // We don't have a window yet, so nothing to do.
- return;
- }
-
- gdk_window_move_resize(widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- SendConfigureMessage(widget);
- }
-
- // Implementation of "remove" event. This called when plugins shut down.
- // We can just ignore it.
- static void HandleRemove(GtkContainer* container, GtkWidget* widget) {
- // Do nothing.
- }
-
- // Sends a "configure" event to the widget, allowing it to repaint.
- static void SendConfigureMessage(GtkWidget* widget) {
- GdkEvent* event = gdk_event_new(GDK_CONFIGURE);
- // This ref matches GtkDrawingArea code. It must be balanced by the
- // event-handling code.
- g_object_ref(widget->window);
- event->configure.window = widget->window;
- event->configure.send_event = TRUE;
- event->configure.x = widget->allocation.x;
- event->configure.y = widget->allocation.y;
- event->configure.width = widget->allocation.width;
- event->configure.height = widget->allocation.height;
- gtk_widget_event(widget, event);
- gdk_event_free(event);
- }
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(CustomGtkContainer);
-};
-
// In response to an invalidation, we call into WebKit to do layout. On
// Windows, WM_PAINT is a virtual message so any extra invalidates that come up
// while it's doing layout are implicitly swallowed as soon as we actually do
@@ -140,135 +28,205 @@ class CustomGtkContainer {
// during that if we get told by WebKit that a region has become invalid, we
// still add that region to the local dirty rect but *don't* enqueue yet
// another "do a paint" message.
-bool handling_expose = false;
+bool g_handling_expose = false;
// -----------------------------------------------------------------------------
// Callback functions to proxy to host...
-gboolean ConfigureEvent(GtkWidget* widget, GdkEventConfigure* config,
- WebWidgetHost* host) {
- host->Resize(gfx::Size(config->width, config->height));
- return FALSE;
-}
+// The web contents are completely drawn and handled by WebKit, except that
+// windowed plugins are GtkSockets on top of it. We need to place the
+// GtkSockets inside a GtkContainer. We use a GtkFixed container, and the
+// GtkSocket objects override a little bit to manage their size (see the code
+// in webplugin_delegate_impl_gtk.cc). We listen on a the events we're
+// interested in and forward them on to the WebWidgetHost. This class is a
+// collection of static methods, implementing the widget related code.
+class WebWidgetHostGtkWidget {
+ public:
+ // This will create a new widget used for hosting the web contents. We use
+ // our GtkDrawingAreaContainer here, for the reasons mentioned above.
+ static GtkWidget* CreateNewWidget(GtkWidget* parent_view,
+ WebWidgetHost* host) {
+ GtkWidget* widget = gtk_fixed_new();
+ gtk_fixed_set_has_window(GTK_FIXED(widget), true);
+
+ gtk_box_pack_start(GTK_BOX(parent_view), widget, TRUE, TRUE, 0);
+
+ gtk_widget_add_events(widget, GDK_EXPOSURE_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK);
+ GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
+ g_signal_connect(widget, "size-allocate",
+ G_CALLBACK(&HandleSizeAllocate), host);
+ g_signal_connect(widget, "configure-event",
+ G_CALLBACK(&HandleConfigure), host);
+ g_signal_connect(widget, "expose-event",
+ G_CALLBACK(&HandleExpose), host);
+ g_signal_connect(widget, "destroy",
+ G_CALLBACK(&HandleDestroy), host);
+ g_signal_connect(widget, "key-press-event",
+ G_CALLBACK(&HandleKeyPress), host);
+ g_signal_connect(widget, "key-release-event",
+ G_CALLBACK(&HandleKeyRelease), host);
+ g_signal_connect(widget, "focus",
+ G_CALLBACK(&HandleFocus), host);
+ g_signal_connect(widget, "focus-in-event",
+ G_CALLBACK(&HandleFocusIn), host);
+ g_signal_connect(widget, "focus-out-event",
+ G_CALLBACK(&HandleFocusOut), host);
+ g_signal_connect(widget, "button-press-event",
+ G_CALLBACK(&HandleButtonPress), host);
+ g_signal_connect(widget, "button-release-event",
+ G_CALLBACK(&HandleButtonRelease), host);
+ g_signal_connect(widget, "motion-notify-event",
+ G_CALLBACK(&HandleMotionNotify), host);
+ g_signal_connect(widget, "scroll-event",
+ G_CALLBACK(&HandleScroll), host);
+
+ return widget;
+ }
-gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose,
- WebWidgetHost* host) {
- // See comments above about what handling_expose is for.
- handling_expose = true;
- gfx::Rect rect(expose->area);
- host->UpdatePaintRect(rect);
- host->Paint();
- handling_expose = false;
- return FALSE;
-}
+ private:
+ // Our size has changed.
+ static void HandleSizeAllocate(GtkWidget* widget,
+ GtkAllocation* allocation,
+ WebWidgetHost* host) {
+ host->Resize(gfx::Size(allocation->width, allocation->height));
+ }
-gboolean WindowDestroyed(GtkWidget* widget, WebWidgetHost* host) {
- host->WindowDestroyed();
- return FALSE;
-}
+ // Size, position, or stacking of the GdkWindow changed.
+ static gboolean HandleConfigure(GtkWidget* widget,
+ GdkEventConfigure* config,
+ WebWidgetHost* host) {
+ host->Resize(gfx::Size(config->width, config->height));
+ return FALSE;
+ }
-gboolean KeyPressReleaseEvent(GtkWidget* widget, GdkEventKey* event,
- WebWidgetHost* host) {
- WebKeyboardEvent wke(event);
- host->webwidget()->HandleInputEvent(&wke);
-
- // The WebKeyboardEvent model, when holding down a key, is:
- // KEY_DOWN, CHAR, (repeated CHAR as key repeats,) KEY_UP
- // The GDK model for the same sequence is just:
- // KEY_PRESS, (repeated KEY_PRESS as key repeats,) KEY_RELEASE
- // So we must simulate a CHAR event for every key press.
- if (event->type == GDK_KEY_PRESS) {
- wke.type = WebKeyboardEvent::CHAR;
- host->webwidget()->HandleInputEvent(&wke);
+ // A portion of the GdkWindow needs to be redraw.
+ static gboolean HandleExpose(GtkWidget* widget,
+ GdkEventExpose* expose,
+ WebWidgetHost* host) {
+ // See comments above about what g_handling_expose is for.
+ g_handling_expose = true;
+ gfx::Rect rect(expose->area);
+ host->UpdatePaintRect(rect);
+ host->Paint();
+ g_handling_expose = false;
+ return FALSE;
}
- return FALSE;
-}
+ // The GdkWindow was destroyed.
+ static gboolean HandleDestroy(GtkWidget* widget, WebWidgetHost* host) {
+ host->WindowDestroyed();
+ return FALSE;
+ }
-// This signal is called when arrow keys or tab is pressed. If we return true,
-// we prevent focus from being moved to another widget. If we want to allow
-// focus to be moved outside of web contents, we need to implement
-// WebViewDelegate::TakeFocus in the test webview delegate.
-gboolean FocusMove(GtkWidget* widget, GdkEventFocus* focus,
- WebWidgetHost* host) {
- return TRUE;
-}
+ // Keyboard key pressed.
+ static gboolean HandleKeyPress(GtkWidget* widget,
+ GdkEventKey* event,
+ WebWidgetHost* host) {
+ WebKeyboardEvent wke(event);
+ host->webwidget()->HandleInputEvent(&wke);
-gboolean FocusIn(GtkWidget* widget, GdkEventFocus* focus,
- WebWidgetHost* host) {
- host->webwidget()->SetFocus(true);
- return FALSE;
-}
+ // The WebKeyboardEvent model, when holding down a key, is:
+ // KEY_DOWN, CHAR, (repeated CHAR as key repeats,) KEY_UP
+ // The GDK model for the same sequence is just:
+ // KEY_PRESS, (repeated KEY_PRESS as key repeats,) KEY_RELEASE
+ // So we must simulate a CHAR event for every key press.
+ if (event->type == GDK_KEY_PRESS) {
+ wke.type = WebKeyboardEvent::CHAR;
+ host->webwidget()->HandleInputEvent(&wke);
+ }
-gboolean FocusOut(GtkWidget* widget, GdkEventFocus* focus,
- WebWidgetHost* host) {
- host->webwidget()->SetFocus(false);
- return FALSE;
-}
+ return FALSE;
+ }
+
+ // Keyboard key released.
+ static gboolean HandleKeyRelease(GtkWidget* widget,
+ GdkEventKey* event,
+ WebWidgetHost* host) {
+ return HandleKeyPress(widget, event, host);
+ }
-gboolean ButtonPressReleaseEvent(GtkWidget* widget, GdkEventButton* event,
+ // This signal is called when arrow keys or tab is pressed. If we return
+ // true, we prevent focus from being moved to another widget. If we want to
+ // allow focus to be moved outside of web contents, we need to implement
+ // WebViewDelegate::TakeFocus in the test webview delegate.
+ static gboolean HandleFocus(GtkWidget* widget,
+ GdkEventFocus* focus,
+ WebWidgetHost* host) {
+ return TRUE;
+ }
+
+ // Keyboard focus entered.
+ static gboolean HandleFocusIn(GtkWidget* widget,
+ GdkEventFocus* focus,
+ WebWidgetHost* host) {
+ host->webwidget()->SetFocus(true);
+ return FALSE;
+ }
+
+ // Keyboard focus left.
+ static gboolean HandleFocusOut(GtkWidget* widget,
+ GdkEventFocus* focus,
WebWidgetHost* host) {
- WebMouseEvent wme(event);
- host->webwidget()->HandleInputEvent(&wme);
- return FALSE;
-}
+ host->webwidget()->SetFocus(false);
+ return FALSE;
+ }
-gboolean MouseMoveEvent(GtkWidget* widget, GdkEventMotion* event,
- WebWidgetHost* host) {
- WebMouseEvent wme(event);
- host->webwidget()->HandleInputEvent(&wme);
- return FALSE;
-}
+ // Mouse button down.
+ static gboolean HandleButtonPress(GtkWidget* widget,
+ GdkEventButton* event,
+ WebWidgetHost* host) {
+ WebMouseEvent wme(event);
+ host->webwidget()->HandleInputEvent(&wme);
+ return FALSE;
+ }
-gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event,
- WebWidgetHost* host) {
- WebMouseWheelEvent wmwe(event);
- host->webwidget()->HandleInputEvent(&wmwe);
- return FALSE;
-}
+ // Mouse button up.
+ static gboolean HandleButtonRelease(GtkWidget* widget,
+ GdkEventButton* event,
+ WebWidgetHost* host) {
+ return HandleButtonPress(widget, event, host);
+ }
+
+ // Mouse pointer movements.
+ static gboolean HandleMotionNotify(GtkWidget* widget,
+ GdkEventMotion* event,
+ WebWidgetHost* host) {
+ WebMouseEvent wme(event);
+ host->webwidget()->HandleInputEvent(&wme);
+ return FALSE;
+ }
+
+ // Mouse scroll wheel.
+ static gboolean HandleScroll(GtkWidget* widget,
+ GdkEventScroll* event,
+ WebWidgetHost* host) {
+ WebMouseWheelEvent wmwe(event);
+ host->webwidget()->HandleInputEvent(&wmwe);
+ return FALSE;
+ }
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(WebWidgetHostGtkWidget);
+};
} // namespace
-GtkWidget* WebWidgetHost::CreateWindow(GtkWidget* parent_view, void* host) {
- GtkWidget* widget = CustomGtkContainer::CreateNewWidget();
-
- gtk_box_pack_start(GTK_BOX(parent_view), widget, TRUE, TRUE, 0);
-
- // TODO(evanm): it might be cleaner to just have the custom widget set
- // all of this up rather than connecting signals.
- gtk_widget_add_events(widget, GDK_EXPOSURE_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK);
- GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
- g_signal_connect(widget, "configure-event", G_CALLBACK(ConfigureEvent), host);
- g_signal_connect(widget, "expose-event", G_CALLBACK(ExposeEvent), host);
- g_signal_connect(widget, "destroy", G_CALLBACK(::WindowDestroyed), host);
- g_signal_connect(widget, "key-press-event", G_CALLBACK(KeyPressReleaseEvent),
- host);
- g_signal_connect(widget, "key-release-event",
- G_CALLBACK(KeyPressReleaseEvent), host);
- g_signal_connect(widget, "focus", G_CALLBACK(FocusMove), host);
- g_signal_connect(widget, "focus-in-event", G_CALLBACK(FocusIn), host);
- g_signal_connect(widget, "focus-out-event", G_CALLBACK(FocusOut), host);
- g_signal_connect(widget, "button-press-event",
- G_CALLBACK(ButtonPressReleaseEvent), host);
- g_signal_connect(widget, "button-release-event",
- G_CALLBACK(ButtonPressReleaseEvent), host);
- g_signal_connect(widget, "motion-notify-event", G_CALLBACK(MouseMoveEvent),
- host);
- g_signal_connect(widget, "scroll-event", G_CALLBACK(MouseScrollEvent),
- host);
-
- return widget;
+// This is provided so that the webview can reuse the custom GTK window code.
+// static
+gfx::NativeView WebWidgetHost::CreateWidget(
+ gfx::NativeView parent_view, WebWidgetHost* host) {
+ return WebWidgetHostGtkWidget::CreateNewWidget(parent_view, host);
}
+// static
WebWidgetHost* WebWidgetHost::Create(GtkWidget* parent_view,
WebWidgetDelegate* delegate) {
WebWidgetHost* host = new WebWidgetHost();
- host->view_ = CreateWindow(parent_view, host);
+ host->view_ = CreateWidget(parent_view, host);
host->webwidget_ = WebWidget::Create(delegate);
// We manage our own double buffering because we need to be able to update
// the expose area in an ExposeEvent within the lifetime of the event handler.
@@ -286,7 +244,7 @@ void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
UpdatePaintRect(damaged_rect);
- if (!handling_expose) {
+ if (!g_handling_expose) {
gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(),
damaged_rect.y(), damaged_rect.width(), damaged_rect.height());
}