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 "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/wm/public/activation_change_observer.h" | 8 #include "ui/wm/public/activation_change_observer.h" |
9 #include "ui/wm/public/activation_delegate.h" | 9 #include "ui/wm/public/activation_delegate.h" |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 aura::client::ActivationChangeObserver* observer) { | 52 aura::client::ActivationChangeObserver* observer) { |
53 observers_.AddObserver(observer); | 53 observers_.AddObserver(observer); |
54 } | 54 } |
55 | 55 |
56 void DefaultActivationClient::RemoveObserver( | 56 void DefaultActivationClient::RemoveObserver( |
57 aura::client::ActivationChangeObserver* observer) { | 57 aura::client::ActivationChangeObserver* observer) { |
58 observers_.RemoveObserver(observer); | 58 observers_.RemoveObserver(observer); |
59 } | 59 } |
60 | 60 |
61 void DefaultActivationClient::ActivateWindow(aura::Window* window) { | 61 void DefaultActivationClient::ActivateWindow(aura::Window* window) { |
62 ActivateWindowImpl(aura::client::ActivationChangeObserver::ActivationReason:: | |
63 ACTIVATION_CLIENT, | |
64 window); | |
65 } | |
66 | |
67 void DefaultActivationClient::ActivateWindowImpl( | |
68 aura::client::ActivationChangeObserver::ActivationReason reason, | |
69 aura::Window* window) { | |
62 aura::Window* last_active = GetActiveWindow(); | 70 aura::Window* last_active = GetActiveWindow(); |
63 if (last_active == window) | 71 if (last_active == window) |
64 return; | 72 return; |
65 | 73 |
66 last_active_ = last_active; | 74 last_active_ = last_active; |
67 RemoveActiveWindow(window); | 75 RemoveActiveWindow(window); |
68 active_windows_.push_back(window); | 76 active_windows_.push_back(window); |
69 window->parent()->StackChildAtTop(window); | 77 window->parent()->StackChildAtTop(window); |
70 window->AddObserver(this); | 78 window->AddObserver(this); |
71 | 79 |
72 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, | 80 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, observers_, |
73 observers_, | 81 OnWindowActivated(reason, window, last_active)); |
74 OnWindowActivated(window, last_active)); | |
75 | 82 |
76 aura::client::ActivationChangeObserver* observer = | 83 aura::client::ActivationChangeObserver* observer = |
77 aura::client::GetActivationChangeObserver(last_active); | 84 aura::client::GetActivationChangeObserver(last_active); |
78 if (observer) | 85 if (observer) { |
79 observer->OnWindowActivated(window, last_active); | 86 observer->OnWindowActivated(reason, window, last_active); |
87 } | |
80 observer = aura::client::GetActivationChangeObserver(window); | 88 observer = aura::client::GetActivationChangeObserver(window); |
81 if (observer) | 89 if (observer) { |
82 observer->OnWindowActivated(window, last_active); | 90 observer->OnWindowActivated(reason, window, last_active); |
91 } | |
83 } | 92 } |
84 | 93 |
85 void DefaultActivationClient::DeactivateWindow(aura::Window* window) { | 94 void DefaultActivationClient::DeactivateWindow(aura::Window* window) { |
86 aura::client::ActivationChangeObserver* observer = | 95 aura::client::ActivationChangeObserver* observer = |
87 aura::client::GetActivationChangeObserver(window); | 96 aura::client::GetActivationChangeObserver(window); |
88 if (observer) | 97 if (observer) { |
89 observer->OnWindowActivated(NULL, window); | 98 observer->OnWindowActivated(aura::client::ActivationChangeObserver:: |
99 ActivationReason::ACTIVATION_CLIENT, | |
100 NULL, window); | |
sky
2015/06/04 20:02:03
nullptr
bruthig
2015/06/04 21:07:41
Done.
| |
101 } | |
90 if (last_active_) | 102 if (last_active_) |
91 ActivateWindow(last_active_); | 103 ActivateWindow(last_active_); |
92 } | 104 } |
93 | 105 |
94 aura::Window* DefaultActivationClient::GetActiveWindow() { | 106 aura::Window* DefaultActivationClient::GetActiveWindow() { |
95 if (active_windows_.empty()) | 107 if (active_windows_.empty()) |
96 return NULL; | 108 return NULL; |
97 return active_windows_.back(); | 109 return active_windows_.back(); |
98 } | 110 } |
99 | 111 |
(...skipping 14 matching lines...) Expand all Loading... | |
114 // DefaultActivationClient, aura::WindowObserver implementation: | 126 // DefaultActivationClient, aura::WindowObserver implementation: |
115 | 127 |
116 void DefaultActivationClient::OnWindowDestroyed(aura::Window* window) { | 128 void DefaultActivationClient::OnWindowDestroyed(aura::Window* window) { |
117 if (window == last_active_) | 129 if (window == last_active_) |
118 last_active_ = NULL; | 130 last_active_ = NULL; |
119 | 131 |
120 if (window == GetActiveWindow()) { | 132 if (window == GetActiveWindow()) { |
121 active_windows_.pop_back(); | 133 active_windows_.pop_back(); |
122 aura::Window* next_active = GetActiveWindow(); | 134 aura::Window* next_active = GetActiveWindow(); |
123 if (next_active && aura::client::GetActivationChangeObserver(next_active)) { | 135 if (next_active && aura::client::GetActivationChangeObserver(next_active)) { |
124 aura::client::GetActivationChangeObserver(next_active)->OnWindowActivated( | 136 aura::client::GetActivationChangeObserver(next_active) |
125 next_active, NULL); | 137 ->OnWindowActivated(aura::client::ActivationChangeObserver:: |
138 ActivationReason::WINDOW_DISPOSITION_CHANGED, | |
139 next_active, NULL); | |
sky
2015/06/04 20:02:03
nullptr
bruthig
2015/06/04 21:07:41
Done.
| |
126 } | 140 } |
127 return; | 141 return; |
128 } | 142 } |
129 | 143 |
130 RemoveActiveWindow(window); | 144 RemoveActiveWindow(window); |
131 } | 145 } |
132 | 146 |
133 //////////////////////////////////////////////////////////////////////////////// | 147 //////////////////////////////////////////////////////////////////////////////// |
134 // DefaultActivationClient, private: | 148 // DefaultActivationClient, private: |
135 | 149 |
136 DefaultActivationClient::~DefaultActivationClient() { | 150 DefaultActivationClient::~DefaultActivationClient() { |
137 for (unsigned int i = 0; i < active_windows_.size(); ++i) { | 151 for (unsigned int i = 0; i < active_windows_.size(); ++i) { |
138 active_windows_[i]->RemoveObserver(this); | 152 active_windows_[i]->RemoveObserver(this); |
139 } | 153 } |
140 } | 154 } |
141 | 155 |
142 void DefaultActivationClient::RemoveActiveWindow(aura::Window* window) { | 156 void DefaultActivationClient::RemoveActiveWindow(aura::Window* window) { |
143 for (unsigned int i = 0; i < active_windows_.size(); ++i) { | 157 for (unsigned int i = 0; i < active_windows_.size(); ++i) { |
144 if (active_windows_[i] == window) { | 158 if (active_windows_[i] == window) { |
145 active_windows_.erase(active_windows_.begin() + i); | 159 active_windows_.erase(active_windows_.begin() + i); |
146 window->RemoveObserver(this); | 160 window->RemoveObserver(this); |
147 return; | 161 return; |
148 } | 162 } |
149 } | 163 } |
150 } | 164 } |
151 | 165 |
152 } // namespace wm | 166 } // namespace wm |
OLD | NEW |