OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/display/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/common/display/display_info.h" | 9 #include "ash/common/display/display_info.h" |
10 #include "ash/common/shelf/shelf.h" | 10 #include "ash/common/shelf/shelf.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "ui/display/manager/display_layout.h" | 27 #include "ui/display/manager/display_layout.h" |
28 #include "ui/display/screen.h" | 28 #include "ui/display/screen.h" |
29 #include "ui/events/event_handler.h" | 29 #include "ui/events/event_handler.h" |
30 #include "ui/events/test/event_generator.h" | 30 #include "ui/events/test/event_generator.h" |
31 #include "ui/gfx/geometry/rect_conversions.h" | 31 #include "ui/gfx/geometry/rect_conversions.h" |
32 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
33 | 33 |
34 namespace ash { | 34 namespace ash { |
35 namespace { | 35 namespace { |
36 | 36 |
37 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; | 37 const char kWallpaperView[] = "WallpaperView"; |
38 | 38 |
39 class TestEventHandler : public ui::EventHandler { | 39 class TestEventHandler : public ui::EventHandler { |
40 public: | 40 public: |
41 TestEventHandler() | 41 TestEventHandler() |
42 : target_root_(nullptr), | 42 : target_root_(nullptr), |
43 touch_radius_x_(0.0), | 43 touch_radius_x_(0.0), |
44 touch_radius_y_(0.0), | 44 touch_radius_y_(0.0), |
45 scroll_x_offset_(0.0), | 45 scroll_x_offset_(0.0), |
46 scroll_y_offset_(0.0), | 46 scroll_y_offset_(0.0), |
47 scroll_x_offset_ordinal_(0.0), | 47 scroll_x_offset_ordinal_(0.0), |
48 scroll_y_offset_ordinal_(0.0) {} | 48 scroll_y_offset_ordinal_(0.0) {} |
49 ~TestEventHandler() override {} | 49 ~TestEventHandler() override {} |
50 | 50 |
51 void OnMouseEvent(ui::MouseEvent* event) override { | 51 void OnMouseEvent(ui::MouseEvent* event) override { |
52 if (event->flags() & ui::EF_IS_SYNTHESIZED) | 52 if (event->flags() & ui::EF_IS_SYNTHESIZED) |
53 return; | 53 return; |
54 aura::Window* target = static_cast<aura::Window*>(event->target()); | 54 aura::Window* target = static_cast<aura::Window*>(event->target()); |
55 mouse_location_ = event->root_location(); | 55 mouse_location_ = event->root_location(); |
56 target_root_ = target->GetRootWindow(); | 56 target_root_ = target->GetRootWindow(); |
57 event->StopPropagation(); | 57 event->StopPropagation(); |
58 } | 58 } |
59 | 59 |
60 void OnTouchEvent(ui::TouchEvent* event) override { | 60 void OnTouchEvent(ui::TouchEvent* event) override { |
61 aura::Window* target = static_cast<aura::Window*>(event->target()); | 61 aura::Window* target = static_cast<aura::Window*>(event->target()); |
62 // Only record when the target is the background which covers | 62 // Only record when the target is the wallpaper, which covers the entire |
63 // entire root window. | 63 // root window. |
64 if (target->name() != kDesktopBackgroundView) | 64 if (target->name() != kWallpaperView) |
65 return; | 65 return; |
66 touch_radius_x_ = event->pointer_details().radius_x; | 66 touch_radius_x_ = event->pointer_details().radius_x; |
67 touch_radius_y_ = event->pointer_details().radius_y; | 67 touch_radius_y_ = event->pointer_details().radius_y; |
68 event->StopPropagation(); | 68 event->StopPropagation(); |
69 } | 69 } |
70 | 70 |
71 void OnScrollEvent(ui::ScrollEvent* event) override { | 71 void OnScrollEvent(ui::ScrollEvent* event) override { |
72 aura::Window* target = static_cast<aura::Window*>(event->target()); | 72 aura::Window* target = static_cast<aura::Window*>(event->target()); |
73 // Only record when the target is the background which covers | 73 // Only record when the target is the wallpaper, which covers the entire |
74 // entire root window. | 74 // root window. |
75 if (target->name() != kDesktopBackgroundView) | 75 if (target->name() != kWallpaperView) |
76 return; | 76 return; |
77 | 77 |
78 if (event->type() == ui::ET_SCROLL) { | 78 if (event->type() == ui::ET_SCROLL) { |
79 scroll_x_offset_ = event->x_offset(); | 79 scroll_x_offset_ = event->x_offset(); |
80 scroll_y_offset_ = event->y_offset(); | 80 scroll_y_offset_ = event->y_offset(); |
81 scroll_x_offset_ordinal_ = event->x_offset_ordinal(); | 81 scroll_x_offset_ordinal_ = event->x_offset_ordinal(); |
82 scroll_y_offset_ordinal_ = event->y_offset_ordinal(); | 82 scroll_y_offset_ordinal_ = event->y_offset_ordinal(); |
83 } | 83 } |
84 event->StopPropagation(); | 84 event->StopPropagation(); |
85 } | 85 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 426 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
427 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 427 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
428 | 428 |
429 UpdateDisplay("200x400,500x500"); | 429 UpdateDisplay("200x400,500x500"); |
430 // The aspect ratio is flipped, so X margin is now 125. | 430 // The aspect ratio is flipped, so X margin is now 125. |
431 transformer = CreateCurrentRootWindowTransformerForMirroring(); | 431 transformer = CreateCurrentRootWindowTransformerForMirroring(); |
432 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 432 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
433 } | 433 } |
434 | 434 |
435 } // namespace ash | 435 } // namespace ash |
OLD | NEW |