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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 void DesktopDragDropClientAuraX11::OnWindowDestroyed(aura::Window* window) { 760 void DesktopDragDropClientAuraX11::OnWindowDestroyed(aura::Window* window) {
761 DCHECK_EQ(target_window_, window); 761 DCHECK_EQ(target_window_, window);
762 target_window_ = NULL; 762 target_window_ = NULL;
763 } 763 }
764 764
765 void DesktopDragDropClientAuraX11::OnMouseMovement( 765 void DesktopDragDropClientAuraX11::OnMouseMovement(
766 const gfx::Point& screen_point, 766 const gfx::Point& screen_point,
767 int flags, 767 int flags,
768 base::TimeDelta event_time) { 768 base::TimeDelta event_time) {
769 if (drag_widget_.get()) { 769 if (drag_widget_.get()) {
770 display::Display display =
771 display::Screen::GetScreen()->GetDisplayNearestWindow(
772 drag_widget_->GetNativeWindow());
773 gfx::Point scaled_point = gfx::ScaleToRoundedPoint(
774 screen_point, 1.f / display.device_scale_factor());
770 drag_widget_->SetBounds( 775 drag_widget_->SetBounds(
771 gfx::Rect(screen_point - drag_widget_offset_, 776 gfx::Rect(scaled_point - drag_widget_offset_, drag_image_size_));
772 drag_widget_->GetWindowBoundsInScreen().size()));
773 drag_widget_->StackAtTop(); 777 drag_widget_->StackAtTop();
774 } 778 }
775 779
776 const int kModifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | 780 const int kModifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN |
777 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN | 781 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN |
778 ui::EF_LEFT_MOUSE_BUTTON | 782 ui::EF_LEFT_MOUSE_BUTTON |
779 ui::EF_MIDDLE_MOUSE_BUTTON | 783 ui::EF_MIDDLE_MOUSE_BUTTON |
780 ui::EF_RIGHT_MOUSE_BUTTON; 784 ui::EF_RIGHT_MOUSE_BUTTON;
781 current_modifier_state_ = flags & kModifiers; 785 current_modifier_state_ = flags & kModifiers;
782 786
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 1193
1190 gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint() - 1194 gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint() -
1191 drag_widget_offset_; 1195 drag_widget_offset_;
1192 params.bounds = gfx::Rect(location, image.size()); 1196 params.bounds = gfx::Rect(location, image.size());
1193 widget->set_focus_on_creation(false); 1197 widget->set_focus_on_creation(false);
1194 widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE); 1198 widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE);
1195 widget->Init(params); 1199 widget->Init(params);
1196 widget->SetOpacity(kDragWidgetOpacity); 1200 widget->SetOpacity(kDragWidgetOpacity);
1197 widget->GetNativeWindow()->SetName("DragWindow"); 1201 widget->GetNativeWindow()->SetName("DragWindow");
1198 1202
1203 drag_image_size_ = image.size();
1199 ImageView* image_view = new ImageView(); 1204 ImageView* image_view = new ImageView();
1200 image_view->SetImage(image); 1205 image_view->SetImage(image);
1201 image_view->SetBounds(0, 0, image.width(), image.height()); 1206 image_view->SetBoundsRect(gfx::Rect(drag_image_size_));
1202 widget->SetContentsView(image_view); 1207 widget->SetContentsView(image_view);
1203 widget->Show(); 1208 widget->Show();
1204 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); 1209 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false);
1205 1210
1206 drag_widget_.reset(widget); 1211 drag_widget_.reset(widget);
1207 } 1212 }
1208 1213
1209 bool DesktopDragDropClientAuraX11::IsValidDragImage( 1214 bool DesktopDragDropClientAuraX11::IsValidDragImage(
1210 const gfx::ImageSkia& image) { 1215 const gfx::ImageSkia& image) {
1211 if (image.isNull()) 1216 if (image.isNull())
(...skipping 10 matching lines...) Expand all
1222 for (int x = 0; x < in_bitmap->width(); ++x) { 1227 for (int x = 0; x < in_bitmap->width(); ++x) {
1223 if (SkColorGetA(in_row[x]) > kMinAlpha) 1228 if (SkColorGetA(in_row[x]) > kMinAlpha)
1224 return true; 1229 return true;
1225 } 1230 }
1226 } 1231 }
1227 1232
1228 return false; 1233 return false;
1229 } 1234 }
1230 1235
1231 } // namespace views 1236 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698