| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/utility/screenshot_controller.h" | 5 #include "ash/utility/screenshot_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/display/mouse_cursor_event_filter.h" | 9 #include "ash/display/mouse_cursor_event_filter.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 class ScreenshotController::ScopedCursorSetter { | 198 class ScreenshotController::ScopedCursorSetter { |
| 199 public: | 199 public: |
| 200 ScopedCursorSetter(::wm::CursorManager* cursor_manager, | 200 ScopedCursorSetter(::wm::CursorManager* cursor_manager, |
| 201 gfx::NativeCursor cursor) | 201 gfx::NativeCursor cursor) |
| 202 : cursor_manager_(nullptr) { | 202 : cursor_manager_(nullptr) { |
| 203 if (cursor_manager->IsCursorLocked()) | 203 if (cursor_manager->IsCursorLocked()) |
| 204 return; | 204 return; |
| 205 gfx::NativeCursor original_cursor = cursor_manager->GetCursor(); | 205 gfx::NativeCursor original_cursor = cursor_manager->GetCursor(); |
| 206 cursor_manager_ = cursor_manager; | 206 cursor_manager_ = cursor_manager; |
| 207 if (cursor == ui::kCursorNone) { | 207 if (cursor == ui::CursorType::kNone) { |
| 208 cursor_manager_->HideCursor(); | 208 cursor_manager_->HideCursor(); |
| 209 } else { | 209 } else { |
| 210 cursor_manager_->SetCursor(cursor); | 210 cursor_manager_->SetCursor(cursor); |
| 211 cursor_manager_->ShowCursor(); | 211 cursor_manager_->ShowCursor(); |
| 212 } | 212 } |
| 213 cursor_manager_->LockCursor(); | 213 cursor_manager_->LockCursor(); |
| 214 // Set/ShowCursor does not make any effects at this point but it sets | 214 // Set/ShowCursor does not make any effects at this point but it sets |
| 215 // back to the original cursor when unlocked. | 215 // back to the original cursor when unlocked. |
| 216 cursor_manager_->SetCursor(original_cursor); | 216 cursor_manager_->SetCursor(original_cursor); |
| 217 cursor_manager_->ShowCursor(); | 217 cursor_manager_->ShowCursor(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 mode_ = WINDOW; | 254 mode_ = WINDOW; |
| 255 | 255 |
| 256 display::Screen::GetScreen()->AddObserver(this); | 256 display::Screen::GetScreen()->AddObserver(this); |
| 257 for (aura::Window* root : Shell::GetAllRootWindows()) { | 257 for (aura::Window* root : Shell::GetAllRootWindows()) { |
| 258 layers_[root] = base::MakeUnique<ScreenshotLayer>( | 258 layers_[root] = base::MakeUnique<ScreenshotLayer>( |
| 259 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(), | 259 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(), |
| 260 true); | 260 true); |
| 261 } | 261 } |
| 262 SetSelectedWindow(wm::GetActiveWindow()); | 262 SetSelectedWindow(wm::GetActiveWindow()); |
| 263 | 263 |
| 264 cursor_setter_.reset( | 264 cursor_setter_.reset(new ScopedCursorSetter(Shell::Get()->cursor_manager(), |
| 265 new ScopedCursorSetter(Shell::Get()->cursor_manager(), ui::kCursorCross)); | 265 ui::CursorType::kCross)); |
| 266 | 266 |
| 267 EnableMouseWarp(true); | 267 EnableMouseWarp(true); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void ScreenshotController::StartPartialScreenshotSession( | 270 void ScreenshotController::StartPartialScreenshotSession( |
| 271 ScreenshotDelegate* screenshot_delegate, | 271 ScreenshotDelegate* screenshot_delegate, |
| 272 bool draw_overlay_immediately) { | 272 bool draw_overlay_immediately) { |
| 273 // Already in a screenshot session. | 273 // Already in a screenshot session. |
| 274 if (screenshot_delegate_) { | 274 if (screenshot_delegate_) { |
| 275 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); | 275 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 | 278 |
| 279 screenshot_delegate_ = screenshot_delegate; | 279 screenshot_delegate_ = screenshot_delegate; |
| 280 mode_ = PARTIAL; | 280 mode_ = PARTIAL; |
| 281 display::Screen::GetScreen()->AddObserver(this); | 281 display::Screen::GetScreen()->AddObserver(this); |
| 282 for (aura::Window* root : Shell::GetAllRootWindows()) { | 282 for (aura::Window* root : Shell::GetAllRootWindows()) { |
| 283 layers_[root] = base::MakeUnique<ScreenshotLayer>( | 283 layers_[root] = base::MakeUnique<ScreenshotLayer>( |
| 284 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(), | 284 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(), |
| 285 draw_overlay_immediately); | 285 draw_overlay_immediately); |
| 286 } | 286 } |
| 287 | 287 |
| 288 if (!pen_events_only_) { | 288 if (!pen_events_only_) { |
| 289 cursor_setter_.reset(new ScopedCursorSetter(Shell::Get()->cursor_manager(), | 289 cursor_setter_.reset(new ScopedCursorSetter(Shell::Get()->cursor_manager(), |
| 290 ui::kCursorCross)); | 290 ui::CursorType::kCross)); |
| 291 } | 291 } |
| 292 | 292 |
| 293 EnableMouseWarp(false); | 293 EnableMouseWarp(false); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void ScreenshotController::CancelScreenshotSession() { | 296 void ScreenshotController::CancelScreenshotSession() { |
| 297 for (aura::Window* root : Shell::GetAllRootWindows()) { | 297 for (aura::Window* root : Shell::GetAllRootWindows()) { |
| 298 // Having pre-handled all mouse events, widgets that had mouse capture may | 298 // Having pre-handled all mouse events, widgets that had mouse capture may |
| 299 // now misbehave, so break any existing captures. Do this after the | 299 // now misbehave, so break any existing captures. Do this after the |
| 300 // screenshot session is over so that it's still possible to screenshot | 300 // screenshot session is over so that it's still possible to screenshot |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 CompletePartialScreenshot(); | 333 CompletePartialScreenshot(); |
| 334 } | 334 } |
| 335 } else { | 335 } else { |
| 336 root_window_ = current_root; | 336 root_window_ = current_root; |
| 337 start_position_ = event.root_location(); | 337 start_position_ = event.root_location(); |
| 338 if (!pen_events_only_) { | 338 if (!pen_events_only_) { |
| 339 // ScopedCursorSetter must be reset first to make sure that its dtor is | 339 // ScopedCursorSetter must be reset first to make sure that its dtor is |
| 340 // called before ctor is called. | 340 // called before ctor is called. |
| 341 cursor_setter_.reset(); | 341 cursor_setter_.reset(); |
| 342 cursor_setter_.reset(new ScopedCursorSetter( | 342 cursor_setter_.reset(new ScopedCursorSetter( |
| 343 Shell::Get()->cursor_manager(), ui::kCursorNone)); | 343 Shell::Get()->cursor_manager(), ui::CursorType::kNone)); |
| 344 } | 344 } |
| 345 Update(event); | 345 Update(event); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 void ScreenshotController::CompleteWindowScreenshot() { | 349 void ScreenshotController::CompleteWindowScreenshot() { |
| 350 if (selected_) | 350 if (selected_) |
| 351 screenshot_delegate_->HandleTakeWindowScreenshot(selected_); | 351 screenshot_delegate_->HandleTakeWindowScreenshot(selected_); |
| 352 CancelScreenshotSession(); | 352 CancelScreenshotSession(); |
| 353 } | 353 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 545 |
| 546 void ScreenshotController::OnDisplayMetricsChanged( | 546 void ScreenshotController::OnDisplayMetricsChanged( |
| 547 const display::Display& display, | 547 const display::Display& display, |
| 548 uint32_t changed_metrics) {} | 548 uint32_t changed_metrics) {} |
| 549 | 549 |
| 550 void ScreenshotController::OnWindowDestroying(aura::Window* window) { | 550 void ScreenshotController::OnWindowDestroying(aura::Window* window) { |
| 551 SetSelectedWindow(nullptr); | 551 SetSelectedWindow(nullptr); |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace ash | 554 } // namespace ash |
| OLD | NEW |