| 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/display/cursor_window_controller.h" | 5 #include "ash/display/cursor_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/display/mirror_window_controller.h" | 8 #include "ash/display/mirror_window_controller.h" |
| 9 #include "ash/display/window_tree_host_manager.h" | 9 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/window_delegate.h" | 14 #include "ui/aura/window_delegate.h" |
| 15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/base/cursor/cursors_aura.h" | 16 #include "ui/base/cursor/cursors_aura.h" |
| 17 #include "ui/base/hit_test.h" | 17 #include "ui/base/hit_test.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/compositor/dip_util.h" | 19 #include "ui/compositor/dip_util.h" |
| 20 #include "ui/compositor/paint_recorder.h" | 20 #include "ui/compositor/paint_recorder.h" |
| 21 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
| 23 #include "ui/gfx/geometry/dip_util.h" | 23 #include "ui/gfx/geometry/dip_util.h" |
| 24 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
| 25 #include "ui/gfx/image/image_skia_operations.h" | 25 #include "ui/gfx/image/image_skia_operations.h" |
| 26 #include "ui/gfx/screen.h" |
| 26 | 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 | 29 |
| 29 class CursorWindowDelegate : public aura::WindowDelegate { | 30 class CursorWindowDelegate : public aura::WindowDelegate { |
| 30 public: | 31 public: |
| 31 CursorWindowDelegate() {} | 32 CursorWindowDelegate() {} |
| 32 ~CursorWindowDelegate() override {} | 33 ~CursorWindowDelegate() override {} |
| 33 | 34 |
| 34 // aura::WindowDelegate overrides: | 35 // aura::WindowDelegate overrides: |
| 35 gfx::Size GetMinimumSize() const override { return size_; } | 36 gfx::Size GetMinimumSize() const override { return size_; } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (is_cursor_compositing_enabled_ != enabled) { | 95 if (is_cursor_compositing_enabled_ != enabled) { |
| 95 is_cursor_compositing_enabled_ = enabled; | 96 is_cursor_compositing_enabled_ = enabled; |
| 96 if (display_.is_valid()) | 97 if (display_.is_valid()) |
| 97 UpdateCursorImage(); | 98 UpdateCursorImage(); |
| 98 UpdateContainer(); | 99 UpdateContainer(); |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 void CursorWindowController::UpdateContainer() { | 103 void CursorWindowController::UpdateContainer() { |
| 103 if (is_cursor_compositing_enabled_) { | 104 if (is_cursor_compositing_enabled_) { |
| 104 gfx::Screen* screen = Shell::GetScreen(); | 105 gfx::Screen* screen = gfx::Screen::GetScreen(); |
| 105 gfx::Display display = screen->GetDisplayNearestPoint( | 106 gfx::Display display = screen->GetDisplayNearestPoint( |
| 106 screen->GetCursorScreenPoint()); | 107 screen->GetCursorScreenPoint()); |
| 107 DCHECK(display.is_valid()); | 108 DCHECK(display.is_valid()); |
| 108 if (display.is_valid()) | 109 if (display.is_valid()) |
| 109 SetDisplay(display); | 110 SetDisplay(display); |
| 110 } else { | 111 } else { |
| 111 aura::Window* mirror_window = Shell::GetInstance() | 112 aura::Window* mirror_window = Shell::GetInstance() |
| 112 ->window_tree_host_manager() | 113 ->window_tree_host_manager() |
| 113 ->mirror_window_controller() | 114 ->mirror_window_controller() |
| 114 ->GetWindow(); | 115 ->GetWindow(); |
| 115 if (mirror_window) | 116 if (mirror_window) |
| 116 display_ = Shell::GetScreen()->GetPrimaryDisplay(); | 117 display_ = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
| 117 SetContainer(mirror_window); | 118 SetContainer(mirror_window); |
| 118 } | 119 } |
| 119 // Updates the hot point based on the current display. | 120 // Updates the hot point based on the current display. |
| 120 UpdateCursorImage(); | 121 UpdateCursorImage(); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void CursorWindowController::SetDisplay(const gfx::Display& display) { | 124 void CursorWindowController::SetDisplay(const gfx::Display& display) { |
| 124 if (!is_cursor_compositing_enabled_) | 125 if (!is_cursor_compositing_enabled_) |
| 125 return; | 126 return; |
| 126 | 127 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 cursor_window_->Show(); | 288 cursor_window_->Show(); |
| 288 else | 289 else |
| 289 cursor_window_->Hide(); | 290 cursor_window_->Hide(); |
| 290 } | 291 } |
| 291 | 292 |
| 292 const gfx::ImageSkia& CursorWindowController::GetCursorImageForTest() const { | 293 const gfx::ImageSkia& CursorWindowController::GetCursorImageForTest() const { |
| 293 return delegate_->cursor_image(); | 294 return delegate_->cursor_image(); |
| 294 } | 295 } |
| 295 | 296 |
| 296 } // namespace ash | 297 } // namespace ash |
| OLD | NEW |