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 "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 | 98 |
99 // Switch Magnified RootWindow to |new_root_window|. This does following: | 99 // Switch Magnified RootWindow to |new_root_window|. This does following: |
100 // - Unzoom the current root_window. | 100 // - Unzoom the current root_window. |
101 // - Zoom the given new root_window |new_root_window|. | 101 // - Zoom the given new root_window |new_root_window|. |
102 // - Switch the target window from current window to |new_root_window|. | 102 // - Switch the target window from current window to |new_root_window|. |
103 void SwitchTargetRootWindow(aura::RootWindow* new_root_window); | 103 void SwitchTargetRootWindow(aura::RootWindow* new_root_window); |
104 | 104 |
105 // Returns if the magnification scale is 1.0 or not (larger then 1.0). | 105 // Returns if the magnification scale is 1.0 or not (larger then 1.0). |
106 bool IsMagnified() const; | 106 bool IsMagnified() const; |
107 | 107 |
108 // Returns the default scale which depends on the login status. | 108 // Returns true if the user is logged in. |
109 float GetDefaultZoomScale() const { | 109 bool IsUserLoggedIn() const { |
110 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ? | 110 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ? |
111 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() : | 111 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() : |
Daniel Erat
2012/11/28 15:35:23
it seems pretty strange to me how all of this code
mazda
2012/11/28 19:27:16
I filed a cleanup issue (http://crbug.com/163170)
| |
112 user::LOGGED_IN_NONE; | 112 user::LOGGED_IN_NONE; |
113 return login != user::LOGGED_IN_NONE; | |
114 } | |
113 | 115 |
116 // Returns the default scale which depends on the login status. | |
117 float GetDefaultZoomScale() const { | |
114 // On login screen, don't magnify the screen by default. | 118 // On login screen, don't magnify the screen by default. |
115 if (login == user::LOGGED_IN_NONE) | 119 if (!IsUserLoggedIn()) |
116 return kNonMagnifiedScale; | 120 return kNonMagnifiedScale; |
117 | 121 |
118 return kInitialMagnifiedScale; | 122 return kInitialMagnifiedScale; |
119 } | 123 } |
120 | 124 |
121 // Returns the rect of the magnification window. | 125 // Returns the rect of the magnification window. |
122 gfx::RectF GetWindowRectDIP(float scale) const; | 126 gfx::RectF GetWindowRectDIP(float scale) const; |
123 // Returns the size of the root window. | 127 // Returns the size of the root window. |
124 gfx::Size GetHostSizeDIP() const; | 128 gfx::Size GetHostSizeDIP() const; |
125 | 129 |
(...skipping 26 matching lines...) Expand all Loading... | |
152 }; | 156 }; |
153 | 157 |
154 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
155 // MagnificationControllerImpl: | 159 // MagnificationControllerImpl: |
156 | 160 |
157 MagnificationControllerImpl::MagnificationControllerImpl() | 161 MagnificationControllerImpl::MagnificationControllerImpl() |
158 : root_window_(ash::Shell::GetPrimaryRootWindow()), | 162 : root_window_(ash::Shell::GetPrimaryRootWindow()), |
159 is_on_animation_(false), | 163 is_on_animation_(false), |
160 is_enabled_(false), | 164 is_enabled_(false), |
161 move_cursor_after_animation_(false), | 165 move_cursor_after_animation_(false), |
162 scale_(std::numeric_limits<double>::min()) { | 166 scale_(std::numeric_limits<double>::min()) { |
yoshiki
2012/11/28 05:00:14
Could you change it from "std::numeric_limits<doub
mazda
2012/11/28 19:27:16
Done.
| |
163 Shell::GetInstance()->AddPreTargetHandler(this); | 167 Shell::GetInstance()->AddPreTargetHandler(this); |
164 } | 168 } |
165 | 169 |
166 MagnificationControllerImpl::~MagnificationControllerImpl() { | 170 MagnificationControllerImpl::~MagnificationControllerImpl() { |
167 Shell::GetInstance()->RemovePreTargetHandler(this); | 171 Shell::GetInstance()->RemovePreTargetHandler(this); |
168 } | 172 } |
169 | 173 |
170 void MagnificationControllerImpl::RedrawKeepingMousePosition( | 174 void MagnificationControllerImpl::RedrawKeepingMousePosition( |
171 float scale, bool animate) { | 175 float scale, bool animate) { |
172 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot(); | 176 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 if (x_diff != 0 || y_diff != 0) | 348 if (x_diff != 0 || y_diff != 0) |
345 AfterAnimationMoveCursorTo(mouse); | 349 AfterAnimationMoveCursorTo(mouse); |
346 } | 350 } |
347 } | 351 } |
348 } | 352 } |
349 | 353 |
350 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( | 354 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( |
351 const gfx::Point& location) { | 355 const gfx::Point& location) { |
352 aura::client::CursorClient* cursor_client = | 356 aura::client::CursorClient* cursor_client = |
353 aura::client::GetCursorClient(root_window_); | 357 aura::client::GetCursorClient(root_window_); |
354 if (cursor_client) | 358 if (cursor_client) { |
359 // When cursor is invisible on login screen, do not move cursor nor show | |
Daniel Erat
2012/11/28 15:35:23
nit: s/nor/or/, s/cursor/the cursor/g
("nor" woul
mazda
2012/11/28 19:27:16
Done.
| |
360 // cursor after the animation. | |
361 if (!IsUserLoggedIn() && !cursor_client->IsCursorVisible()) | |
yoshiki
2012/11/28 05:00:14
I think you can remove "!IsUserLoggedIn()". We sho
mazda
2012/11/28 19:27:16
Done.
| |
362 return; | |
355 cursor_client->ShowCursor(false); | 363 cursor_client->ShowCursor(false); |
364 } | |
356 move_cursor_after_animation_ = true; | 365 move_cursor_after_animation_ = true; |
357 position_after_animation_ = location; | 366 position_after_animation_ = location; |
358 } | 367 } |
359 | 368 |
360 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const { | 369 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const { |
361 return ui::ConvertSizeToDIP(root_window_->layer(), | 370 return ui::ConvertSizeToDIP(root_window_->layer(), |
362 root_window_->GetHostSize()); | 371 root_window_->GetHostSize()); |
363 } | 372 } |
364 | 373 |
365 gfx::RectF MagnificationControllerImpl::GetWindowRectDIP(float scale) const { | 374 gfx::RectF MagnificationControllerImpl::GetWindowRectDIP(float scale) const { |
(...skipping 24 matching lines...) Expand all Loading... | |
390 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); | 399 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); |
391 } | 400 } |
392 | 401 |
393 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { | 402 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { |
394 if (!is_on_animation_) | 403 if (!is_on_animation_) |
395 return; | 404 return; |
396 | 405 |
397 if (move_cursor_after_animation_) { | 406 if (move_cursor_after_animation_) { |
398 root_window_->MoveCursorTo(position_after_animation_); | 407 root_window_->MoveCursorTo(position_after_animation_); |
399 move_cursor_after_animation_ = false; | 408 move_cursor_after_animation_ = false; |
409 | |
410 aura::client::CursorClient* cursor_client = | |
411 aura::client::GetCursorClient(root_window_); | |
412 if (cursor_client) | |
413 cursor_client->ShowCursor(true); | |
400 } | 414 } |
401 | 415 |
402 aura::client::CursorClient* cursor_client = | |
403 aura::client::GetCursorClient(root_window_); | |
404 if (cursor_client) | |
405 cursor_client->ShowCursor(true); | |
406 | |
407 is_on_animation_ = false; | 416 is_on_animation_ = false; |
408 } | 417 } |
409 | 418 |
410 void MagnificationControllerImpl::SwitchTargetRootWindow( | 419 void MagnificationControllerImpl::SwitchTargetRootWindow( |
411 aura::RootWindow* new_root_window) { | 420 aura::RootWindow* new_root_window) { |
412 if (new_root_window == root_window_) | 421 if (new_root_window == root_window_) |
413 return; | 422 return; |
414 | 423 |
415 float scale = GetScale(); | 424 float scale = GetScale(); |
416 | 425 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 535 |
527 //////////////////////////////////////////////////////////////////////////////// | 536 //////////////////////////////////////////////////////////////////////////////// |
528 // MagnificationController: | 537 // MagnificationController: |
529 | 538 |
530 // static | 539 // static |
531 MagnificationController* MagnificationController::CreateInstance() { | 540 MagnificationController* MagnificationController::CreateInstance() { |
532 return new MagnificationControllerImpl(); | 541 return new MagnificationControllerImpl(); |
533 } | 542 } |
534 | 543 |
535 } // namespace ash | 544 } // namespace ash |
OLD | NEW |