diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 08:03:26 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 08:03:26 +0000 |
commit | 2c744a3a2f82490ae38b2ac4545117647a0d020a (patch) | |
tree | a2ceb3e28ac942f3bb580aa8267f398fd14bfe1b /ash | |
parent | c1a2e523ea6a58827b1d9433932e529534c37c17 (diff) | |
download | chromium_src-2c744a3a2f82490ae38b2ac4545117647a0d020a.zip chromium_src-2c744a3a2f82490ae38b2ac4545117647a0d020a.tar.gz chromium_src-2c744a3a2f82490ae38b2ac4545117647a0d020a.tar.bz2 |
linux_aura: Use aura cursor images them on the desktop aura code.
This adds an interface in ui/ for accessing cursor images and
for getting their metadata like hotspots. An interface was then added to
DesktopNativeCursorManager so that linux_aura could load these cursors while
windows ignored them. This also fixes up a few other errors in the list
of cursors used on non-chromeos X11.
BUG=171517
TEST=Go to http://trac.webkit.org/export/37902/trunk/WebCore/manual-tests/cursor.html in a debug linux_aura build. Hovering over all the gray boxes shouldn't DCHECK chrome.
Review URL: https://chromiumcodereview.appspot.com/12662040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/image_cursors.cc | 142 |
1 files changed, 60 insertions, 82 deletions
diff --git a/ash/wm/image_cursors.cc b/ash/wm/image_cursors.cc index 1792c6c..547c9b3 100644 --- a/ash/wm/image_cursors.cc +++ b/ash/wm/image_cursors.cc @@ -6,84 +6,54 @@ #include "base/logging.h" #include "base/string16.h" -#include "ui/base/cursor/cursor_loader.h" #include "ui/base/cursor/cursor.h" +#include "ui/base/cursor/cursor_loader.h" +#include "ui/base/cursor/cursors_aura.h" #include "ui/gfx/display.h" #include "ui/gfx/point.h" -#include "grit/ash_resources.h" -#include "grit/ui_resources.h" - -namespace { - -const int kAnimatedCursorFrameDelayMs = 25; - -struct HotPoint { - int x; - int y; -}; -struct CursorData { - int id; - int resource_id; - HotPoint hot_1x; - HotPoint hot_2x; -}; +namespace ash { -// TODO(oshima): Remove this comment (http://crbug.com/141586). -// The cursor's hot points are defined in chromeos cursor images at: -// http://folder/kuscher/projects/Chrome_OS/Pointers/focuspoint -const CursorData kImageCursors[] = { - {ui::kCursorNull, IDR_AURA_CURSOR_PTR, {4, 4}, {8, 9}}, - {ui::kCursorPointer, IDR_AURA_CURSOR_PTR, {4, 4}, {8, 9}}, - {ui::kCursorNoDrop, IDR_AURA_CURSOR_NO_DROP, {9, 9}, {18, 18}}, - {ui::kCursorNotAllowed, IDR_AURA_CURSOR_NO_DROP, {9, 9}, {18, 18}}, - {ui::kCursorCopy, IDR_AURA_CURSOR_COPY, {9, 9}, {18, 18}}, - {ui::kCursorHand, IDR_AURA_CURSOR_HAND, {9, 4}, {19, 8}}, - {ui::kCursorMove, IDR_AURA_CURSOR_MOVE, {11, 11}, {23, 23}}, - {ui::kCursorNorthEastResize, IDR_AURA_CURSOR_NORTH_EAST_RESIZE, - {12, 11}, {25, 23}}, - {ui::kCursorSouthWestResize, IDR_AURA_CURSOR_SOUTH_WEST_RESIZE, - {12, 11}, {25, 23}}, - {ui::kCursorSouthEastResize, IDR_AURA_CURSOR_SOUTH_EAST_RESIZE, - {11, 11}, {24, 23}}, - {ui::kCursorNorthWestResize, IDR_AURA_CURSOR_NORTH_WEST_RESIZE, - {11, 11}, {24, 23}}, - {ui::kCursorNorthResize, IDR_AURA_CURSOR_NORTH_RESIZE, {11, 12}, {23, 23}}, - {ui::kCursorSouthResize, IDR_AURA_CURSOR_SOUTH_RESIZE, {11, 12}, {23, 23}}, - {ui::kCursorEastResize, IDR_AURA_CURSOR_EAST_RESIZE, {12, 11}, {25, 23}}, - {ui::kCursorWestResize, IDR_AURA_CURSOR_WEST_RESIZE, {12, 11}, {25, 23}}, - {ui::kCursorIBeam, IDR_AURA_CURSOR_IBEAM, {12, 12}, {24, 25}}, - {ui::kCursorAlias, IDR_AURA_CURSOR_ALIAS, {8, 6}, {15, 11}}, - {ui::kCursorCell, IDR_AURA_CURSOR_CELL, {11, 11}, {24, 23}}, - {ui::kCursorContextMenu, IDR_AURA_CURSOR_CONTEXT_MENU, {4, 4}, {8, 9}}, - {ui::kCursorCross, IDR_AURA_CURSOR_CROSSHAIR, {12, 12}, {25, 23}}, - {ui::kCursorHelp, IDR_AURA_CURSOR_HELP, {4, 4}, {8, 9}}, - {ui::kCursorVerticalText, IDR_AURA_CURSOR_XTERM_HORIZ, {12, 11}, {26, 23}}, - {ui::kCursorZoomIn, IDR_AURA_CURSOR_ZOOM_IN, {10, 10}, {20, 20}}, - {ui::kCursorZoomOut, IDR_AURA_CURSOR_ZOOM_OUT, {10, 10}, {20, 20}}, - {ui::kCursorRowResize, IDR_AURA_CURSOR_ROW_RESIZE, {11, 12}, {23, 23}}, - {ui::kCursorColumnResize, IDR_AURA_CURSOR_COL_RESIZE, {12, 11}, {25, 23}}, - {ui::kCursorEastWestResize, IDR_AURA_CURSOR_EAST_WEST_RESIZE, - {12, 11}, {25, 23}}, - {ui::kCursorNorthSouthResize, IDR_AURA_CURSOR_NORTH_SOUTH_RESIZE, - {11, 12}, {23, 23}}, - {ui::kCursorNorthEastSouthWestResize, - IDR_AURA_CURSOR_NORTH_EAST_SOUTH_WEST_RESIZE, {12, 11}, {25, 23}}, - {ui::kCursorNorthWestSouthEastResize, - IDR_AURA_CURSOR_NORTH_WEST_SOUTH_EAST_RESIZE, {11, 11}, {24, 23}}, - {ui::kCursorGrab, IDR_AURA_CURSOR_GRAB, {8, 5}, {16, 10}}, - {ui::kCursorGrabbing, IDR_AURA_CURSOR_GRABBING, {9, 9}, {18, 18}}, +const int kImageCursorIds[] = { + ui::kCursorNull, + ui::kCursorPointer, + ui::kCursorNoDrop, + ui::kCursorNotAllowed, + ui::kCursorCopy, + ui::kCursorHand, + ui::kCursorMove, + ui::kCursorNorthEastResize, + ui::kCursorSouthWestResize, + ui::kCursorSouthEastResize, + ui::kCursorNorthWestResize, + ui::kCursorNorthResize, + ui::kCursorSouthResize, + ui::kCursorEastResize, + ui::kCursorWestResize, + ui::kCursorIBeam, + ui::kCursorAlias, + ui::kCursorCell, + ui::kCursorContextMenu, + ui::kCursorCross, + ui::kCursorHelp, + ui::kCursorVerticalText, + ui::kCursorZoomIn, + ui::kCursorZoomOut, + ui::kCursorRowResize, + ui::kCursorColumnResize, + ui::kCursorEastWestResize, + ui::kCursorNorthSouthResize, + ui::kCursorNorthEastSouthWestResize, + ui::kCursorNorthWestSouthEastResize, + ui::kCursorGrab, + ui::kCursorGrabbing, }; -const CursorData kAnimatedCursors[] = { - {ui::kCursorWait, IDR_THROBBER, {7, 7}, {14, 14}}, - {ui::kCursorProgress, IDR_THROBBER, {7, 7}, {14, 14}}, +const int kAnimatedCursorIds[] = { + ui::kCursorWait, + ui::kCursorProgress }; -} // namespace - -namespace ash { - ImageCursors::ImageCursors() { } @@ -113,20 +83,28 @@ bool ImageCursors::SetDisplay(const gfx::Display& display) { cursor_loader_->UnloadAll(); cursor_loader_->set_display(display); - for (size_t i = 0; i < arraysize(kImageCursors); ++i) { - const HotPoint& hot = device_scale_factor == 1.0f ? - kImageCursors[i].hot_1x : kImageCursors[i].hot_2x; - cursor_loader_->LoadImageCursor(kImageCursors[i].id, - kImageCursors[i].resource_id, - gfx::Point(hot.x, hot.y)); + for (size_t i = 0; i < arraysize(kImageCursorIds); ++i) { + int resource_id = -1; + gfx::Point hot_point; + bool success = ui::GetCursorDataFor(kImageCursorIds[i], + device_scale_factor, + &resource_id, + &hot_point); + DCHECK(success); + cursor_loader_->LoadImageCursor(kImageCursorIds[i], resource_id, hot_point); } - for (size_t i = 0; i < arraysize(kAnimatedCursors); ++i) { - const HotPoint& hot = device_scale_factor == 1.0f ? - kAnimatedCursors[i].hot_1x : kAnimatedCursors[i].hot_2x; - cursor_loader_->LoadAnimatedCursor(kAnimatedCursors[i].id, - kAnimatedCursors[i].resource_id, - gfx::Point(hot.x, hot.y), - kAnimatedCursorFrameDelayMs); + for (size_t i = 0; i < arraysize(kAnimatedCursorIds); ++i) { + int resource_id = -1; + gfx::Point hot_point; + bool success = ui::GetAnimatedCursorDataFor(kAnimatedCursorIds[i], + device_scale_factor, + &resource_id, + &hot_point); + DCHECK(success); + cursor_loader_->LoadAnimatedCursor(kAnimatedCursorIds[i], + resource_id, + hot_point, + ui::kAnimatedCursorFrameDelayMs); } return true; } |