diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-06-08 14:03:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-06-16 08:18:09 +0000 |
commit | aaa91ea2551f7df5ff9023c8fa7743e76070bac9 (patch) | |
tree | ca997cc6633a2914151551566c6cff64cd60ff97 /src/core/render_widget_host_view_qt.cpp | |
parent | df6d3709a442591b286ceb47a3fd984a16da5d8b (diff) |
Support WebCursors Qt doesn't have cursor types for
Use Chromium's Aura cursors when we don't have Qt equivalents.
These cursors were also supported in QtWebKit. Note this
depends on Aura being used, which means OS X still doesn't
have the new cursors.
Task-number: QTBUG-53593
Change-Id: I9fbbf102dd313da5a6836069b4d7ece057d8c946
Reviewed-by: Alexandru Croitor <alexandru.croitor@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index a0dcb8197..220761ef3 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -68,6 +68,10 @@ #include "ui/events/gesture_detection/motion_event.h" #include "ui/gfx/geometry/size_conversions.h" +#if defined(USE_AURA) +#include "ui/base/cursor/cursors_aura.h" +#endif + #include <QEvent> #include <QFocusEvent> #include <QGuiApplication> @@ -455,7 +459,10 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) { content::WebCursor::CursorInfo cursorInfo; webCursor.GetCursorInfo(&cursorInfo); - Qt::CursorShape shape; + Qt::CursorShape shape = Qt::ArrowCursor; +#if defined(USE_AURA) + int auraType = -1; +#endif switch (cursorInfo.type) { case blink::WebCursorInfo::TypePointer: shape = Qt::ArrowCursor; @@ -513,17 +520,42 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) case blink::WebCursorInfo::TypeMove: shape = Qt::SizeAllCursor; break; + case blink::WebCursorInfo::TypeProgress: + shape = Qt::BusyCursor; + break; +#if defined(USE_AURA) case blink::WebCursorInfo::TypeVerticalText: + auraType = ui::kCursorVerticalText; + break; case blink::WebCursorInfo::TypeCell: + auraType = ui::kCursorCell; + break; case blink::WebCursorInfo::TypeContextMenu: + auraType = ui::kCursorContextMenu; + break; case blink::WebCursorInfo::TypeAlias: - case blink::WebCursorInfo::TypeProgress: + auraType = ui::kCursorAlias; + break; case blink::WebCursorInfo::TypeCopy: + auraType = ui::kCursorCopy; + break; case blink::WebCursorInfo::TypeZoomIn: + auraType = ui::kCursorZoomIn; + break; case blink::WebCursorInfo::TypeZoomOut: - // FIXME: Load from the resource bundle. - shape = Qt::ArrowCursor; + auraType = ui::kCursorZoomOut; + break; +#else + case blink::WebCursorInfo::TypeVerticalText: + case blink::WebCursorInfo::TypeCell: + case blink::WebCursorInfo::TypeContextMenu: + case blink::WebCursorInfo::TypeAlias: + case blink::WebCursorInfo::TypeCopy: + case blink::WebCursorInfo::TypeZoomIn: + case blink::WebCursorInfo::TypeZoomOut: + // FIXME: Support on OS X break; +#endif case blink::WebCursorInfo::TypeNoDrop: case blink::WebCursorInfo::TypeNotAllowed: shape = Qt::ForbiddenCursor; @@ -543,13 +575,18 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor), cursorInfo.hotspot.x(), cursorInfo.hotspot.y())); return; } - // Use arrow cursor as fallback in case the Chromium implementation changes. - shape = Qt::ArrowCursor; break; - default: - Q_UNREACHABLE(); - shape = Qt::ArrowCursor; } +#if defined(USE_AURA) + if (auraType > 0) { + SkBitmap bitmap; + gfx::Point hotspot; + if (ui::GetCursorBitmap(auraType, &bitmap, &hotspot)) { + m_delegate->updateCursor(QCursor(QPixmap::fromImage(toQImage(bitmap)), hotspot.x(), hotspot.y())); + return; + } + } +#endif m_delegate->updateCursor(QCursor(shape)); } |