| 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/partial_magnification_controller.h" | 5 #include "ash/magnifier/partial_magnification_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
| 10 #include "ui/views/corewm/compound_event_filter.h" | 10 #include "ui/views/corewm/compound_event_filter.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 is_enabled_ = enabled; | 72 is_enabled_ = enabled; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 //////////////////////////////////////////////////////////////////////////////// | 76 //////////////////////////////////////////////////////////////////////////////// |
| 77 // PartialMagnificationController: ui::EventHandler implementation | 77 // PartialMagnificationController: ui::EventHandler implementation |
| 78 | 78 |
| 79 void PartialMagnificationController::OnMouseEvent(ui::MouseEvent* event) { | 79 void PartialMagnificationController::OnMouseEvent(ui::MouseEvent* event) { |
| 80 if (IsPartialMagnified() && event->type() == ui::ET_MOUSE_MOVED) { | 80 if (IsPartialMagnified() && event->type() == ui::ET_MOUSE_MOVED) { |
| 81 aura::Window* target = static_cast<aura::Window*>(event->target()); | 81 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 82 aura::RootWindow* current_root = target->GetRootWindow(); | 82 aura::Window* current_root = target->GetRootWindow(); |
| 83 // TODO(zork): Handle the case where the event is captured on a different | 83 // TODO(zork): Handle the case where the event is captured on a different |
| 84 // display, such as when a menu is opened. | 84 // display, such as when a menu is opened. |
| 85 gfx::Rect root_bounds = current_root->bounds(); | 85 gfx::Rect root_bounds = current_root->bounds(); |
| 86 | 86 |
| 87 if (root_bounds.Contains(event->root_location())) { | 87 if (root_bounds.Contains(event->root_location())) { |
| 88 SwitchTargetRootWindow(current_root); | 88 SwitchTargetRootWindow(current_root); |
| 89 | 89 |
| 90 OnMouseMove(event->root_location()); | 90 OnMouseMove(event->root_location()); |
| 91 } | 91 } |
| 92 } | 92 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (zoom_widget_) { | 171 if (zoom_widget_) { |
| 172 RemoveZoomWidgetObservers(); | 172 RemoveZoomWidgetObservers(); |
| 173 zoom_widget_->Close(); | 173 zoom_widget_->Close(); |
| 174 zoom_widget_ = NULL; | 174 zoom_widget_ = NULL; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void PartialMagnificationController::RemoveZoomWidgetObservers() { | 178 void PartialMagnificationController::RemoveZoomWidgetObservers() { |
| 179 DCHECK(zoom_widget_); | 179 DCHECK(zoom_widget_); |
| 180 zoom_widget_->RemoveObserver(this); | 180 zoom_widget_->RemoveObserver(this); |
| 181 aura::RootWindow* root_window = | 181 aura::Window* root_window = |
| 182 zoom_widget_->GetNativeView()->GetRootWindow(); | 182 zoom_widget_->GetNativeView()->GetRootWindow(); |
| 183 DCHECK(root_window); | 183 DCHECK(root_window); |
| 184 root_window->RemoveObserver(this); | 184 root_window->RemoveObserver(this); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void PartialMagnificationController::SwitchTargetRootWindow( | 187 void PartialMagnificationController::SwitchTargetRootWindow( |
| 188 aura::RootWindow* new_root_window) { | 188 aura::Window* new_root_window) { |
| 189 if (zoom_widget_ && | 189 if (zoom_widget_ && |
| 190 new_root_window == zoom_widget_->GetNativeView()->GetRootWindow()) | 190 new_root_window == zoom_widget_->GetNativeView()->GetRootWindow()) |
| 191 return; | 191 return; |
| 192 | 192 |
| 193 CloseMagnifierWindow(); | 193 CloseMagnifierWindow(); |
| 194 | 194 |
| 195 // Recreate the magnifier window by updating the scale factor. | 195 // Recreate the magnifier window by updating the scale factor. |
| 196 SetScale(GetScale()); | 196 SetScale(GetScale()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 aura::RootWindow* PartialMagnificationController::GetCurrentRootWindow() { | 199 aura::RootWindow* PartialMagnificationController::GetCurrentRootWindow() { |
| 200 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 200 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 201 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); | 201 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
| 202 iter != root_windows.end(); ++iter) { | 202 iter != root_windows.end(); ++iter) { |
| 203 aura::RootWindow* root_window = *iter; | 203 aura::RootWindow* root_window = *iter; |
| 204 if (root_window->ContainsPointInRoot( | 204 if (root_window->ContainsPointInRoot( |
| 205 root_window->GetLastMouseLocationInRoot())) | 205 root_window->GetLastMouseLocationInRoot())) |
| 206 return root_window; | 206 return root_window; |
| 207 } | 207 } |
| 208 return NULL; | 208 return NULL; |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace ash | 211 } // namespace ash |
| OLD | NEW |