| 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/wm/ash_native_cursor_manager.h" | 5 #include "ash/wm/ash_native_cursor_manager.h" |
| 6 | 6 |
| 7 #include "ash/display/cursor_window_controller.h" | 7 #include "ash/display/cursor_window_controller.h" |
| 8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // Mirror window never process events. | 53 // Mirror window never process events. |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 AshNativeCursorManager::AshNativeCursorManager() | 58 AshNativeCursorManager::AshNativeCursorManager() |
| 59 : native_cursor_enabled_(true), image_cursors_(new ui::ImageCursors) {} | 59 : native_cursor_enabled_(true), image_cursors_(new ui::ImageCursors) {} |
| 60 | 60 |
| 61 AshNativeCursorManager::~AshNativeCursorManager() {} | 61 AshNativeCursorManager::~AshNativeCursorManager() {} |
| 62 | 62 |
| 63 void AshNativeCursorManager::AddObserver(Observer* observer) { |
| 64 observers_.AddObserver(observer); |
| 65 } |
| 66 |
| 67 void AshNativeCursorManager::RemoveObserver(Observer* observer) { |
| 68 observers_.RemoveObserver(observer); |
| 69 } |
| 70 |
| 63 void AshNativeCursorManager::SetNativeCursorEnabled(bool enabled) { | 71 void AshNativeCursorManager::SetNativeCursorEnabled(bool enabled) { |
| 64 native_cursor_enabled_ = enabled; | 72 native_cursor_enabled_ = enabled; |
| 65 | 73 |
| 66 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 74 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 67 SetCursor(cursor_manager->GetCursor(), cursor_manager); | 75 SetCursor(cursor_manager->GetCursor(), cursor_manager); |
| 68 } | 76 } |
| 69 | 77 |
| 70 void AshNativeCursorManager::SetDisplay( | 78 void AshNativeCursorManager::SetDisplay( |
| 71 const display::Display& display, | 79 const display::Display& display, |
| 72 ::wm::NativeCursorManagerDelegate* delegate) { | 80 ::wm::NativeCursorManagerDelegate* delegate) { |
| 73 DCHECK(display.is_valid()); | 81 DCHECK(display.is_valid()); |
| 82 |
| 83 for (Observer& observer : observers_) |
| 84 observer.OnCursorDisplayChanging(display); |
| 85 |
| 74 // Use the platform's device scale factor instead of the display's, which | 86 // Use the platform's device scale factor instead of the display's, which |
| 75 // might have been adjusted for the UI scale. | 87 // might have been adjusted for the UI scale. |
| 76 const float original_scale = Shell::GetInstance() | 88 const float original_scale = Shell::GetInstance() |
| 77 ->display_manager() | 89 ->display_manager() |
| 78 ->GetDisplayInfo(display.id()) | 90 ->GetDisplayInfo(display.id()) |
| 79 .device_scale_factor(); | 91 .device_scale_factor(); |
| 80 // And use the nearest resource scale factor. | 92 // And use the nearest resource scale factor. |
| 81 const float cursor_scale = | 93 const float cursor_scale = |
| 82 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale)); | 94 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale)); |
| 83 | 95 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 disabled_cursor_location_); | 168 disabled_cursor_location_); |
| 157 } else { | 169 } else { |
| 158 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); | 170 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); |
| 159 } | 171 } |
| 160 | 172 |
| 161 SetVisibility(delegate->IsCursorVisible(), delegate); | 173 SetVisibility(delegate->IsCursorVisible(), delegate); |
| 162 NotifyMouseEventsEnableStateChange(enabled); | 174 NotifyMouseEventsEnableStateChange(enabled); |
| 163 } | 175 } |
| 164 | 176 |
| 165 } // namespace ash | 177 } // namespace ash |
| OLD | NEW |