| 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 "ash/display/display_info.h" | 7 #include "ash/display/display_info.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/host/root_window_transformer.h" | 9 #include "ash/host/root_window_transformer.h" |
| 10 #include "ash/magnifier/magnification_controller.h" | 10 #include "ash/magnifier/magnification_controller.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 class TestEventHandler : public ui::EventHandler { | 34 class TestEventHandler : public ui::EventHandler { |
| 35 public: | 35 public: |
| 36 TestEventHandler() : target_root_(NULL), | 36 TestEventHandler() : target_root_(NULL), |
| 37 touch_radius_x_(0.0), | 37 touch_radius_x_(0.0), |
| 38 touch_radius_y_(0.0), | 38 touch_radius_y_(0.0), |
| 39 scroll_x_offset_(0.0), | 39 scroll_x_offset_(0.0), |
| 40 scroll_y_offset_(0.0), | 40 scroll_y_offset_(0.0), |
| 41 scroll_x_offset_ordinal_(0.0), | 41 scroll_x_offset_ordinal_(0.0), |
| 42 scroll_y_offset_ordinal_(0.0) {} | 42 scroll_y_offset_ordinal_(0.0) {} |
| 43 virtual ~TestEventHandler() {} | 43 ~TestEventHandler() override {} |
| 44 | 44 |
| 45 virtual void OnMouseEvent(ui::MouseEvent* event) override { | 45 void OnMouseEvent(ui::MouseEvent* event) override { |
| 46 if (event->flags() & ui::EF_IS_SYNTHESIZED) | 46 if (event->flags() & ui::EF_IS_SYNTHESIZED) |
| 47 return; | 47 return; |
| 48 aura::Window* target = static_cast<aura::Window*>(event->target()); | 48 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 49 mouse_location_ = event->root_location(); | 49 mouse_location_ = event->root_location(); |
| 50 target_root_ = target->GetRootWindow(); | 50 target_root_ = target->GetRootWindow(); |
| 51 event->StopPropagation(); | 51 event->StopPropagation(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void OnTouchEvent(ui::TouchEvent* event) override { | 54 void OnTouchEvent(ui::TouchEvent* event) override { |
| 55 aura::Window* target = static_cast<aura::Window*>(event->target()); | 55 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 56 // Only record when the target is the background which covers | 56 // Only record when the target is the background which covers |
| 57 // entire root window. | 57 // entire root window. |
| 58 if (target->name() != kDesktopBackgroundView) | 58 if (target->name() != kDesktopBackgroundView) |
| 59 return; | 59 return; |
| 60 touch_radius_x_ = event->radius_x(); | 60 touch_radius_x_ = event->radius_x(); |
| 61 touch_radius_y_ = event->radius_y(); | 61 touch_radius_y_ = event->radius_y(); |
| 62 event->StopPropagation(); | 62 event->StopPropagation(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void OnScrollEvent(ui::ScrollEvent* event) override { | 65 void OnScrollEvent(ui::ScrollEvent* event) override { |
| 66 aura::Window* target = static_cast<aura::Window*>(event->target()); | 66 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 67 // Only record when the target is the background which covers | 67 // Only record when the target is the background which covers |
| 68 // entire root window. | 68 // entire root window. |
| 69 if (target->name() != kDesktopBackgroundView) | 69 if (target->name() != kDesktopBackgroundView) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 if (event->type() == ui::ET_SCROLL) { | 72 if (event->type() == ui::ET_SCROLL) { |
| 73 scroll_x_offset_ = event->x_offset(); | 73 scroll_x_offset_ = event->x_offset(); |
| 74 scroll_y_offset_ = event->y_offset(); | 74 scroll_y_offset_ = event->y_offset(); |
| 75 scroll_x_offset_ordinal_ = event->x_offset_ordinal(); | 75 scroll_x_offset_ordinal_ = event->x_offset_ordinal(); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 402 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
| 403 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 403 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
| 404 | 404 |
| 405 UpdateDisplay("200x400,500x500"); | 405 UpdateDisplay("200x400,500x500"); |
| 406 // The aspect ratio is flipped, so X margin is now 125. | 406 // The aspect ratio is flipped, so X margin is now 125. |
| 407 transformer = test_api.CreateCurrentRootWindowTransformer(); | 407 transformer = test_api.CreateCurrentRootWindowTransformer(); |
| 408 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 408 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace ash | 411 } // namespace ash |
| OLD | NEW |