| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/default_activation_client.h" | 5 #include "ui/wm/core/default_activation_client.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/wm/public/activation_change_observer.h" | 9 #include "ui/wm/public/activation_change_observer.h" |
| 10 #include "ui/wm/public/activation_delegate.h" | 10 #include "ui/wm/public/activation_delegate.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void DefaultActivationClient::ActivateWindow(aura::Window* window) { | 62 void DefaultActivationClient::ActivateWindow(aura::Window* window) { |
| 63 ActivateWindowImpl(aura::client::ActivationChangeObserver::ActivationReason:: | 63 ActivateWindowImpl(aura::client::ActivationChangeObserver::ActivationReason:: |
| 64 ACTIVATION_CLIENT, | 64 ACTIVATION_CLIENT, |
| 65 window); | 65 window); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void DefaultActivationClient::ActivateWindowImpl( | 68 void DefaultActivationClient::ActivateWindowImpl( |
| 69 aura::client::ActivationChangeObserver::ActivationReason reason, | 69 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 70 aura::Window* window) { | 70 aura::Window* window) { |
| 71 aura::Window* last_active = GetActiveWindow(); | 71 aura::Window* last_active = ActivationClient::GetActiveWindow(); |
| 72 if (last_active == window) | 72 if (last_active == window) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 last_active_ = last_active; | 75 last_active_ = last_active; |
| 76 RemoveActiveWindow(window); | 76 RemoveActiveWindow(window); |
| 77 active_windows_.push_back(window); | 77 active_windows_.push_back(window); |
| 78 window->parent()->StackChildAtTop(window); | 78 window->parent()->StackChildAtTop(window); |
| 79 window->AddObserver(this); | 79 window->AddObserver(this); |
| 80 | 80 |
| 81 for (auto& observer : observers_) | 81 for (auto& observer : observers_) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 97 aura::client::GetActivationChangeObserver(window); | 97 aura::client::GetActivationChangeObserver(window); |
| 98 if (observer) { | 98 if (observer) { |
| 99 observer->OnWindowActivated(aura::client::ActivationChangeObserver:: | 99 observer->OnWindowActivated(aura::client::ActivationChangeObserver:: |
| 100 ActivationReason::ACTIVATION_CLIENT, | 100 ActivationReason::ACTIVATION_CLIENT, |
| 101 nullptr, window); | 101 nullptr, window); |
| 102 } | 102 } |
| 103 if (last_active_) | 103 if (last_active_) |
| 104 ActivateWindow(last_active_); | 104 ActivateWindow(last_active_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 aura::Window* DefaultActivationClient::GetActiveWindow() { | 107 const aura::Window* DefaultActivationClient::GetActiveWindow() const { |
| 108 if (active_windows_.empty()) | 108 if (active_windows_.empty()) |
| 109 return nullptr; | 109 return nullptr; |
| 110 return active_windows_.back(); | 110 return active_windows_.back(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 aura::Window* DefaultActivationClient::GetActivatableWindow( | 113 aura::Window* DefaultActivationClient::GetActivatableWindow( |
| 114 aura::Window* window) { | 114 aura::Window* window) { |
| 115 return nullptr; | 115 return nullptr; |
| 116 } | 116 } |
| 117 | 117 |
| 118 aura::Window* DefaultActivationClient::GetToplevelWindow(aura::Window* window) { | 118 aura::Window* DefaultActivationClient::GetToplevelWindow(aura::Window* window) { |
| 119 return nullptr; | 119 return nullptr; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool DefaultActivationClient::CanActivateWindow(aura::Window* window) const { | 122 bool DefaultActivationClient::CanActivateWindow(aura::Window* window) const { |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 //////////////////////////////////////////////////////////////////////////////// | 126 //////////////////////////////////////////////////////////////////////////////// |
| 127 // DefaultActivationClient, aura::WindowObserver implementation: | 127 // DefaultActivationClient, aura::WindowObserver implementation: |
| 128 | 128 |
| 129 void DefaultActivationClient::OnWindowDestroyed(aura::Window* window) { | 129 void DefaultActivationClient::OnWindowDestroyed(aura::Window* window) { |
| 130 if (window == last_active_) | 130 if (window == last_active_) |
| 131 last_active_ = nullptr; | 131 last_active_ = nullptr; |
| 132 | 132 |
| 133 if (window == GetActiveWindow()) { | 133 if (window == GetActiveWindow()) { |
| 134 active_windows_.pop_back(); | 134 active_windows_.pop_back(); |
| 135 aura::Window* next_active = GetActiveWindow(); | 135 aura::Window* next_active = ActivationClient::GetActiveWindow(); |
| 136 if (next_active && aura::client::GetActivationChangeObserver(next_active)) { | 136 if (next_active && aura::client::GetActivationChangeObserver(next_active)) { |
| 137 aura::client::GetActivationChangeObserver(next_active) | 137 aura::client::GetActivationChangeObserver(next_active) |
| 138 ->OnWindowActivated(aura::client::ActivationChangeObserver:: | 138 ->OnWindowActivated(aura::client::ActivationChangeObserver:: |
| 139 ActivationReason::WINDOW_DISPOSITION_CHANGED, | 139 ActivationReason::WINDOW_DISPOSITION_CHANGED, |
| 140 next_active, nullptr); | 140 next_active, nullptr); |
| 141 } | 141 } |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 RemoveActiveWindow(window); | 145 RemoveActiveWindow(window); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 158 for (unsigned int i = 0; i < active_windows_.size(); ++i) { | 158 for (unsigned int i = 0; i < active_windows_.size(); ++i) { |
| 159 if (active_windows_[i] == window) { | 159 if (active_windows_[i] == window) { |
| 160 active_windows_.erase(active_windows_.begin() + i); | 160 active_windows_.erase(active_windows_.begin() + i); |
| 161 window->RemoveObserver(this); | 161 window->RemoveObserver(this); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace wm | 167 } // namespace wm |
| OLD | NEW |