Commit f49b7a09 authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

Magnifier: Support wrapping the cursor between extended monitors

This CL supports wrapping the cursor between primary and secondary monitors. The behavior is described at comment #1 of crbug.com/139766.

BUG=139766

Review URL: https://chromiumcodereview.appspot.com/10837092

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150163 0039d316-1c4b-4281-b951-d872f2087c98
parent 9c51203f
...@@ -79,6 +79,12 @@ class MagnificationControllerImpl : virtual public MagnificationController, ...@@ -79,6 +79,12 @@ class MagnificationControllerImpl : virtual public MagnificationController,
bool animate); bool animate);
void OnMouseMove(const gfx::Point& location); 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). // Returns if the magnification scale is 1.0 or not (larger then 1.0).
bool IsMagnified() const; bool IsMagnified() const;
...@@ -161,11 +167,12 @@ bool MagnificationControllerImpl::RedrawDIP(const gfx::Point& position_in_dip, ...@@ -161,11 +167,12 @@ bool MagnificationControllerImpl::RedrawDIP(const gfx::Point& position_in_dip,
if (y > max_y) if (y > max_y)
y = max_y; y = max_y;
// Ignores 1 px diffirence because it may be error on calculation. // Does nothing if both the origin and the scale are not changed.
if (std::abs(origin_.x() - x) <= 1 && if (origin_.x() == x &&
std::abs(origin_.y() - y) <= 1 && origin_.y() == y &&
scale == scale_) scale == scale_) {
return false; return false;
}
origin_.set_x(x); origin_.set_x(x);
origin_.set_y(y); origin_.set_y(y);
...@@ -333,6 +340,18 @@ void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { ...@@ -333,6 +340,18 @@ void MagnificationControllerImpl::OnImplicitAnimationsCompleted() {
is_on_zooming_ = false; 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 // MagnificationControllerImpl: MagnificationController implementation
...@@ -342,11 +361,10 @@ void MagnificationControllerImpl::SetScale(float scale, bool animate) { ...@@ -342,11 +361,10 @@ void MagnificationControllerImpl::SetScale(float scale, bool animate) {
ValidateScale(&scale); ValidateScale(&scale);
// Try not to change the point which the mouse cursor indicates to. gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot();
const gfx::Rect window_rect = GetWindowRectDIP(scale); const gfx::Point origin =
const gfx::Point mouse = gfx::Screen::GetCursorScreenPoint(); gfx::Point(mouse_in_root.x() * (1.0f - 1.0f / scale),
const gfx::Point origin = gfx::Point(mouse.x() * (1.0f - 1.0f / scale), mouse_in_root.y() * (1.0f - 1.0f / scale));
mouse.y() * (1.0f - 1.0f / scale));
Redraw(origin, scale, animate); Redraw(origin, scale, animate);
} }
...@@ -403,8 +421,18 @@ bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target, ...@@ -403,8 +421,18 @@ bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target,
bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target, bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target,
aura::MouseEvent* event) { aura::MouseEvent* event) {
if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) {
OnMouseMove(event->root_location()); 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; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment