| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/ws/focus_controller.h" | 5 #include "services/ui/ws/focus_controller.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "services/ui/public/interfaces/window_manager.mojom.h" | 8 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 9 #include "services/ui/ws/focus_controller_delegate.h" | 9 #include "services/ui/ws/focus_controller_delegate.h" |
| 10 #include "services/ui/ws/focus_controller_observer.h" | 10 #include "services/ui/ws/focus_controller_observer.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 void FocusController::SetActiveWindow(ServerWindow* window, | 134 void FocusController::SetActiveWindow(ServerWindow* window, |
| 135 ActivationChangeReason reason) { | 135 ActivationChangeReason reason) { |
| 136 DCHECK(!window || CanBeActivated(window)); | 136 DCHECK(!window || CanBeActivated(window)); |
| 137 if (active_window_ == window) | 137 if (active_window_ == window) |
| 138 return; | 138 return; |
| 139 if (reason != ActivationChangeReason::CYCLE) { | 139 if (reason != ActivationChangeReason::CYCLE) { |
| 140 cycle_windows_.reset(); | 140 cycle_windows_.reset(); |
| 141 } else if (activation_reason_ != ActivationChangeReason::CYCLE) { | 141 } else if (activation_reason_ != ActivationChangeReason::CYCLE) { |
| 142 DCHECK(!cycle_windows_); | 142 DCHECK(!cycle_windows_); |
| 143 cycle_windows_.reset(new ServerWindowTracker()); | 143 cycle_windows_ = base::MakeUnique<ServerWindowTracker>(); |
| 144 if (active_window_) | 144 if (active_window_) |
| 145 cycle_windows_->Add(active_window_); | 145 cycle_windows_->Add(active_window_); |
| 146 } | 146 } |
| 147 | 147 |
| 148 ServerWindow* old_active = active_window_; | 148 ServerWindow* old_active = active_window_; |
| 149 active_window_ = window; | 149 active_window_ = window; |
| 150 activation_reason_ = reason; | 150 activation_reason_ = reason; |
| 151 FOR_EACH_OBSERVER(FocusControllerObserver, observers_, | 151 FOR_EACH_OBSERVER(FocusControllerObserver, observers_, |
| 152 OnActivationChanged(old_active, active_window_)); | 152 OnActivationChanged(old_active, active_window_)); |
| 153 if (active_window_ && activation_reason_ == ActivationChangeReason::CYCLE) | 153 if (active_window_ && activation_reason_ == ActivationChangeReason::CYCLE) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 focused_window_ = window; | 229 focused_window_ = window; |
| 230 // We can currently use only a single ServerWindowDrawnTracker since focused | 230 // We can currently use only a single ServerWindowDrawnTracker since focused |
| 231 // window is expected to be a direct descendant of the active window. | 231 // window is expected to be a direct descendant of the active window. |
| 232 if (focused_window_ && active_window_) { | 232 if (focused_window_ && active_window_) { |
| 233 DCHECK(active_window_->Contains(focused_window_)); | 233 DCHECK(active_window_->Contains(focused_window_)); |
| 234 } | 234 } |
| 235 ServerWindow* track_window = focused_window_; | 235 ServerWindow* track_window = focused_window_; |
| 236 if (!track_window) | 236 if (!track_window) |
| 237 track_window = active_window_; | 237 track_window = active_window_; |
| 238 if (track_window) | 238 if (track_window) { |
| 239 drawn_tracker_.reset(new ServerWindowDrawnTracker(track_window, this)); | 239 drawn_tracker_ = |
| 240 else | 240 base::MakeUnique<ServerWindowDrawnTracker>(track_window, this); |
| 241 } else { |
| 241 drawn_tracker_.reset(); | 242 drawn_tracker_.reset(); |
| 243 } |
| 242 return true; | 244 return true; |
| 243 } | 245 } |
| 244 | 246 |
| 245 void FocusController::OnDrawnStateWillChange(ServerWindow* ancestor, | 247 void FocusController::OnDrawnStateWillChange(ServerWindow* ancestor, |
| 246 ServerWindow* window, | 248 ServerWindow* window, |
| 247 bool is_drawn) { | 249 bool is_drawn) { |
| 248 DCHECK(!is_drawn); | 250 DCHECK(!is_drawn); |
| 249 DCHECK_NE(ancestor, window); | 251 DCHECK_NE(ancestor, window); |
| 250 DCHECK(root_->Contains(window)); | 252 DCHECK(root_->Contains(window)); |
| 251 drawn_tracker_.reset(); | 253 drawn_tracker_.reset(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 304 } |
| 303 | 305 |
| 304 void FocusController::OnDrawnStateChanged(ServerWindow* ancestor, | 306 void FocusController::OnDrawnStateChanged(ServerWindow* ancestor, |
| 305 ServerWindow* window, | 307 ServerWindow* window, |
| 306 bool is_drawn) { | 308 bool is_drawn) { |
| 307 // DCHECK(false); TODO(sadrul): | 309 // DCHECK(false); TODO(sadrul): |
| 308 } | 310 } |
| 309 | 311 |
| 310 } // namespace ws | 312 } // namespace ws |
| 311 } // namespace ui | 313 } // namespace ui |
| OLD | NEW |