diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 03:42:02 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 03:42:02 +0000 |
commit | 97620e52f695007e5d810a2c0ef09b2cee3ff7c2 (patch) | |
tree | ea08fd711a7ede248aa944385204b0076ad6dedd /webkit/glue/webcursor_gtk.cc | |
parent | 1c41af415bd13bf25db073ee898eb416ead52ef4 (diff) | |
download | chromium_src-97620e52f695007e5d810a2c0ef09b2cee3ff7c2.zip chromium_src-97620e52f695007e5d810a2c0ef09b2cee3ff7c2.tar.gz chromium_src-97620e52f695007e5d810a2c0ef09b2cee3ff7c2.tar.bz2 |
Handle the zoom cursors properly by copying more code out of WebKit's GTK port.
Review URL: http://codereview.chromium.org/13079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webcursor_gtk.cc')
-rw-r--r-- | webkit/glue/webcursor_gtk.cc | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/webkit/glue/webcursor_gtk.cc b/webkit/glue/webcursor_gtk.cc index 6607d67..bb66be7 100644 --- a/webkit/glue/webcursor_gtk.cc +++ b/webkit/glue/webcursor_gtk.cc @@ -14,6 +14,35 @@ using WebCore::PlatformCursor; +namespace { + +// webcursor_gtk_data.h is taken directly from WebKit's CursorGtk.h. +#include "webkit/glue/webcursor_gtk_data.h" + +// This helper function is taken directly from WebKit's CursorGtk.cpp. +// It attempts to create a custom cursor from the data inlined in +// webcursor_gtk_data.h. +GdkCursor* GetInlineCustomCursor(CustomCursorType type) { + const CustomCursor& custom = CustomCursors[type]; + GdkCursor* cursor = gdk_cursor_new_from_name(gdk_display_get_default(), + custom.name); + if (!cursor) { + const GdkColor fg = { 0, 0, 0, 0 }; + const GdkColor bg = { 65535, 65535, 65535, 65535 }; + GdkPixmap* source = gdk_bitmap_create_from_data(NULL, custom.bits, + 32, 32); + GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, custom.mask_bits, + 32, 32); + cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, + custom.hot_x, custom.hot_y); + g_object_unref(source); + g_object_unref(mask); + } + return cursor; +} + +} // end anonymous namespace + GdkCursorType WebCursor::GetCursorType() const { // http://library.gnome.org/devel/gdk/2.12/gdk-Cursors.html has images // of the default X theme, but beware that the user's cursor theme can @@ -98,9 +127,7 @@ GdkCursorType WebCursor::GetCursorType() const { case PlatformCursor::typeNotAllowed: NOTIMPLEMENTED(); return GDK_ARROW; case PlatformCursor::typeZoomIn: - NOTIMPLEMENTED(); return GDK_ARROW; case PlatformCursor::typeZoomOut: - NOTIMPLEMENTED(); return GDK_ARROW; case PlatformCursor::typeCustom: return GDK_CURSOR_IS_PIXMAP; } @@ -109,6 +136,18 @@ GdkCursorType WebCursor::GetCursorType() const { } GdkCursor* WebCursor::GetCustomCursor() const { + switch (type_) { + case PlatformCursor::typeZoomIn: + return GetInlineCustomCursor(CustomCursorZoomIn); + case PlatformCursor::typeZoomOut: + return GetInlineCustomCursor(CustomCursorZoomOut); + } + + if (type_ != PlatformCursor::typeCustom) { + NOTREACHED(); + return NULL; + } + const guchar* data = reinterpret_cast<const guchar*>(&custom_data_[0]); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(data, |