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