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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc

Issue 2739113002: Simplify calls for scale factor (Closed)
Patch Set: Display::GetForcedDeviceScaleFactor() Created 3 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 10
11 #include "base/event_types.h" 11 #include "base/event_types.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "ui/aura/client/capture_client.h" 18 #include "ui/aura/client/capture_client.h"
19 #include "ui/aura/client/drag_drop_client.h" 19 #include "ui/aura/client/drag_drop_client.h"
20 #include "ui/aura/client/drag_drop_delegate.h" 20 #include "ui/aura/client/drag_drop_delegate.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/aura/window_tree_host.h" 22 #include "ui/aura/window_tree_host.h"
23 #include "ui/base/clipboard/clipboard.h" 23 #include "ui/base/clipboard/clipboard.h"
24 #include "ui/base/dragdrop/drop_target_event.h" 24 #include "ui/base/dragdrop/drop_target_event.h"
25 #include "ui/base/dragdrop/os_exchange_data.h" 25 #include "ui/base/dragdrop/os_exchange_data.h"
26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" 26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
27 #include "ui/base/layout.h"
27 #include "ui/base/x/selection_utils.h" 28 #include "ui/base/x/selection_utils.h"
28 #include "ui/base/x/x11_util.h" 29 #include "ui/base/x/x11_util.h"
29 #include "ui/base/x/x11_window_event_manager.h" 30 #include "ui/base/x/x11_window_event_manager.h"
30 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
31 #include "ui/events/event.h" 32 #include "ui/events/event.h"
32 #include "ui/events/event_utils.h" 33 #include "ui/events/event_utils.h"
33 #include "ui/events/platform/platform_event_source.h" 34 #include "ui/events/platform/platform_event_source.h"
34 #include "ui/gfx/image/image_skia.h" 35 #include "ui/gfx/image/image_skia.h"
35 #include "ui/views/controls/image_view.h" 36 #include "ui/views/controls/image_view.h"
36 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" 37 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 void DesktopDragDropClientAuraX11::OnWindowDestroyed(aura::Window* window) { 887 void DesktopDragDropClientAuraX11::OnWindowDestroyed(aura::Window* window) {
887 DCHECK_EQ(target_window_, window); 888 DCHECK_EQ(target_window_, window);
888 target_window_ = NULL; 889 target_window_ = NULL;
889 } 890 }
890 891
891 void DesktopDragDropClientAuraX11::OnMouseMovement( 892 void DesktopDragDropClientAuraX11::OnMouseMovement(
892 const gfx::Point& screen_point, 893 const gfx::Point& screen_point,
893 int flags, 894 int flags,
894 base::TimeTicks event_time) { 895 base::TimeTicks event_time) {
895 if (drag_widget_.get()) { 896 if (drag_widget_.get()) {
896 display::Display display = 897 float scale_factor =
897 display::Screen::GetScreen()->GetDisplayNearestWindow( 898 ui::GetScaleFactorForNativeView(drag_widget_->GetNativeWindow());
898 drag_widget_->GetNativeWindow()); 899 gfx::Point scaled_point =
899 gfx::Point scaled_point = gfx::ScaleToRoundedPoint( 900 gfx::ScaleToRoundedPoint(screen_point, 1.f / scale_factor);
900 screen_point, 1.f / display.device_scale_factor());
901 drag_widget_->SetBounds( 901 drag_widget_->SetBounds(
902 gfx::Rect(scaled_point - drag_widget_offset_, drag_image_size_)); 902 gfx::Rect(scaled_point - drag_widget_offset_, drag_image_size_));
903 drag_widget_->StackAtTop(); 903 drag_widget_->StackAtTop();
904 } 904 }
905 905
906 const int kModifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | 906 const int kModifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN |
907 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN | 907 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN |
908 ui::EF_LEFT_MOUSE_BUTTON | 908 ui::EF_LEFT_MOUSE_BUTTON |
909 ui::EF_MIDDLE_MOUSE_BUTTON | 909 ui::EF_MIDDLE_MOUSE_BUTTON |
910 ui::EF_RIGHT_MOUSE_BUTTON; 910 ui::EF_RIGHT_MOUSE_BUTTON;
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 for (int x = 0; x < in_bitmap->width(); ++x) { 1359 for (int x = 0; x < in_bitmap->width(); ++x) {
1360 if (SkColorGetA(in_row[x]) > kMinAlpha) 1360 if (SkColorGetA(in_row[x]) > kMinAlpha)
1361 return true; 1361 return true;
1362 } 1362 }
1363 } 1363 }
1364 1364
1365 return false; 1365 return false;
1366 } 1366 }
1367 1367
1368 } // namespace views 1368 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698