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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
96 // PartialMagnificationController: aura::WindowObserver implementation | 96 // PartialMagnificationController: aura::WindowObserver implementation |
97 | 97 |
98 void PartialMagnificationController::OnWindowDestroying( | 98 void PartialMagnificationController::OnWindowDestroying( |
99 aura::Window* window) { | 99 aura::Window* window) { |
100 CloseMagnifierWindow(); | 100 CloseMagnifierWindow(); |
101 | 101 |
102 aura::Window* new_root_window = GetCurrentRootWindow(); | 102 aura::RootWindow* new_root_window = GetCurrentRootWindow(); |
103 if (new_root_window != window) | 103 if (new_root_window != window) |
104 SwitchTargetRootWindow(new_root_window); | 104 SwitchTargetRootWindow(new_root_window); |
105 } | 105 } |
106 | 106 |
107 void PartialMagnificationController::OnWidgetDestroying( | 107 void PartialMagnificationController::OnWidgetDestroying( |
108 views::Widget* widget) { | 108 views::Widget* widget) { |
109 DCHECK_EQ(widget, zoom_widget_); | 109 DCHECK_EQ(widget, zoom_widget_); |
110 RemoveZoomWidgetObservers(); | 110 RemoveZoomWidgetObservers(); |
111 zoom_widget_ = NULL; | 111 zoom_widget_ = NULL; |
112 } | 112 } |
(...skipping 11 matching lines...) Expand all Loading... |
124 } | 124 } |
125 | 125 |
126 bool PartialMagnificationController::IsPartialMagnified() const { | 126 bool PartialMagnificationController::IsPartialMagnified() const { |
127 return scale_ >= kMinPartialMagnifiedScaleThreshold; | 127 return scale_ >= kMinPartialMagnifiedScaleThreshold; |
128 } | 128 } |
129 | 129 |
130 void PartialMagnificationController::CreateMagnifierWindow() { | 130 void PartialMagnificationController::CreateMagnifierWindow() { |
131 if (zoom_widget_) | 131 if (zoom_widget_) |
132 return; | 132 return; |
133 | 133 |
134 aura::Window* root_window = GetCurrentRootWindow(); | 134 aura::RootWindow* root_window = GetCurrentRootWindow(); |
135 if (!root_window) | 135 if (!root_window) |
136 return; | 136 return; |
137 | 137 |
138 root_window->AddObserver(this); | 138 root_window->AddObserver(this); |
139 | 139 |
140 gfx::Point mouse(root_window->GetDispatcher()->GetLastMouseLocationInRoot()); | 140 gfx::Point mouse(root_window->GetLastMouseLocationInRoot()); |
141 | 141 |
142 zoom_widget_ = new views::Widget; | 142 zoom_widget_ = new views::Widget; |
143 views::Widget::InitParams params( | 143 views::Widget::InitParams params( |
144 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 144 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
145 params.can_activate = false; | 145 params.can_activate = false; |
146 params.accept_events = false; | 146 params.accept_events = false; |
147 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 147 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
148 params.parent = root_window; | 148 params.parent = root_window; |
149 zoom_widget_->Init(params); | 149 zoom_widget_->Init(params); |
150 zoom_widget_->SetBounds(gfx::Rect(mouse.x() - kMagnifierWidth / 2, | 150 zoom_widget_->SetBounds(gfx::Rect(mouse.x() - kMagnifierWidth / 2, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Window* PartialMagnificationController::GetCurrentRootWindow() { | 199 aura::RootWindow* PartialMagnificationController::GetCurrentRootWindow() { |
200 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 200 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
201 for (aura::Window::Windows::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::Window* root_window = *iter; | 203 aura::RootWindow* root_window = *iter; |
204 if (root_window->ContainsPointInRoot( | 204 if (root_window->ContainsPointInRoot( |
205 root_window->GetDispatcher()->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 |