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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Returns the rect of the magnification window. | 108 // Returns the rect of the magnification window. |
109 gfx::RectF GetWindowRectDIP(float scale) const; | 109 gfx::RectF GetWindowRectDIP(float scale) const; |
110 // Returns the size of the root window. | 110 // Returns the size of the root window. |
111 gfx::Size GetHostSizeDIP() const; | 111 gfx::Size GetHostSizeDIP() const; |
112 | 112 |
113 // Correct the givin scale value if nessesary. | 113 // Correct the givin scale value if nessesary. |
114 void ValidateScale(float* scale); | 114 void ValidateScale(float* scale); |
115 | 115 |
116 // ui::EventHandler overrides: | 116 // ui::EventHandler overrides: |
117 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 117 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
118 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 118 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
119 | 119 |
120 aura::RootWindow* root_window_; | 120 aura::RootWindow* root_window_; |
121 | 121 |
122 // True if the magnified window is currently animating a change. Otherwise, | 122 // True if the magnified window is currently animating a change. Otherwise, |
123 // false. | 123 // false. |
124 bool is_on_animation_; | 124 bool is_on_animation_; |
125 | 125 |
126 bool is_enabled_; | 126 bool is_enabled_; |
127 | 127 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 bool MagnificationControllerImpl::IsEnabled() const { | 484 bool MagnificationControllerImpl::IsEnabled() const { |
485 return is_enabled_; | 485 return is_enabled_; |
486 } | 486 } |
487 | 487 |
488 //////////////////////////////////////////////////////////////////////////////// | 488 //////////////////////////////////////////////////////////////////////////////// |
489 // MagnificationControllerImpl: aura::EventFilter implementation | 489 // MagnificationControllerImpl: aura::EventFilter implementation |
490 | 490 |
491 ui::EventResult MagnificationControllerImpl::OnMouseEvent( | 491 void MagnificationControllerImpl::OnMouseEvent(ui::MouseEvent* event) { |
492 ui::MouseEvent* event) { | |
493 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) { | 492 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) { |
494 aura::Window* target = static_cast<aura::Window*>(event->target()); | 493 aura::Window* target = static_cast<aura::Window*>(event->target()); |
495 aura::RootWindow* current_root = target->GetRootWindow(); | 494 aura::RootWindow* current_root = target->GetRootWindow(); |
496 gfx::Rect root_bounds = current_root->bounds(); | 495 gfx::Rect root_bounds = current_root->bounds(); |
497 | 496 |
498 if (root_bounds.Contains(event->root_location())) { | 497 if (root_bounds.Contains(event->root_location())) { |
499 if (current_root != root_window_) | 498 if (current_root != root_window_) |
500 SwitchTargetRootWindow(current_root); | 499 SwitchTargetRootWindow(current_root); |
501 | 500 |
502 OnMouseMove(event->root_location()); | 501 OnMouseMove(event->root_location()); |
503 } | 502 } |
504 } | 503 } |
505 | |
506 return ui::ER_UNHANDLED; | |
507 } | 504 } |
508 | 505 |
509 void MagnificationControllerImpl::OnScrollEvent( | 506 void MagnificationControllerImpl::OnScrollEvent( |
510 ui::ScrollEvent* event) { | 507 ui::ScrollEvent* event) { |
511 if (event->IsAltDown() && event->IsControlDown()) { | 508 if (event->IsAltDown() && event->IsControlDown()) { |
512 if (event->type() == ui::ET_SCROLL_FLING_START || | 509 if (event->type() == ui::ET_SCROLL_FLING_START || |
513 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 510 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
514 event->StopPropagation(); | 511 event->StopPropagation(); |
515 return; | 512 return; |
516 } | 513 } |
(...skipping 11 matching lines...) Expand all Loading... |
528 | 525 |
529 //////////////////////////////////////////////////////////////////////////////// | 526 //////////////////////////////////////////////////////////////////////////////// |
530 // MagnificationController: | 527 // MagnificationController: |
531 | 528 |
532 // static | 529 // static |
533 MagnificationController* MagnificationController::CreateInstance() { | 530 MagnificationController* MagnificationController::CreateInstance() { |
534 return new MagnificationControllerImpl(); | 531 return new MagnificationControllerImpl(); |
535 } | 532 } |
536 | 533 |
537 } // namespace ash | 534 } // namespace ash |
OLD | NEW |