Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Unified Diff: ui/base/dragdrop/drag_utils_win.cc

Issue 1475263002: Ensure that the drag image during drag drop operations on Windows is of the correct scale. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/dragdrop/drag_utils_win.cc
diff --git a/ui/base/dragdrop/drag_utils_win.cc b/ui/base/dragdrop/drag_utils_win.cc
index 9fedd4202a34ac8e32614fd9de5b9d15a07b8407..e2c5b601bdcd93373c20f964d2edd19ce1070af8 100644
--- a/ui/base/dragdrop/drag_utils_win.cc
+++ b/ui/base/dragdrop/drag_utils_win.cc
@@ -18,9 +18,14 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/skbitmap_operations.h"
+#include "ui/gfx/win/dpi.h"
namespace drag_utils {
+// The DragDropHelper object on Windows supports images with width upto 300 px.
+// Images with widths more than that are clipped.
+const int kMaxDragImageWidth = 300;
+
static void SetDragImageOnDataObject(HBITMAP hbitmap,
const gfx::Size& size_in_pixels,
const gfx::Vector2d& cursor_offset,
@@ -31,9 +36,13 @@ static void SetDragImageOnDataObject(HBITMAP hbitmap,
if (SUCCEEDED(rv)) {
SHDRAGIMAGE sdi;
sdi.sizeDragImage = size_in_pixels.ToSIZE();
+ sdi.sizeDragImage.cx =
+ std::min<int>(kMaxDragImageWidth, sdi.sizeDragImage.cx);
ananta 2015/12/01 02:47:07 If the width is more than 300 the bitmap is displa
sdi.crColorKey = 0xFFFFFFFF;
sdi.hbmpDragImage = hbitmap;
- sdi.ptOffset = gfx::PointAtOffsetFromOrigin(cursor_offset).ToPOINT();
+ gfx::Point point_at_offset_in_pixels = gfx::win::DIPToScreenPoint(
+ gfx::PointAtOffsetFromOrigin(cursor_offset));
+ sdi.ptOffset = point_at_offset_in_pixels.ToPOINT();
helper->InitializeFromBitmap(&sdi, data_object);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698