summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 18:28:50 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 18:28:50 +0000
commitbe18d3eae2db247dc5a0e211cc97579620324641 (patch)
tree4b3bfe1413bd6c714a048e5cca80a02938fce9e3 /webkit
parent0d8a7a1b0662e50c962cd3f14d7ef1a65d5a630b (diff)
downloadchromium_src-be18d3eae2db247dc5a0e211cc97579620324641.zip
chromium_src-be18d3eae2db247dc5a0e211cc97579620324641.tar.gz
chromium_src-be18d3eae2db247dc5a0e211cc97579620324641.tar.bz2
Basic cursor support.
Review URL: http://codereview.chromium.org/9744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/SConscript5
-rw-r--r--webkit/glue/webcursor.h7
-rw-r--r--webkit/glue/webcursor_gtk.cc107
-rw-r--r--webkit/tools/test_shell/gtk/test_webview_delegate.cc15
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h13
5 files changed, 145 insertions, 2 deletions
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript
index ffbcda5..6476ffd 100644
--- a/webkit/glue/SConscript
+++ b/webkit/glue/SConscript
@@ -108,6 +108,9 @@ if env['PLATFORM'] == 'win32':
'webkit_glue_win.cc',
])
elif env['PLATFORM'] == 'posix':
- input_files.append('webinputevent_linux.cc')
+ input_files.extend([
+ 'webcursor_gtk.cc',
+ 'webinputevent_linux.cc',
+ ])
env.ChromeStaticLibrary('glue', input_files)
diff --git a/webkit/glue/webcursor.h b/webkit/glue/webcursor.h
index 92e27f3..7775751 100644
--- a/webkit/glue/webcursor.h
+++ b/webkit/glue/webcursor.h
@@ -14,6 +14,9 @@
typedef struct HINSTANCE__* HINSTANCE;
typedef struct HICON__* HICON;
typedef HICON HCURSOR;
+#elif defined(OS_LINUX)
+// GdkCursorType is an enum, which we can't forward-declare. :(
+#include <gdk/gdkcursor.h>
#endif
class Pickle;
@@ -58,6 +61,10 @@ class WebCursor {
// Initialize this from the given Windows cursor.
void InitFromCursor(HCURSOR handle);
+#elif defined(OS_LINUX)
+ // Return the stock GdkCursorType for this cursor, or GDK_CURSOR_IS_PIXMAP
+ // if it's a custom cursor.
+ GdkCursorType GetCursorType() const;
#endif
private:
diff --git a/webkit/glue/webcursor_gtk.cc b/webkit/glue/webcursor_gtk.cc
new file mode 100644
index 0000000..6224804
--- /dev/null
+++ b/webkit/glue/webcursor_gtk.cc
@@ -0,0 +1,107 @@
+// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "webkit/glue/webcursor.h"
+
+#include "config.h"
+#include "PlatformCursor.h"
+
+#undef LOG
+#include "base/logging.h"
+
+using WebCore::PlatformCursor;
+
+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
+ // change everything.
+ switch (type_) {
+ case PlatformCursor::typePointer:
+ return GDK_ARROW;
+ case PlatformCursor::typeCross:
+ return GDK_CROSS;
+ case PlatformCursor::typeHand:
+ return GDK_HAND2;
+ case PlatformCursor::typeIBeam:
+ return GDK_XTERM;
+ case PlatformCursor::typeWait:
+ return GDK_WATCH;
+ case PlatformCursor::typeHelp:
+ return GDK_QUESTION_ARROW;
+ case PlatformCursor::typeEastResize:
+ return GDK_RIGHT_SIDE;
+ case PlatformCursor::typeNorthResize:
+ return GDK_TOP_SIDE;
+ case PlatformCursor::typeNorthEastResize:
+ return GDK_TOP_RIGHT_CORNER;
+ case PlatformCursor::typeNorthWestResize:
+ return GDK_TOP_LEFT_CORNER;
+ case PlatformCursor::typeSouthResize:
+ return GDK_BOTTOM_SIDE;
+ case PlatformCursor::typeSouthEastResize:
+ return GDK_BOTTOM_LEFT_CORNER;
+ case PlatformCursor::typeSouthWestResize:
+ return GDK_BOTTOM_RIGHT_CORNER;
+ case PlatformCursor::typeWestResize:
+ return GDK_LEFT_SIDE;
+ case PlatformCursor::typeNorthSouthResize:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeEastWestResize:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeNorthEastSouthWestResize:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeNorthWestSouthEastResize:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeColumnResize:
+ return GDK_SB_H_DOUBLE_ARROW; // TODO(evanm): is this correct?
+ case PlatformCursor::typeRowResize:
+ return GDK_SB_V_DOUBLE_ARROW; // TODO(evanm): is this correct?
+ case PlatformCursor::typeMiddlePanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeEastPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeNorthPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeNorthEastPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeNorthWestPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeSouthPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeSouthEastPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeSouthWestPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeWestPanning:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeMove:
+ return GDK_FLEUR;
+ case PlatformCursor::typeVerticalText:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeCell:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeContextMenu:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeAlias:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeProgress:
+ return GDK_WATCH;
+ case PlatformCursor::typeNoDrop:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeCopy:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ case PlatformCursor::typeNone:
+ NOTIMPLEMENTED(); return GDK_ARROW;
+ 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;
+ }
+ NOTREACHED();
+ return GDK_ARROW;
+}
diff --git a/webkit/tools/test_shell/gtk/test_webview_delegate.cc b/webkit/tools/test_shell/gtk/test_webview_delegate.cc
index e251117..e934fd2c 100644
--- a/webkit/tools/test_shell/gtk/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/gtk/test_webview_delegate.cc
@@ -12,6 +12,7 @@
#include "base/string_util.h"
#include "net/base/net_errors.h"
#include "chrome/common/page_transition_types.h"
+#include "webkit/glue/webcursor.h"
#include "webkit/glue/webdatasource.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/weberror.h"
@@ -54,7 +55,19 @@ void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
void TestWebViewDelegate::SetCursor(WebWidget* webwidget,
const WebCursor& cursor) {
- NOTIMPLEMENTED();
+ GdkCursorType cursor_type = cursor.GetCursorType();
+ if (cursor_type_ == cursor_type)
+ return;
+
+ cursor_type_ = cursor_type;
+ if (cursor_type_ == GDK_CURSOR_IS_PIXMAP) {
+ NOTIMPLEMENTED();
+ cursor_type = GDK_ARROW; // Just a hack for now.
+ }
+ GdkCursor* gdk_cursor = gdk_cursor_new(cursor_type);
+ gdk_window_set_cursor(shell_->webViewWnd()->window, gdk_cursor);
+ // The window now owns the cursor.
+ gdk_cursor_unref(gdk_cursor);
}
void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget,
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 9c54213..d083e8a 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -16,6 +16,10 @@
#endif
#include <map>
+#if defined(OS_LINUX)
+#include <gdk/gdkcursor.h>
+#endif
+
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "webkit/glue/webview_delegate.h"
@@ -59,6 +63,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
last_page_id_updated_(-1)
#if defined(OS_WIN)
, custom_cursor_(NULL)
+#elif defined(OS_LINUX)
+ , cursor_type_(GDK_X_CURSOR)
#endif
{
}
@@ -300,6 +306,13 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
scoped_refptr<TestDragDelegate> drag_delegate_;
scoped_refptr<TestDropDelegate> drop_delegate_;
#endif
+
+#if defined(OS_LINUX)
+ // The type of cursor the window is currently using.
+ // Used for judging whether a new SetCursor call is actually changing the
+ // cursor.
+ GdkCursorType cursor_type_;
+#endif
CapturedContextMenuEvents captured_context_menu_events_;