Commit 2f1d5f56 authored by braveyao's avatar braveyao Committed by Commit bot

Fix Aura can't provide accurate cursor hotspot info.

On Linux,  device scale factor is not set.
On Win, there is no API to offer hotspot of a cursor.
This cl addresses the above two problems.

BUG=676687

Review-Url: https://codereview.chromium.org/2605773002
Cr-Commit-Position: refs/heads/master@{#441790}
parent 9d13a981
......@@ -284,6 +284,7 @@ void CursorLoaderX11::SetPlatformCursor(gfx::NativeCursor* cursor) {
if (*cursor == kCursorCustom)
return;
cursor->set_device_scale_factor(scale());
cursor->SetPlatformCursor(CursorFromId(cursor->native_type()));
}
......
......@@ -239,6 +239,7 @@ bool GetCursorBitmap(const Cursor& cursor,
cursor_loader.SetPlatformCursor(&cursor_copy);
const std::unique_ptr<SkBitmap> cursor_bitmap(
IconUtil::CreateSkBitmapFromHICON(cursor_copy.platform()));
*point = IconUtil::GetHotSpotFromHICON(cursor_copy.platform());
#else
int resource_id;
if (!GetCursorDataFor(ui::CURSOR_SET_NORMAL,
......
......@@ -369,6 +369,14 @@ base::win::ScopedHICON IconUtil::CreateCursorFromDIB(const gfx::Size& icon_size,
return base::win::ScopedHICON(CreateIconIndirect(&ii));
}
gfx::Point IconUtil::GetHotSpotFromHICON(HICON icon) {
ScopedICONINFO icon_info;
gfx::Point hotspot;
if (::GetIconInfo(icon, &icon_info))
hotspot = gfx::Point(icon_info.xHotspot, icon_info.yHotspot);
return hotspot;
}
SkBitmap IconUtil::CreateSkBitmapFromHICONHelper(HICON icon,
const gfx::Size& s) {
DCHECK(icon);
......
......@@ -141,6 +141,10 @@ class GFX_EXPORT IconUtil {
const void* dib_bits,
size_t dib_size);
// Given a valid HICON handle representing an icon, this function retrieves
// the hot spot of the icon.
static gfx::Point GetHotSpotFromHICON(HICON icon);
private:
// The icon format is published in the MSDN but there is no definition of
// the icon file structures in any of the Windows header files so we need to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment