| 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/common/system/chromeos/palette/palette_utils.h" | 7 #include "ash/common/system/chromeos/palette/palette_utils.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "third_party/skia/include/core/SkDrawLooper.h" | 9 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 return; | 276 return; |
| 277 | 277 |
| 278 // Compute the event location in screen space. | 278 // Compute the event location in screen space. |
| 279 aura::Window* target = static_cast<aura::Window*>(event->target()); | 279 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 280 aura::Window* event_root = target->GetRootWindow(); | 280 aura::Window* event_root = target->GetRootWindow(); |
| 281 gfx::Point screen_point = event->root_location(); | 281 gfx::Point screen_point = event->root_location(); |
| 282 wm::ConvertPointToScreen(event_root, &screen_point); | 282 wm::ConvertPointToScreen(event_root, &screen_point); |
| 283 | 283 |
| 284 // If the stylus is pressed on the palette icon or widget, do not activate. | 284 // If the stylus is pressed on the palette icon or widget, do not activate. |
| 285 if (event->type() == ui::ET_TOUCH_PRESSED && | 285 if (event->type() == ui::ET_TOUCH_PRESSED && |
| 286 !PaletteContainsPointInScreen(screen_point)) { | 286 !palette_utils::PaletteContainsPointInScreen(screen_point)) { |
| 287 SetActive(true); | 287 SetActive(true); |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (event->type() == ui::ET_TOUCH_RELEASED) | 290 if (event->type() == ui::ET_TOUCH_RELEASED) |
| 291 SetActive(false); | 291 SetActive(false); |
| 292 | 292 |
| 293 if (!is_active_) | 293 if (!is_active_) |
| 294 return; | 294 return; |
| 295 | 295 |
| 296 // If the previous root window was detached host_widget_ will be null; | 296 // If the previous root window was detached host_widget_ will be null; |
| 297 // reconstruct it. We also need to change the root window if the cursor has | 297 // reconstruct it. We also need to change the root window if the cursor has |
| 298 // crossed display boundries. | 298 // crossed display boundries. |
| 299 SwitchTargetRootWindowIfNeeded(GetCurrentRootWindow()); | 299 SwitchTargetRootWindowIfNeeded(GetCurrentRootWindow()); |
| 300 | 300 |
| 301 // If that failed for any reason return. | 301 // If that failed for any reason return. |
| 302 if (!host_widget_) { | 302 if (!host_widget_) { |
| 303 SetActive(false); | 303 SetActive(false); |
| 304 return; | 304 return; |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Remap point from where it was captured to the display it is actually on. | 307 // Remap point from where it was captured to the display it is actually on. |
| 308 gfx::Point point = event->root_location(); | 308 gfx::Point point = event->root_location(); |
| 309 aura::Window::ConvertPointToTarget( | 309 aura::Window::ConvertPointToTarget( |
| 310 event_root, host_widget_->GetNativeView()->GetRootWindow(), &point); | 310 event_root, host_widget_->GetNativeView()->GetRootWindow(), &point); |
| 311 host_widget_->SetBounds(GetBounds(point)); | 311 host_widget_->SetBounds(GetBounds(point)); |
| 312 | 312 |
| 313 // If the stylus is over the palette icon or widget, do not consume the event. | 313 // If the stylus is over the palette icon or widget, do not consume the event. |
| 314 if (!PaletteContainsPointInScreen(screen_point)) | 314 if (!palette_utils::PaletteContainsPointInScreen(screen_point)) |
| 315 event->StopPropagation(); | 315 event->StopPropagation(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void PartialMagnificationController::CreateMagnifierWindow( | 318 void PartialMagnificationController::CreateMagnifierWindow( |
| 319 aura::Window* root_window) { | 319 aura::Window* root_window) { |
| 320 if (host_widget_ || !root_window) | 320 if (host_widget_ || !root_window) |
| 321 return; | 321 return; |
| 322 | 322 |
| 323 root_window->AddObserver(this); | 323 root_window->AddObserver(this); |
| 324 | 324 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 void PartialMagnificationController::RemoveZoomWidgetObservers() { | 374 void PartialMagnificationController::RemoveZoomWidgetObservers() { |
| 375 DCHECK(host_widget_); | 375 DCHECK(host_widget_); |
| 376 host_widget_->RemoveObserver(this); | 376 host_widget_->RemoveObserver(this); |
| 377 aura::Window* root_window = host_widget_->GetNativeView()->GetRootWindow(); | 377 aura::Window* root_window = host_widget_->GetNativeView()->GetRootWindow(); |
| 378 DCHECK(root_window); | 378 DCHECK(root_window); |
| 379 root_window->RemoveObserver(this); | 379 root_window->RemoveObserver(this); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace ash | 382 } // namespace ash |
| OLD | NEW |