| Index: ash/magnifier/magnification_controller.cc
|
| diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc
|
| index ff2ea926b665153300329b47800ab16596c0e48c..83f47e4546f3e9d28a93b82e838c3593b63606a6 100644
|
| --- a/ash/magnifier/magnification_controller.cc
|
| +++ b/ash/magnifier/magnification_controller.cc
|
| @@ -79,6 +79,12 @@ class MagnificationControllerImpl : virtual public MagnificationController,
|
| bool animate);
|
| void OnMouseMove(const gfx::Point& location);
|
|
|
| + // Switch Magnified RootWindow to |new_root_window|. This does following:
|
| + // - Unzoom the current root_window.
|
| + // - Zoom the given new root_window |new_root_window|.
|
| + // - Switch the target window from current window to |new_root_window|.
|
| + void SwitchTargetRootWindow(aura::RootWindow* new_root_window);
|
| +
|
| // Returns if the magnification scale is 1.0 or not (larger then 1.0).
|
| bool IsMagnified() const;
|
|
|
| @@ -161,11 +167,12 @@ bool MagnificationControllerImpl::RedrawDIP(const gfx::Point& position_in_dip,
|
| if (y > max_y)
|
| y = max_y;
|
|
|
| - // Ignores 1 px diffirence because it may be error on calculation.
|
| - if (std::abs(origin_.x() - x) <= 1 &&
|
| - std::abs(origin_.y() - y) <= 1 &&
|
| - scale == scale_)
|
| + // Does nothing if both the origin and the scale are not changed.
|
| + if (origin_.x() == x &&
|
| + origin_.y() == y &&
|
| + scale == scale_) {
|
| return false;
|
| + }
|
|
|
| origin_.set_x(x);
|
| origin_.set_y(y);
|
| @@ -333,6 +340,18 @@ void MagnificationControllerImpl::OnImplicitAnimationsCompleted() {
|
| is_on_zooming_ = false;
|
| }
|
|
|
| +void MagnificationControllerImpl::SwitchTargetRootWindow(
|
| + aura::RootWindow* new_root_window) {
|
| + if (new_root_window == root_window_)
|
| + return;
|
| +
|
| + float scale = GetScale();
|
| +
|
| + SetScale(1.0f, true);
|
| + root_window_ = new_root_window;
|
| + SetScale(scale, true);
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // MagnificationControllerImpl: MagnificationController implementation
|
|
|
| @@ -342,11 +361,10 @@ void MagnificationControllerImpl::SetScale(float scale, bool animate) {
|
|
|
| ValidateScale(&scale);
|
|
|
| - // Try not to change the point which the mouse cursor indicates to.
|
| - const gfx::Rect window_rect = GetWindowRectDIP(scale);
|
| - const gfx::Point mouse = gfx::Screen::GetCursorScreenPoint();
|
| - const gfx::Point origin = gfx::Point(mouse.x() * (1.0f - 1.0f / scale),
|
| - mouse.y() * (1.0f - 1.0f / scale));
|
| + gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot();
|
| + const gfx::Point origin =
|
| + gfx::Point(mouse_in_root.x() * (1.0f - 1.0f / scale),
|
| + mouse_in_root.y() * (1.0f - 1.0f / scale));
|
| Redraw(origin, scale, animate);
|
| }
|
|
|
| @@ -403,8 +421,18 @@ bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target,
|
|
|
| bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target,
|
| aura::MouseEvent* event) {
|
| - if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED)
|
| - OnMouseMove(event->root_location());
|
| + if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) {
|
| + aura::RootWindow* current_root = target->GetRootWindow();
|
| + gfx::Rect root_bounds = current_root->bounds();
|
| +
|
| + if (root_bounds.Contains(event->root_location())) {
|
| + if (current_root != root_window_)
|
| + SwitchTargetRootWindow(current_root);
|
| +
|
| + OnMouseMove(event->root_location());
|
| + }
|
| + }
|
| +
|
| return false;
|
| }
|
|
|
|
|