| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/accelerators/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
| 11 #include "ash/common/accessibility_delegate.h" | 11 #include "ash/common/accessibility_delegate.h" |
| 12 #include "ash/common/ash_switches.h" | 12 #include "ash/common/ash_switches.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/wm_shell.h" |
| 14 #include "ash/display/root_window_transformers.h" | 15 #include "ash/display/root_window_transformers.h" |
| 15 #include "ash/host/ash_window_tree_host.h" | 16 #include "ash/host/ash_window_tree_host.h" |
| 16 #include "ash/host/root_window_transformer.h" | 17 #include "ash/host/root_window_transformer.h" |
| 17 #include "ash/root_window_controller.h" | 18 #include "ash/root_window_controller.h" |
| 18 #include "ash/screen_util.h" | 19 #include "ash/screen_util.h" |
| 19 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 21 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
| 22 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
| 23 #include "ui/aura/client/cursor_client.h" | 24 #include "ui/aura/client/cursor_client.h" |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 558 } |
| 558 | 559 |
| 559 //////////////////////////////////////////////////////////////////////////////// | 560 //////////////////////////////////////////////////////////////////////////////// |
| 560 // MagnificationControllerImpl: MagnificationController implementation | 561 // MagnificationControllerImpl: MagnificationController implementation |
| 561 | 562 |
| 562 void MagnificationControllerImpl::SetScale(float scale, bool animate) { | 563 void MagnificationControllerImpl::SetScale(float scale, bool animate) { |
| 563 if (!is_enabled_) | 564 if (!is_enabled_) |
| 564 return; | 565 return; |
| 565 | 566 |
| 566 ValidateScale(&scale); | 567 ValidateScale(&scale); |
| 567 Shell::GetInstance()->accessibility_delegate()->SaveScreenMagnifierScale( | 568 WmShell::Get()->GetAccessibilityDelegate()->SaveScreenMagnifierScale(scale); |
| 568 scale); | |
| 569 RedrawKeepingMousePosition(scale, animate); | 569 RedrawKeepingMousePosition(scale, animate); |
| 570 } | 570 } |
| 571 | 571 |
| 572 void MagnificationControllerImpl::MoveWindow(int x, int y, bool animate) { | 572 void MagnificationControllerImpl::MoveWindow(int x, int y, bool animate) { |
| 573 if (!is_enabled_) | 573 if (!is_enabled_) |
| 574 return; | 574 return; |
| 575 | 575 |
| 576 Redraw(gfx::PointF(x, y), scale_, animate); | 576 Redraw(gfx::PointF(x, y), scale_, animate); |
| 577 } | 577 } |
| 578 | 578 |
| 579 void MagnificationControllerImpl::MoveWindow(const gfx::Point& point, | 579 void MagnificationControllerImpl::MoveWindow(const gfx::Point& point, |
| 580 bool animate) { | 580 bool animate) { |
| 581 if (!is_enabled_) | 581 if (!is_enabled_) |
| 582 return; | 582 return; |
| 583 | 583 |
| 584 Redraw(gfx::PointF(point), scale_, animate); | 584 Redraw(gfx::PointF(point), scale_, animate); |
| 585 } | 585 } |
| 586 | 586 |
| 587 void MagnificationControllerImpl::SetScrollDirection( | 587 void MagnificationControllerImpl::SetScrollDirection( |
| 588 ScrollDirection direction) { | 588 ScrollDirection direction) { |
| 589 scroll_direction_ = direction; | 589 scroll_direction_ = direction; |
| 590 StartOrStopScrollIfNecessary(); | 590 StartOrStopScrollIfNecessary(); |
| 591 } | 591 } |
| 592 | 592 |
| 593 void MagnificationControllerImpl::SetEnabled(bool enabled) { | 593 void MagnificationControllerImpl::SetEnabled(bool enabled) { |
| 594 Shell* shell = Shell::GetInstance(); | |
| 595 ui::InputMethod* input_method = GetInputMethod(root_window_); | 594 ui::InputMethod* input_method = GetInputMethod(root_window_); |
| 596 if (enabled) { | 595 if (enabled) { |
| 597 if (!is_enabled_ && input_method) | 596 if (!is_enabled_ && input_method) |
| 598 input_method->AddObserver(this); | 597 input_method->AddObserver(this); |
| 599 | 598 |
| 600 float scale = Shell::GetInstance() | 599 WmShell* wm_shell = WmShell::Get(); |
| 601 ->accessibility_delegate() | 600 float scale = |
| 602 ->GetSavedScreenMagnifierScale(); | 601 wm_shell->GetAccessibilityDelegate()->GetSavedScreenMagnifierScale(); |
| 603 if (scale <= 0.0f) | 602 if (scale <= 0.0f) |
| 604 scale = kInitialMagnifiedScale; | 603 scale = kInitialMagnifiedScale; |
| 605 ValidateScale(&scale); | 604 ValidateScale(&scale); |
| 606 | 605 |
| 607 // Do nothing, if already enabled with same scale. | 606 // Do nothing, if already enabled with same scale. |
| 608 if (is_enabled_ && scale == scale_) | 607 if (is_enabled_ && scale == scale_) |
| 609 return; | 608 return; |
| 610 | 609 |
| 611 is_enabled_ = enabled; | 610 is_enabled_ = enabled; |
| 612 RedrawKeepingMousePosition(scale, true); | 611 RedrawKeepingMousePosition(scale, true); |
| 613 shell->accessibility_delegate()->SaveScreenMagnifierScale(scale); | 612 wm_shell->GetAccessibilityDelegate()->SaveScreenMagnifierScale(scale); |
| 614 } else { | 613 } else { |
| 615 // Do nothing, if already disabled. | 614 // Do nothing, if already disabled. |
| 616 if (!is_enabled_) | 615 if (!is_enabled_) |
| 617 return; | 616 return; |
| 618 | 617 |
| 619 if (input_method) | 618 if (input_method) |
| 620 input_method->RemoveObserver(this); | 619 input_method->RemoveObserver(this); |
| 621 | 620 |
| 622 RedrawKeepingMousePosition(kNonMagnifiedScale, true); | 621 RedrawKeepingMousePosition(kNonMagnifiedScale, true); |
| 623 is_enabled_ = enabled; | 622 is_enabled_ = enabled; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 | 847 |
| 849 //////////////////////////////////////////////////////////////////////////////// | 848 //////////////////////////////////////////////////////////////////////////////// |
| 850 // MagnificationController: | 849 // MagnificationController: |
| 851 | 850 |
| 852 // static | 851 // static |
| 853 MagnificationController* MagnificationController::CreateInstance() { | 852 MagnificationController* MagnificationController::CreateInstance() { |
| 854 return new MagnificationControllerImpl(); | 853 return new MagnificationControllerImpl(); |
| 855 } | 854 } |
| 856 | 855 |
| 857 } // namespace ash | 856 } // namespace ash |
| OLD | NEW |