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

Unified Diff: ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc

Issue 2006463002: Scale the location of drag image for high DPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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
Index: ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
index c133595c1232d980619f041deca5d0dfb7f94a95..cbe21d44ed67f88bba16fda36b2607935e98c3f5 100644
--- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
+++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
@@ -767,9 +767,13 @@ void DesktopDragDropClientAuraX11::OnMouseMovement(
int flags,
base::TimeDelta event_time) {
if (drag_widget_.get()) {
+ display::Display display =
+ display::Screen::GetScreen()->GetDisplayNearestWindow(
+ drag_widget_->GetNativeWindow());
+ gfx::Point scaled_point = gfx::ScaleToRoundedPoint(
+ screen_point, 1.f / display.device_scale_factor());
drag_widget_->SetBounds(
- gfx::Rect(screen_point - drag_widget_offset_,
- drag_widget_->GetWindowBoundsInScreen().size()));
+ gfx::Rect(scaled_point - drag_widget_offset_, drag_image_size_));
drag_widget_->StackAtTop();
}
@@ -1196,9 +1200,10 @@ void DesktopDragDropClientAuraX11::CreateDragWidget(
widget->SetOpacity(kDragWidgetOpacity);
widget->GetNativeWindow()->SetName("DragWindow");
+ drag_image_size_ = image.size();
ImageView* image_view = new ImageView();
image_view->SetImage(image);
- image_view->SetBounds(0, 0, image.width(), image.height());
+ image_view->SetBoundsRect(gfx::Rect(drag_image_size_));
widget->SetContentsView(image_view);
widget->Show();
widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false);

Powered by Google App Engine
This is Rietveld 408576698