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/display/display_controller.h" | |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
11 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_property.h" | 14 #include "ui/aura/window_property.h" |
14 #include "ui/base/events/event.h" | 15 #include "ui/base/events/event.h" |
15 #include "ui/base/events/event_handler.h" | 16 #include "ui/base/events/event_handler.h" |
16 #include "ui/compositor/dip_util.h" | 17 #include "ui/compositor/dip_util.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 namespace ash { | 43 namespace ash { |
43 | 44 |
44 //////////////////////////////////////////////////////////////////////////////// | 45 //////////////////////////////////////////////////////////////////////////////// |
45 // MagnificationControllerImpl: | 46 // MagnificationControllerImpl: |
46 | 47 |
47 class MagnificationControllerImpl : virtual public MagnificationController, | 48 class MagnificationControllerImpl : virtual public MagnificationController, |
48 public ui::EventHandler, | 49 public ui::EventHandler, |
49 public ui::ImplicitAnimationObserver { | 50 public ui::ImplicitAnimationObserver, |
51 public aura::WindowObserver { | |
50 public: | 52 public: |
51 MagnificationControllerImpl(); | 53 MagnificationControllerImpl(); |
52 virtual ~MagnificationControllerImpl(); | 54 virtual ~MagnificationControllerImpl(); |
53 | 55 |
54 // MagnificationController overrides: | 56 // MagnificationController overrides: |
55 virtual void SetEnabled(bool enabled) OVERRIDE; | 57 virtual void SetEnabled(bool enabled) OVERRIDE; |
56 virtual bool IsEnabled() const OVERRIDE; | 58 virtual bool IsEnabled() const OVERRIDE; |
57 virtual void SetScale(float scale, bool animate) OVERRIDE; | 59 virtual void SetScale(float scale, bool animate) OVERRIDE; |
58 virtual float GetScale() const OVERRIDE { return scale_; } | 60 virtual float GetScale() const OVERRIDE { return scale_; } |
59 virtual void MoveWindow(int x, int y, bool animate) OVERRIDE; | 61 virtual void MoveWindow(int x, int y, bool animate) OVERRIDE; |
60 virtual void MoveWindow(const gfx::Point& point, bool animate) OVERRIDE; | 62 virtual void MoveWindow(const gfx::Point& point, bool animate) OVERRIDE; |
61 virtual gfx::Point GetWindowPosition() const OVERRIDE { | 63 virtual gfx::Point GetWindowPosition() const OVERRIDE { |
62 return gfx::ToFlooredPoint(origin_); | 64 return gfx::ToFlooredPoint(origin_); |
63 } | 65 } |
64 virtual void EnsureRectIsVisible(const gfx::Rect& rect, | 66 virtual void EnsureRectIsVisible(const gfx::Rect& rect, |
65 bool animate) OVERRIDE; | 67 bool animate) OVERRIDE; |
66 virtual void EnsurePointIsVisible(const gfx::Point& point, | 68 virtual void EnsurePointIsVisible(const gfx::Point& point, |
67 bool animate) OVERRIDE; | 69 bool animate) OVERRIDE; |
68 | 70 |
69 private: | 71 private: |
70 // ui::ImplicitAnimationObserver overrides: | 72 // ui::ImplicitAnimationObserver overrides: |
71 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 73 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
72 | 74 |
75 // aura::WindowObserver overrides: | |
76 virtual void OnWindowDestroying(aura::Window* root_window) OVERRIDE; | |
77 | |
73 // Redraws the magnification window with the given origin position and the | 78 // Redraws the magnification window with the given origin position and the |
74 // given scale. Returns true if the window is changed; otherwise, false. | 79 // given scale. Returns true if the window is changed; otherwise, false. |
75 // These methods should be called internally just after the scale and/or | 80 // These methods should be called internally just after the scale and/or |
76 // the position are changed to redraw the window. | 81 // the position are changed to redraw the window. |
77 bool Redraw(const gfx::PointF& position, float scale, bool animate); | 82 bool Redraw(const gfx::PointF& position, float scale, bool animate); |
78 bool RedrawDIP(const gfx::PointF& position, float scale, bool animate); | 83 bool RedrawDIP(const gfx::PointF& position, float scale, bool animate); |
79 | 84 |
80 // Redraw with the given zoom scale keeping the mouse cursor location. In | 85 // Redraw with the given zoom scale keeping the mouse cursor location. In |
81 // other words, zoom (or unzoom) centering around the cursor. | 86 // other words, zoom (or unzoom) centering around the cursor. |
82 void RedrawKeepingMousePosition(float scale, bool animate); | 87 void RedrawKeepingMousePosition(float scale, bool animate); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 gfx::Size GetHostSizeDIP() const; | 120 gfx::Size GetHostSizeDIP() const; |
116 | 121 |
117 // Correct the givin scale value if nessesary. | 122 // Correct the givin scale value if nessesary. |
118 void ValidateScale(float* scale); | 123 void ValidateScale(float* scale); |
119 | 124 |
120 // ui::EventHandler overrides: | 125 // ui::EventHandler overrides: |
121 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 126 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
122 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 127 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
123 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 128 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
124 | 129 |
130 // Target root window. This must not be NULL. | |
125 aura::RootWindow* root_window_; | 131 aura::RootWindow* root_window_; |
126 | 132 |
127 // True if the magnified window is currently animating a change. Otherwise, | 133 // True if the magnified window is currently animating a change. Otherwise, |
128 // false. | 134 // false. |
129 bool is_on_animation_; | 135 bool is_on_animation_; |
130 | 136 |
131 bool is_enabled_; | 137 bool is_enabled_; |
132 | 138 |
133 // True if the cursor needs to move the given position after the animation | 139 // True if the cursor needs to move the given position after the animation |
134 // will be finished. When using this, set |position_after_animation_| as well. | 140 // will be finished. When using this, set |position_after_animation_| as well. |
(...skipping 16 matching lines...) Expand all Loading... | |
151 // MagnificationControllerImpl: | 157 // MagnificationControllerImpl: |
152 | 158 |
153 MagnificationControllerImpl::MagnificationControllerImpl() | 159 MagnificationControllerImpl::MagnificationControllerImpl() |
154 : root_window_(ash::Shell::GetPrimaryRootWindow()), | 160 : root_window_(ash::Shell::GetPrimaryRootWindow()), |
155 is_on_animation_(false), | 161 is_on_animation_(false), |
156 is_enabled_(false), | 162 is_enabled_(false), |
157 move_cursor_after_animation_(false), | 163 move_cursor_after_animation_(false), |
158 scale_(kNonMagnifiedScale) { | 164 scale_(kNonMagnifiedScale) { |
159 Shell::GetInstance()->AddPreTargetHandler(this); | 165 Shell::GetInstance()->AddPreTargetHandler(this); |
160 | 166 |
161 if (root_window_) | 167 CHECK(root_window_); |
oshima
2013/02/27 19:07:04
CHECK/DCHECK is useful if you want to fail early,
| |
162 point_of_interest_ = root_window_->bounds().CenterPoint(); | 168 root_window_->AddObserver(this); |
169 point_of_interest_ = root_window_->bounds().CenterPoint(); | |
163 } | 170 } |
164 | 171 |
165 MagnificationControllerImpl::~MagnificationControllerImpl() { | 172 MagnificationControllerImpl::~MagnificationControllerImpl() { |
173 DCHECK(root_window_); | |
oshima
2013/02/27 19:07:04
ditto
| |
174 root_window_->RemoveObserver(this); | |
175 | |
166 Shell::GetInstance()->RemovePreTargetHandler(this); | 176 Shell::GetInstance()->RemovePreTargetHandler(this); |
167 } | 177 } |
168 | 178 |
169 void MagnificationControllerImpl::RedrawKeepingMousePosition( | 179 void MagnificationControllerImpl::RedrawKeepingMousePosition( |
170 float scale, bool animate) { | 180 float scale, bool animate) { |
181 DCHECK(root_window_); | |
oshima
2013/02/27 19:07:04
ditto
| |
182 | |
171 gfx::Point mouse_in_root = point_of_interest_; | 183 gfx::Point mouse_in_root = point_of_interest_; |
172 | 184 |
173 // mouse_in_root is invalid value when the cursor is hidden. | 185 // mouse_in_root is invalid value when the cursor is hidden. |
174 if (!root_window_->bounds().Contains(mouse_in_root)) | 186 if (!root_window_->bounds().Contains(mouse_in_root)) |
175 mouse_in_root = root_window_->bounds().CenterPoint(); | 187 mouse_in_root = root_window_->bounds().CenterPoint(); |
176 | 188 |
177 const gfx::PointF origin = | 189 const gfx::PointF origin = |
178 gfx::PointF(mouse_in_root.x() - | 190 gfx::PointF(mouse_in_root.x() - |
179 (scale_ / scale) * (mouse_in_root.x() - origin_.x()), | 191 (scale_ / scale) * (mouse_in_root.x() - origin_.x()), |
180 mouse_in_root.y() - | 192 mouse_in_root.y() - |
181 (scale_ / scale) * (mouse_in_root.y() - origin_.y())); | 193 (scale_ / scale) * (mouse_in_root.y() - origin_.y())); |
182 bool changed = RedrawDIP(origin, scale, animate); | 194 bool changed = RedrawDIP(origin, scale, animate); |
183 if (changed) | 195 if (changed) |
184 AfterAnimationMoveCursorTo(mouse_in_root); | 196 AfterAnimationMoveCursorTo(mouse_in_root); |
185 } | 197 } |
186 | 198 |
187 bool MagnificationControllerImpl::Redraw(const gfx::PointF& position, | 199 bool MagnificationControllerImpl::Redraw(const gfx::PointF& position, |
188 float scale, | 200 float scale, |
189 bool animate) { | 201 bool animate) { |
202 DCHECK(root_window_); | |
oshima
2013/02/27 19:07:04
ditto
| |
203 | |
190 const gfx::PointF position_in_dip = | 204 const gfx::PointF position_in_dip = |
191 ui::ConvertPointToDIP(root_window_->layer(), position); | 205 ui::ConvertPointToDIP(root_window_->layer(), position); |
192 return RedrawDIP(position_in_dip, scale, animate); | 206 return RedrawDIP(position_in_dip, scale, animate); |
193 } | 207 } |
194 | 208 |
195 bool MagnificationControllerImpl::RedrawDIP(const gfx::PointF& position_in_dip, | 209 bool MagnificationControllerImpl::RedrawDIP(const gfx::PointF& position_in_dip, |
196 float scale, | 210 float scale, |
197 bool animate) { | 211 bool animate) { |
212 DCHECK(root_window_); | |
213 | |
198 float x = position_in_dip.x(); | 214 float x = position_in_dip.x(); |
199 float y = position_in_dip.y(); | 215 float y = position_in_dip.y(); |
200 | 216 |
201 ValidateScale(&scale); | 217 ValidateScale(&scale); |
202 | 218 |
203 if (x < 0) | 219 if (x < 0) |
204 x = 0; | 220 x = 0; |
205 if (y < 0) | 221 if (y < 0) |
206 y = 0; | 222 y = 0; |
207 | 223 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 if (animate) | 262 if (animate) |
247 is_on_animation_ = true; | 263 is_on_animation_ = true; |
248 | 264 |
249 return true; | 265 return true; |
250 } | 266 } |
251 | 267 |
252 void MagnificationControllerImpl::EnsureRectIsVisibleWithScale( | 268 void MagnificationControllerImpl::EnsureRectIsVisibleWithScale( |
253 const gfx::Rect& target_rect, | 269 const gfx::Rect& target_rect, |
254 float scale, | 270 float scale, |
255 bool animate) { | 271 bool animate) { |
272 DCHECK(root_window_); | |
oshima
2013/02/27 19:07:04
ditto
| |
273 | |
256 const gfx::Rect target_rect_in_dip = | 274 const gfx::Rect target_rect_in_dip = |
257 ui::ConvertRectToDIP(root_window_->layer(), target_rect); | 275 ui::ConvertRectToDIP(root_window_->layer(), target_rect); |
258 EnsureRectIsVisibleDIP(target_rect_in_dip, scale, animate); | 276 EnsureRectIsVisibleDIP(target_rect_in_dip, scale, animate); |
259 } | 277 } |
260 | 278 |
261 void MagnificationControllerImpl::EnsureRectIsVisibleDIP( | 279 void MagnificationControllerImpl::EnsureRectIsVisibleDIP( |
262 const gfx::Rect& target_rect, | 280 const gfx::Rect& target_rect, |
263 float scale, | 281 float scale, |
264 bool animate) { | 282 bool animate) { |
265 ValidateScale(&scale); | 283 ValidateScale(&scale); |
(...skipping 26 matching lines...) Expand all Loading... | |
292 void MagnificationControllerImpl::EnsurePointIsVisibleWithScale( | 310 void MagnificationControllerImpl::EnsurePointIsVisibleWithScale( |
293 const gfx::Point& point, | 311 const gfx::Point& point, |
294 float scale, | 312 float scale, |
295 bool animate) { | 313 bool animate) { |
296 EnsureRectIsVisibleWithScale(gfx::Rect(point, gfx::Size(0, 0)), | 314 EnsureRectIsVisibleWithScale(gfx::Rect(point, gfx::Size(0, 0)), |
297 scale, | 315 scale, |
298 animate); | 316 animate); |
299 } | 317 } |
300 | 318 |
301 void MagnificationControllerImpl::OnMouseMove(const gfx::Point& location) { | 319 void MagnificationControllerImpl::OnMouseMove(const gfx::Point& location) { |
320 DCHECK(root_window_); | |
321 | |
302 gfx::Point mouse(location); | 322 gfx::Point mouse(location); |
303 | 323 |
304 int x = origin_.x(); | 324 int x = origin_.x(); |
305 int y = origin_.y(); | 325 int y = origin_.y(); |
306 bool start_zoom = false; | 326 bool start_zoom = false; |
307 | 327 |
308 const gfx::Rect window_rect = gfx::ToEnclosingRect(GetWindowRectDIP(scale_)); | 328 const gfx::Rect window_rect = gfx::ToEnclosingRect(GetWindowRectDIP(scale_)); |
309 const int left = window_rect.x(); | 329 const int left = window_rect.x(); |
310 const int right = window_rect.right(); | 330 const int right = window_rect.right(); |
311 int margin = kPanningMergin / scale_; // No need to consider DPI. | 331 int margin = kPanningMergin / scale_; // No need to consider DPI. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 if (ret) { | 366 if (ret) { |
347 // If the magnified region is moved, hides the mouse cursor and moves it. | 367 // If the magnified region is moved, hides the mouse cursor and moves it. |
348 if (x_diff != 0 || y_diff != 0) | 368 if (x_diff != 0 || y_diff != 0) |
349 root_window_->MoveCursorTo(mouse); | 369 root_window_->MoveCursorTo(mouse); |
350 } | 370 } |
351 } | 371 } |
352 } | 372 } |
353 | 373 |
354 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( | 374 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( |
355 const gfx::Point& location) { | 375 const gfx::Point& location) { |
376 DCHECK(root_window_); | |
377 | |
356 aura::client::CursorClient* cursor_client = | 378 aura::client::CursorClient* cursor_client = |
357 aura::client::GetCursorClient(root_window_); | 379 aura::client::GetCursorClient(root_window_); |
358 if (cursor_client) { | 380 if (cursor_client) { |
359 // When cursor is invisible, do not move or show the cursor after the | 381 // When cursor is invisible, do not move or show the cursor after the |
360 // animation. | 382 // animation. |
361 if (!cursor_client->IsCursorVisible()) | 383 if (!cursor_client->IsCursorVisible()) |
362 return; | 384 return; |
363 cursor_client->DisableMouseEvents(); | 385 cursor_client->DisableMouseEvents(); |
364 } | 386 } |
365 move_cursor_after_animation_ = true; | 387 move_cursor_after_animation_ = true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 | 431 |
410 aura::client::CursorClient* cursor_client = | 432 aura::client::CursorClient* cursor_client = |
411 aura::client::GetCursorClient(root_window_); | 433 aura::client::GetCursorClient(root_window_); |
412 if (cursor_client) | 434 if (cursor_client) |
413 cursor_client->EnableMouseEvents(); | 435 cursor_client->EnableMouseEvents(); |
414 } | 436 } |
415 | 437 |
416 is_on_animation_ = false; | 438 is_on_animation_ = false; |
417 } | 439 } |
418 | 440 |
441 void MagnificationControllerImpl::OnWindowDestroying( | |
442 aura::Window* root_window) { | |
443 if (root_window == root_window_) { | |
444 // There must be at least one root window because this controller is | |
445 // destroyed before the root windows get destroyed. | |
446 DCHECK(root_window); | |
447 | |
448 aura::RootWindow* active_root_window = Shell::GetActiveRootWindow(); | |
449 CHECK(active_root_window); | |
oshima
2013/02/27 17:21:43
what happens when the last root window gets detroy
| |
450 | |
451 // The destroyed root window must not be active. | |
452 CHECK_NE(active_root_window, root_window); | |
453 | |
454 SwitchTargetRootWindow(active_root_window); | |
455 point_of_interest_ = active_root_window->bounds().CenterPoint(); | |
456 } | |
457 } | |
458 | |
419 void MagnificationControllerImpl::SwitchTargetRootWindow( | 459 void MagnificationControllerImpl::SwitchTargetRootWindow( |
420 aura::RootWindow* new_root_window) { | 460 aura::RootWindow* new_root_window) { |
461 DCHECK(root_window_); | |
462 DCHECK(new_root_window); | |
463 | |
421 if (new_root_window == root_window_) | 464 if (new_root_window == root_window_) |
422 return; | 465 return; |
423 | 466 |
467 // Stores the previous scale. | |
424 float scale = GetScale(); | 468 float scale = GetScale(); |
425 | 469 |
470 // Unmagnify the previous root window. | |
471 root_window_->RemoveObserver(this); | |
426 RedrawKeepingMousePosition(1.0f, true); | 472 RedrawKeepingMousePosition(1.0f, true); |
473 | |
427 root_window_ = new_root_window; | 474 root_window_ = new_root_window; |
428 RedrawKeepingMousePosition(scale, true); | 475 RedrawKeepingMousePosition(scale, true); |
476 root_window_->AddObserver(this); | |
429 } | 477 } |
430 | 478 |
431 //////////////////////////////////////////////////////////////////////////////// | 479 //////////////////////////////////////////////////////////////////////////////// |
432 // MagnificationControllerImpl: MagnificationController implementation | 480 // MagnificationControllerImpl: MagnificationController implementation |
433 | 481 |
434 void MagnificationControllerImpl::SetScale(float scale, bool animate) { | 482 void MagnificationControllerImpl::SetScale(float scale, bool animate) { |
435 if (!is_enabled_) | 483 if (!is_enabled_) |
436 return; | 484 return; |
437 | 485 |
438 ValidateScale(&scale); | 486 ValidateScale(&scale); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 | 552 |
505 //////////////////////////////////////////////////////////////////////////////// | 553 //////////////////////////////////////////////////////////////////////////////// |
506 // MagnificationControllerImpl: aura::EventFilter implementation | 554 // MagnificationControllerImpl: aura::EventFilter implementation |
507 | 555 |
508 void MagnificationControllerImpl::OnMouseEvent(ui::MouseEvent* event) { | 556 void MagnificationControllerImpl::OnMouseEvent(ui::MouseEvent* event) { |
509 aura::Window* target = static_cast<aura::Window*>(event->target()); | 557 aura::Window* target = static_cast<aura::Window*>(event->target()); |
510 aura::RootWindow* current_root = target->GetRootWindow(); | 558 aura::RootWindow* current_root = target->GetRootWindow(); |
511 gfx::Rect root_bounds = current_root->bounds(); | 559 gfx::Rect root_bounds = current_root->bounds(); |
512 | 560 |
513 if (root_bounds.Contains(event->root_location())) { | 561 if (root_bounds.Contains(event->root_location())) { |
514 if (current_root != root_window_) | 562 // This must be before |SwitchTargetRootWindow()|. |
515 SwitchTargetRootWindow(current_root); | |
516 | |
517 point_of_interest_ = event->root_location(); | 563 point_of_interest_ = event->root_location(); |
518 | 564 |
519 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) | 565 if (current_root != root_window_) { |
566 DCHECK(current_root); | |
567 SwitchTargetRootWindow(current_root); | |
568 } | |
569 | |
570 if (IsMagnified() && root_window_ && event->type() == ui::ET_MOUSE_MOVED) | |
oshima
2013/02/27 19:07:04
you don't need to check root_window_ anymore, do y
| |
520 OnMouseMove(event->root_location()); | 571 OnMouseMove(event->root_location()); |
521 } | 572 } |
522 } | 573 } |
523 | 574 |
524 void MagnificationControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { | 575 void MagnificationControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { |
525 if (event->IsAltDown() && event->IsControlDown()) { | 576 if (event->IsAltDown() && event->IsControlDown()) { |
526 if (event->type() == ui::ET_SCROLL_FLING_START || | 577 if (event->type() == ui::ET_SCROLL_FLING_START || |
527 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 578 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
528 event->StopPropagation(); | 579 event->StopPropagation(); |
529 return; | 580 return; |
530 } | 581 } |
531 | 582 |
532 if (event->type() == ui::ET_SCROLL) { | 583 if (event->type() == ui::ET_SCROLL) { |
533 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); | 584 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); |
534 float scale = GetScale(); | 585 float scale = GetScale(); |
535 scale += scroll_event->y_offset() * kScrollScaleChangeFactor; | 586 scale += scroll_event->y_offset() * kScrollScaleChangeFactor; |
536 SetScale(scale, true); | 587 SetScale(scale, true); |
537 event->StopPropagation(); | 588 event->StopPropagation(); |
538 return; | 589 return; |
539 } | 590 } |
540 } | 591 } |
541 } | 592 } |
542 | 593 |
543 void MagnificationControllerImpl::OnTouchEvent(ui::TouchEvent* event) { | 594 void MagnificationControllerImpl::OnTouchEvent(ui::TouchEvent* event) { |
544 aura::Window* target = static_cast<aura::Window*>(event->target()); | 595 aura::Window* target = static_cast<aura::Window*>(event->target()); |
545 aura::RootWindow* current_root = target->GetRootWindow(); | 596 aura::RootWindow* current_root = target->GetRootWindow(); |
546 if (current_root == root_window_) { | 597 if (current_root && current_root == root_window_) { |
oshima
2013/02/27 19:07:04
when can |current_root| be NULL?
| |
547 gfx::Rect root_bounds = current_root->bounds(); | 598 gfx::Rect root_bounds = current_root->bounds(); |
548 if (root_bounds.Contains(event->root_location())) | 599 if (root_bounds.Contains(event->root_location())) |
549 point_of_interest_ = event->root_location(); | 600 point_of_interest_ = event->root_location(); |
550 } | 601 } |
551 } | 602 } |
552 | 603 |
553 //////////////////////////////////////////////////////////////////////////////// | 604 //////////////////////////////////////////////////////////////////////////////// |
554 // MagnificationController: | 605 // MagnificationController: |
555 | 606 |
556 // static | 607 // static |
557 MagnificationController* MagnificationController::CreateInstance() { | 608 MagnificationController* MagnificationController::CreateInstance() { |
558 return new MagnificationControllerImpl(); | 609 return new MagnificationControllerImpl(); |
559 } | 610 } |
560 | 611 |
561 } // namespace ash | 612 } // namespace ash |
OLD | NEW |