diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 17:02:06 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 17:02:06 +0000 |
commit | 0c1501597ff71ef3caeded51c2a78d60485bbc27 (patch) | |
tree | 94a32a33df82c6f8c0ae89f462c40996b03c4ed8 /ui | |
parent | e000daf98b303e597bfd74ac961ec8c976519d7a (diff) | |
download | chromium_src-0c1501597ff71ef3caeded51c2a78d60485bbc27.zip chromium_src-0c1501597ff71ef3caeded51c2a78d60485bbc27.tar.gz chromium_src-0c1501597ff71ef3caeded51c2a78d60485bbc27.tar.bz2 |
aura-x11: A couple of cursor related fixes for high-dpi.
* Use the hot-spot for 1x cursors when resources for 2x cursors haven't been loaded.
* Make sure the cursor hot-spots are always within the bounds of the cursor images.
BUG=265028
R=sky@chromium.org, varunjain@chromium.org
Review URL: https://codereview.chromium.org/21342002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/cursor/cursors_aura.cc | 6 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/ui/base/cursor/cursors_aura.cc b/ui/base/cursor/cursors_aura.cc index 400e54c..17349a7 100644 --- a/ui/base/cursor/cursors_aura.cc +++ b/ui/base/cursor/cursors_aura.cc @@ -6,6 +6,7 @@ #include "grit/ui_resources.h" #include "ui/base/cursor/cursor.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/point.h" namespace ui { @@ -77,10 +78,13 @@ bool SearchTable(const CursorData* table, float scale_factor, int* resource_id, gfx::Point* point) { + bool resource_2x_available = + ResourceBundle::GetSharedInstance().max_scale_factor() == + SCALE_FACTOR_200P; for (size_t i = 0; i < table_length; ++i) { if (table[i].id == id) { *resource_id = table[i].resource_id; - *point = scale_factor == 1.0f ? + *point = scale_factor == 1.0f || !resource_2x_available ? gfx::Point(table[i].hot_1x.x, table[i].hot_1x.y) : gfx::Point(table[i].hot_2x.x, table[i].hot_2x.y); return true; diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 663a9eb..836feae 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -475,8 +475,8 @@ XcursorImage* SkBitmapToXcursorImage(const SkBitmap* cursor_image, const SkBitmap* bitmap = needs_scale ? &scaled : cursor_image; XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height()); - image->xhot = hotspot_point.x(); - image->yhot = hotspot_point.y(); + image->xhot = std::min(bitmap->width() - 1, hotspot_point.x()); + image->yhot = std::min(bitmap->height() - 1, hotspot_point.y()); if (bitmap->width() && bitmap->height()) { bitmap->lockPixels(); |