diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 15:14:32 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 15:14:32 +0000 |
commit | 3d428737173006823333a2635df6c4c15ad739a7 (patch) | |
tree | 4cbea5c89c248bbf37fe3becac760f7aee1ffb05 /webkit/glue/webcursor_gtk.cc | |
parent | 337e0feb508d32829e9a60867fd4527b008c4747 (diff) | |
download | chromium_src-3d428737173006823333a2635df6c4c15ad739a7.zip chromium_src-3d428737173006823333a2635df6c4c15ad739a7.tar.gz chromium_src-3d428737173006823333a2635df6c4c15ad739a7.tar.bz2 |
Linux: Implement WebCursorInfo::TypeNone (i.e., invisible) cursor.
BUG=48906
TEST=Write a Pepper plugin which uses the Pepper API to set an invisible cursor. Make sure the cursor disappears over the plugin area.
Review URL: http://codereview.chromium.org/2958007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webcursor_gtk.cc')
-rw-r--r-- | webkit/glue/webcursor_gtk.cc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/webkit/glue/webcursor_gtk.cc b/webkit/glue/webcursor_gtk.cc index a184e69..70c0f46 100644 --- a/webkit/glue/webcursor_gtk.cc +++ b/webkit/glue/webcursor_gtk.cc @@ -5,6 +5,7 @@ #include "webkit/glue/webcursor.h" #include <gdk/gdk.h> +#include <gtk/gtk.h> #include "base/logging.h" #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" @@ -38,6 +39,21 @@ GdkCursor* GetInlineCustomCursor(CustomCursorType type) { return cursor; } +// For GTK 2.16 and beyond, GDK_BLANK_CURSOR is available. Before, we have to +// use a custom cursor. +#if !GTK_CHECK_VERSION(2, 16, 0) +// Get/create a custom cursor which is invisible. +GdkCursor* GetInvisibleCustomCursor() { + const char bits[] = { 0 }; + const GdkColor color = { 0, 0, 0, 0 }; + GdkPixmap* bitmap = gdk_bitmap_create_from_data(NULL, bits, 1, 1); + GdkCursor* cursor = + gdk_cursor_new_from_pixmap(bitmap, bitmap, &color, &color, 0, 0); + g_object_unref(bitmap); + return cursor; +} +#endif + } // end anonymous namespace int WebCursor::GetCursorType() const { @@ -120,7 +136,12 @@ int WebCursor::GetCursorType() const { case WebCursorInfo::TypeCopy: NOTIMPLEMENTED(); return GDK_LAST_CURSOR; case WebCursorInfo::TypeNone: - NOTIMPLEMENTED(); return GDK_LAST_CURSOR; +// See comment above |GetInvisibleCustomCursor()|. +#if !GTK_CHECK_VERSION(2, 16, 0) + return GDK_CURSOR_IS_PIXMAP; +#else + return GDK_BLANK_CURSOR; +#endif case WebCursorInfo::TypeNotAllowed: NOTIMPLEMENTED(); return GDK_LAST_CURSOR; case WebCursorInfo::TypeZoomIn: @@ -134,6 +155,11 @@ int WebCursor::GetCursorType() const { GdkCursor* WebCursor::GetCustomCursor() const { switch (type_) { +// See comment above |GetInvisibleCustomCursor()|. +#if !GTK_CHECK_VERSION(2, 16, 0) + case WebCursorInfo::TypeNone: + return GetInvisibleCustomCursor(); +#endif case WebCursorInfo::TypeZoomIn: return GetInlineCustomCursor(CustomCursorZoomIn); case WebCursorInfo::TypeZoomOut: |