| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/wm/core/cursor_manager.h" | 5 #include "ui/wm/core/cursor_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 gfx::NativeCursor CursorManager::GetCursor() const { | 103 gfx::NativeCursor CursorManager::GetCursor() const { |
| 104 return current_state_->cursor(); | 104 return current_state_->cursor(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void CursorManager::ShowCursor() { | 107 void CursorManager::ShowCursor() { |
| 108 last_cursor_visibility_state_ = true; | 108 last_cursor_visibility_state_ = true; |
| 109 state_on_unlock_->SetVisible(true); | 109 state_on_unlock_->SetVisible(true); |
| 110 if (cursor_lock_count_ == 0 && | 110 if (cursor_lock_count_ == 0 && |
| 111 IsCursorVisible() != state_on_unlock_->visible()) { | 111 IsCursorVisible() != state_on_unlock_->visible()) { |
| 112 delegate_->SetVisibility(state_on_unlock_->visible(), this); | 112 delegate_->SetVisibility(state_on_unlock_->visible(), this); |
| 113 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, | 113 for (auto& observer : observers_) |
| 114 OnCursorVisibilityChanged(true)); | 114 observer.OnCursorVisibilityChanged(true); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CursorManager::HideCursor() { | 118 void CursorManager::HideCursor() { |
| 119 last_cursor_visibility_state_ = false; | 119 last_cursor_visibility_state_ = false; |
| 120 state_on_unlock_->SetVisible(false); | 120 state_on_unlock_->SetVisible(false); |
| 121 if (cursor_lock_count_ == 0 && | 121 if (cursor_lock_count_ == 0 && |
| 122 IsCursorVisible() != state_on_unlock_->visible()) { | 122 IsCursorVisible() != state_on_unlock_->visible()) { |
| 123 delegate_->SetVisibility(state_on_unlock_->visible(), this); | 123 delegate_->SetVisibility(state_on_unlock_->visible(), this); |
| 124 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, | 124 for (auto& observer : observers_) |
| 125 OnCursorVisibilityChanged(false)); | 125 observer.OnCursorVisibilityChanged(false); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool CursorManager::IsCursorVisible() const { | 129 bool CursorManager::IsCursorVisible() const { |
| 130 return current_state_->visible(); | 130 return current_state_->visible(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void CursorManager::SetCursorSet(ui::CursorSetType cursor_set) { | 133 void CursorManager::SetCursorSet(ui::CursorSetType cursor_set) { |
| 134 state_on_unlock_->set_cursor_set(cursor_set); | 134 state_on_unlock_->set_cursor_set(cursor_set); |
| 135 if (GetCursorSet() != state_on_unlock_->cursor_set()) { | 135 if (GetCursorSet() != state_on_unlock_->cursor_set()) { |
| 136 delegate_->SetCursorSet(state_on_unlock_->cursor_set(), this); | 136 delegate_->SetCursorSet(state_on_unlock_->cursor_set(), this); |
| 137 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, | 137 for (auto& observer : observers_) |
| 138 OnCursorSetChanged(cursor_set)); | 138 observer.OnCursorSetChanged(cursor_set); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 ui::CursorSetType CursorManager::GetCursorSet() const { | 142 ui::CursorSetType CursorManager::GetCursorSet() const { |
| 143 return current_state_->cursor_set(); | 143 return current_state_->cursor_set(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void CursorManager::EnableMouseEvents() { | 146 void CursorManager::EnableMouseEvents() { |
| 147 state_on_unlock_->SetMouseEventsEnabled(true); | 147 state_on_unlock_->SetMouseEventsEnabled(true); |
| 148 if (cursor_lock_count_ == 0 && | 148 if (cursor_lock_count_ == 0 && |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 | 213 |
| 214 void CursorManager::CommitCursor(gfx::NativeCursor cursor) { | 214 void CursorManager::CommitCursor(gfx::NativeCursor cursor) { |
| 215 current_state_->set_cursor(cursor); | 215 current_state_->set_cursor(cursor); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void CursorManager::CommitVisibility(bool visible) { | 218 void CursorManager::CommitVisibility(bool visible) { |
| 219 // TODO(tdanderson): Find a better place for this so we don't | 219 // TODO(tdanderson): Find a better place for this so we don't |
| 220 // notify the observers more than is necessary. | 220 // notify the observers more than is necessary. |
| 221 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, | 221 for (auto& observer : observers_) |
| 222 OnCursorVisibilityChanged(visible)); | 222 observer.OnCursorVisibilityChanged(visible); |
| 223 current_state_->SetVisible(visible); | 223 current_state_->SetVisible(visible); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void CursorManager::CommitCursorSet(ui::CursorSetType cursor_set) { | 226 void CursorManager::CommitCursorSet(ui::CursorSetType cursor_set) { |
| 227 current_state_->set_cursor_set(cursor_set); | 227 current_state_->set_cursor_set(cursor_set); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void CursorManager::CommitMouseEventsEnabled(bool enabled) { | 230 void CursorManager::CommitMouseEventsEnabled(bool enabled) { |
| 231 current_state_->SetMouseEventsEnabled(enabled); | 231 current_state_->SetMouseEventsEnabled(enabled); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace wm | 234 } // namespace wm |
| OLD | NEW |