Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: ash/magnifier/magnification_controller.cc

Issue 11316214: Do not let MagnificationController move cursor on login screen when cursor is invisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 the default scale which depends on the login status.
109 float GetDefaultZoomScale() const { 109 float GetDefaultZoomScale() const {
110 // TODO(yoshiki,mazda): Do not use SystemTrayDelegate to get the user login
111 // status (http://crbug.com/163170).
110 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ? 112 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ?
111 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() : 113 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() :
112 user::LOGGED_IN_NONE; 114 user::LOGGED_IN_NONE;
113 115
114 // On login screen, don't magnify the screen by default. 116 // On login screen, don't magnify the screen by default.
115 if (login == user::LOGGED_IN_NONE) 117 if (login == user::LOGGED_IN_NONE)
116 return kNonMagnifiedScale; 118 return kNonMagnifiedScale;
117 119
118 return kInitialMagnifiedScale; 120 return kInitialMagnifiedScale;
119 } 121 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 }; 154 };
153 155
154 //////////////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////////////////
155 // MagnificationControllerImpl: 157 // MagnificationControllerImpl:
156 158
157 MagnificationControllerImpl::MagnificationControllerImpl() 159 MagnificationControllerImpl::MagnificationControllerImpl()
158 : root_window_(ash::Shell::GetPrimaryRootWindow()), 160 : root_window_(ash::Shell::GetPrimaryRootWindow()),
159 is_on_animation_(false), 161 is_on_animation_(false),
160 is_enabled_(false), 162 is_enabled_(false),
161 move_cursor_after_animation_(false), 163 move_cursor_after_animation_(false),
162 scale_(std::numeric_limits<double>::min()) { 164 scale_(kNonMagnifiedScale) {
163 Shell::GetInstance()->AddPreTargetHandler(this); 165 Shell::GetInstance()->AddPreTargetHandler(this);
164 } 166 }
165 167
166 MagnificationControllerImpl::~MagnificationControllerImpl() { 168 MagnificationControllerImpl::~MagnificationControllerImpl() {
167 Shell::GetInstance()->RemovePreTargetHandler(this); 169 Shell::GetInstance()->RemovePreTargetHandler(this);
168 } 170 }
169 171
170 void MagnificationControllerImpl::RedrawKeepingMousePosition( 172 void MagnificationControllerImpl::RedrawKeepingMousePosition(
171 float scale, bool animate) { 173 float scale, bool animate) {
172 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot(); 174 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (x_diff != 0 || y_diff != 0) 346 if (x_diff != 0 || y_diff != 0)
345 AfterAnimationMoveCursorTo(mouse); 347 AfterAnimationMoveCursorTo(mouse);
346 } 348 }
347 } 349 }
348 } 350 }
349 351
350 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( 352 void MagnificationControllerImpl::AfterAnimationMoveCursorTo(
351 const gfx::Point& location) { 353 const gfx::Point& location) {
352 aura::client::CursorClient* cursor_client = 354 aura::client::CursorClient* cursor_client =
353 aura::client::GetCursorClient(root_window_); 355 aura::client::GetCursorClient(root_window_);
354 if (cursor_client) 356 if (cursor_client) {
357 // When cursor is invisible, do not move or show the cursor after the
358 // animation.
359 if (!cursor_client->IsCursorVisible())
360 return;
355 cursor_client->ShowCursor(false); 361 cursor_client->ShowCursor(false);
362 }
356 move_cursor_after_animation_ = true; 363 move_cursor_after_animation_ = true;
357 position_after_animation_ = location; 364 position_after_animation_ = location;
358 } 365 }
359 366
360 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const { 367 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const {
361 return ui::ConvertSizeToDIP(root_window_->layer(), 368 return ui::ConvertSizeToDIP(root_window_->layer(),
362 root_window_->GetHostSize()); 369 root_window_->GetHostSize());
363 } 370 }
364 371
365 gfx::RectF MagnificationControllerImpl::GetWindowRectDIP(float scale) const { 372 gfx::RectF MagnificationControllerImpl::GetWindowRectDIP(float scale) const {
(...skipping 24 matching lines...) Expand all
390 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); 397 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale);
391 } 398 }
392 399
393 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { 400 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() {
394 if (!is_on_animation_) 401 if (!is_on_animation_)
395 return; 402 return;
396 403
397 if (move_cursor_after_animation_) { 404 if (move_cursor_after_animation_) {
398 root_window_->MoveCursorTo(position_after_animation_); 405 root_window_->MoveCursorTo(position_after_animation_);
399 move_cursor_after_animation_ = false; 406 move_cursor_after_animation_ = false;
407
408 aura::client::CursorClient* cursor_client =
409 aura::client::GetCursorClient(root_window_);
410 if (cursor_client)
411 cursor_client->ShowCursor(true);
400 } 412 }
401 413
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; 414 is_on_animation_ = false;
408 } 415 }
409 416
410 void MagnificationControllerImpl::SwitchTargetRootWindow( 417 void MagnificationControllerImpl::SwitchTargetRootWindow(
411 aura::RootWindow* new_root_window) { 418 aura::RootWindow* new_root_window) {
412 if (new_root_window == root_window_) 419 if (new_root_window == root_window_)
413 return; 420 return;
414 421
415 float scale = GetScale(); 422 float scale = GetScale();
416 423
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 533
527 //////////////////////////////////////////////////////////////////////////////// 534 ////////////////////////////////////////////////////////////////////////////////
528 // MagnificationController: 535 // MagnificationController:
529 536
530 // static 537 // static
531 MagnificationController* MagnificationController::CreateInstance() { 538 MagnificationController* MagnificationController::CreateInstance() {
532 return new MagnificationControllerImpl(); 539 return new MagnificationControllerImpl();
533 } 540 }
534 541
535 } // namespace ash 542 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698