OLD | NEW |
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/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 mouse_moved_handler_ = NULL; | 685 mouse_moved_handler_ = NULL; |
686 mouse_event_dispatch_target_ = NULL; | 686 mouse_event_dispatch_target_ = NULL; |
687 } | 687 } |
688 | 688 |
689 //////////////////////////////////////////////////////////////////////////////// | 689 //////////////////////////////////////////////////////////////////////////////// |
690 // RootWindow, private: | 690 // RootWindow, private: |
691 | 691 |
692 void RootWindow::TransformEventForDeviceScaleFactor(bool keep_inside_root, | 692 void RootWindow::TransformEventForDeviceScaleFactor(bool keep_inside_root, |
693 ui::LocatedEvent* event) { | 693 ui::LocatedEvent* event) { |
694 event->UpdateForRootTransform(GetInverseRootTransform()); | 694 event->UpdateForRootTransform(GetInverseRootTransform()); |
695 #if defined(OS_CHROMEOS) | |
696 const gfx::Rect& root_bounds = bounds(); | |
697 if (keep_inside_root & | |
698 host_->GetBounds().Contains(event->system_location()) && | |
699 !root_bounds.Contains(event->root_location())) { | |
700 // Make sure that the mouse location inside the host window gets | |
701 // translated inside root window. | |
702 // TODO(oshima): This is (hopefully) short term bandaid to deal | |
703 // with calculation error due to the fact that we rotate in dip | |
704 // coordinates instead of pixels. crbug.com/222483. | |
705 int x = event->location().x(); | |
706 int y = event->location().y(); | |
707 x = std::min(std::max(x, root_bounds.x()), root_bounds.right()); | |
708 y = std::min(std::max(y, root_bounds.y()), root_bounds.bottom()); | |
709 const gfx::Point new_location(x, y); | |
710 event->set_location(new_location); | |
711 event->set_root_location(new_location); | |
712 } | |
713 #endif // defined(OS_CHROMEOS) | |
714 } | 695 } |
715 | 696 |
716 void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) { | 697 void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) { |
717 if (target == mouse_moved_handler_) | 698 if (target == mouse_moved_handler_) |
718 return; | 699 return; |
719 | 700 |
720 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); | 701 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); |
721 | 702 |
722 if (mouse_event_dispatch_target_ != target) { | 703 if (mouse_event_dispatch_target_ != target) { |
723 mouse_moved_handler_ = NULL; | 704 mouse_moved_handler_ = NULL; |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 } | 1163 } |
1183 | 1164 |
1184 gfx::Transform RootWindow::GetInverseRootTransform() const { | 1165 gfx::Transform RootWindow::GetInverseRootTransform() const { |
1185 float scale = ui::GetDeviceScaleFactor(layer()); | 1166 float scale = ui::GetDeviceScaleFactor(layer()); |
1186 gfx::Transform transform; | 1167 gfx::Transform transform; |
1187 transform.Scale(1.0f / scale, 1.0f / scale); | 1168 transform.Scale(1.0f / scale, 1.0f / scale); |
1188 return transformer_->GetInverseTransform() * transform; | 1169 return transformer_->GetInverseTransform() * transform; |
1189 } | 1170 } |
1190 | 1171 |
1191 } // namespace aura | 1172 } // namespace aura |
OLD | NEW |