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 "ash/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ui/aura/client/cursor_client.h" |
9 #include "ui/aura/event_filter.h" | 10 #include "ui/aura/event_filter.h" |
10 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
11 #include "ui/aura/shared/compound_event_filter.h" | 12 #include "ui/aura/shared/compound_event_filter.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_property.h" | 14 #include "ui/aura/window_property.h" |
14 #include "ui/base/events/event.h" | 15 #include "ui/base/events/event.h" |
15 #include "ui/compositor/dip_util.h" | 16 #include "ui/compositor/dip_util.h" |
16 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
17 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
18 #include "ui/compositor/scoped_layer_animation_settings.h" | 19 #include "ui/compositor/scoped_layer_animation_settings.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 if (start_zoom && !is_on_zooming_) { | 303 if (start_zoom && !is_on_zooming_) { |
303 bool ret = RedrawDIP(gfx::Point(x, y), scale_, true); | 304 bool ret = RedrawDIP(gfx::Point(x, y), scale_, true); |
304 | 305 |
305 if (ret) { | 306 if (ret) { |
306 is_on_zooming_ = true; | 307 is_on_zooming_ = true; |
307 | 308 |
308 int x_diff = origin_.x() - window_rect.x(); | 309 int x_diff = origin_.x() - window_rect.x(); |
309 int y_diff = origin_.y() - window_rect.y(); | 310 int y_diff = origin_.y() - window_rect.y(); |
310 // If the magnified region is moved, hides the mouse cursor and moves it. | 311 // If the magnified region is moved, hides the mouse cursor and moves it. |
311 if (x_diff != 0 || y_diff != 0) { | 312 if (x_diff != 0 || y_diff != 0) { |
312 root_window_->ShowCursor(false); | 313 aura::client::CursorClient* cursor_client = |
| 314 aura::client::GetCursorClient(root_window_); |
| 315 if (cursor_client) |
| 316 cursor_client->ShowCursor(false); |
313 mouse.set_x(mouse.x() - (origin_.x() - window_rect.x())); | 317 mouse.set_x(mouse.x() - (origin_.x() - window_rect.x())); |
314 mouse.set_y(mouse.y() - (origin_.y() - window_rect.y())); | 318 mouse.set_y(mouse.y() - (origin_.y() - window_rect.y())); |
315 root_window_->MoveCursorTo(mouse); | 319 root_window_->MoveCursorTo(mouse); |
316 } | 320 } |
317 } | 321 } |
318 } | 322 } |
319 } | 323 } |
320 | 324 |
321 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const { | 325 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const { |
322 return ui::ConvertSizeToDIP(root_window_->layer(), | 326 return ui::ConvertSizeToDIP(root_window_->layer(), |
(...skipping 22 matching lines...) Expand all Loading... |
345 | 349 |
346 // Adjust the scale to just |kMinMagnifiedScale| if scale is bigger than | 350 // Adjust the scale to just |kMinMagnifiedScale| if scale is bigger than |
347 // |kMinMagnifiedScaleThreshold|; | 351 // |kMinMagnifiedScaleThreshold|; |
348 if (*scale > kMaxMagnifiedScaleThreshold) | 352 if (*scale > kMaxMagnifiedScaleThreshold) |
349 *scale = kMaxMagnifiedScale; | 353 *scale = kMaxMagnifiedScale; |
350 | 354 |
351 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); | 355 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); |
352 } | 356 } |
353 | 357 |
354 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { | 358 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { |
355 root_window_->ShowCursor(true); | 359 aura::client::CursorClient* cursor_client = |
| 360 aura::client::GetCursorClient(root_window_); |
| 361 if (cursor_client) |
| 362 cursor_client->ShowCursor(true); |
356 is_on_zooming_ = false; | 363 is_on_zooming_ = false; |
357 } | 364 } |
358 | 365 |
359 void MagnificationControllerImpl::SwitchTargetRootWindow( | 366 void MagnificationControllerImpl::SwitchTargetRootWindow( |
360 aura::RootWindow* new_root_window) { | 367 aura::RootWindow* new_root_window) { |
361 if (new_root_window == root_window_) | 368 if (new_root_window == root_window_) |
362 return; | 369 return; |
363 | 370 |
364 float scale = GetScale(); | 371 float scale = GetScale(); |
365 | 372 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 //////////////////////////////////////////////////////////////////////////////// | 481 //////////////////////////////////////////////////////////////////////////////// |
475 // MagnificationController: | 482 // MagnificationController: |
476 | 483 |
477 // static | 484 // static |
478 MagnificationController* MagnificationController::CreateInstance() { | 485 MagnificationController* MagnificationController::CreateInstance() { |
479 return new MagnificationControllerImpl(); | 486 return new MagnificationControllerImpl(); |
480 } | 487 } |
481 | 488 |
482 } // namespace internal | 489 } // namespace internal |
483 } // namespace ash | 490 } // namespace ash |
OLD | NEW |