Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: components/mus/ws/window_tree_host_impl.cc

Issue 1459463004: mus: Allow the WM to specify the windows that can have active children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/mus/ws/window_tree_host_impl.h" 5 #include "components/mus/ws/window_tree_host_impl.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/mus/common/types.h" 8 #include "components/mus/common/types.h"
9 #include "components/mus/ws/connection_manager.h" 9 #include "components/mus/ws/connection_manager.h"
10 #include "components/mus/ws/display_manager.h" 10 #include "components/mus/ws/display_manager.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return display_manager_->GetViewportMetrics(); 83 return display_manager_->GetViewportMetrics();
84 } 84 }
85 85
86 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { 86 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) {
87 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); 87 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow();
88 if (old_focused_window == new_focused_window) 88 if (old_focused_window == new_focused_window)
89 return; 89 return;
90 DCHECK(root_window()->Contains(new_focused_window)); 90 DCHECK(root_window()->Contains(new_focused_window));
91 focus_controller_->SetFocusedWindow(new_focused_window); 91 focus_controller_->SetFocusedWindow(new_focused_window);
92 // TODO(beng): have the FocusController notify us via FocusControllerDelegate. 92 // TODO(beng): have the FocusController notify us via FocusControllerDelegate.
93 // It is possible that FocusController set the focus to a different window. So
94 // take that into account before calling into OnFocusChanged().
95 new_focused_window = focus_controller_->GetFocusedWindow();
96 if (new_focused_window == old_focused_window)
97 return;
93 OnFocusChanged(old_focused_window, new_focused_window); 98 OnFocusChanged(old_focused_window, new_focused_window);
94 } 99 }
95 100
96 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { 101 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() {
97 return focus_controller_->GetFocusedWindow(); 102 return focus_controller_->GetFocusedWindow();
98 } 103 }
99 104
100 void WindowTreeHostImpl::DestroyFocusController() { 105 void WindowTreeHostImpl::DestroyFocusController() {
101 focus_controller_.reset(); 106 focus_controller_.reset();
102 } 107 }
(...skipping 23 matching lines...) Expand all
126 131
127 void WindowTreeHostImpl::AddAccelerator(uint32_t id, 132 void WindowTreeHostImpl::AddAccelerator(uint32_t id,
128 mojom::EventMatcherPtr event_matcher) { 133 mojom::EventMatcherPtr event_matcher) {
129 event_dispatcher_.AddAccelerator(id, event_matcher.Pass()); 134 event_dispatcher_.AddAccelerator(id, event_matcher.Pass());
130 } 135 }
131 136
132 void WindowTreeHostImpl::RemoveAccelerator(uint32_t id) { 137 void WindowTreeHostImpl::RemoveAccelerator(uint32_t id) {
133 event_dispatcher_.RemoveAccelerator(id); 138 event_dispatcher_.RemoveAccelerator(id);
134 } 139 }
135 140
141 void WindowTreeHostImpl::SetActivationParent(uint32_t window_id, bool enable) {
142 ServerWindow* window =
143 connection_manager_->GetWindow(WindowIdFromTransportId(window_id));
144 bool wm_misbehaving = false;
Ben Goodger (Google) 2015/11/19 07:26:24 what's this for?
sadrul 2015/11/19 19:33:34 I would normally do a DCHECK(window) here, but a m
145 if (window) {
146 if (enable) {
147 auto it = activation_parents_.insert(window->id());
148 if (!it.second)
149 wm_misbehaving = true;
150 } else {
151 size_t count = activation_parents_.erase(window->id());
152 if (!count)
153 wm_misbehaving = true;
154 }
155 } else {
156 wm_misbehaving = true;
157 }
158
159 if (wm_misbehaving) {
160 // TODO: kill the WM?
161 NOTREACHED();
162 }
163 }
164
136 void WindowTreeHostImpl::OnClientClosed() { 165 void WindowTreeHostImpl::OnClientClosed() {
137 // |display_manager_.reset()| destroys the display-manager first, and then 166 // |display_manager_.reset()| destroys the display-manager first, and then
138 // sets |display_manager_| to nullptr. However, destroying |display_manager_| 167 // sets |display_manager_| to nullptr. However, destroying |display_manager_|
139 // can destroy the corresponding WindowTreeHostConnection, and |this|. So 168 // can destroy the corresponding WindowTreeHostConnection, and |this|. So
140 // setting it to nullptr afterwards in reset() ends up writing on free'd 169 // setting it to nullptr afterwards in reset() ends up writing on free'd
141 // memory. So transfer over to a local scoped_ptr<> before destroying it. 170 // memory. So transfer over to a local scoped_ptr<> before destroying it.
142 scoped_ptr<DisplayManager> temp = display_manager_.Pass(); 171 scoped_ptr<DisplayManager> temp = display_manager_.Pass();
143 } 172 }
144 173
145 ServerWindow* WindowTreeHostImpl::GetRootWindow() { 174 ServerWindow* WindowTreeHostImpl::GetRootWindow() {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 207
179 void WindowTreeHostImpl::OnCompositorFrameDrawn() { 208 void WindowTreeHostImpl::OnCompositorFrameDrawn() {
180 std::set<ServerWindow*> windows; 209 std::set<ServerWindow*> windows;
181 windows.swap(windows_needing_frame_destruction_); 210 windows.swap(windows_needing_frame_destruction_);
182 for (ServerWindow* window : windows) { 211 for (ServerWindow* window : windows) {
183 window->RemoveObserver(this); 212 window->RemoveObserver(this);
184 window->DestroySurfacesScheduledForDestruction(); 213 window->DestroySurfacesScheduledForDestruction();
185 } 214 }
186 } 215 }
187 216
217 bool WindowTreeHostImpl::CanHaveActiveChildren(ServerWindow* window) const {
218 return window && activation_parents_.count(window->id()) > 0;
219 }
220
221 void WindowTreeHostImpl::OnActivationChanged(ServerWindow* old_active_window,
222 ServerWindow* new_active_window) {
223 DCHECK_NE(new_active_window, old_active_window);
224 if (new_active_window && new_active_window->parent()) {
225 // Raise the new active window.
226 // TODO(sad): Let the WM dictate whether to raise the window or not?
227 new_active_window->parent()->StackChildAtTop(new_active_window);
Ben Goodger (Google) 2015/11/19 07:26:25 does this account for transients?
sadrul 2015/11/19 19:33:34 StackChildAtTop() etc. account for transients, yep
228 }
229 }
230
188 void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window, 231 void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window,
189 ServerWindow* new_focused_window) { 232 ServerWindow* new_focused_window) {
190 // There are up to four connections that need to be notified: 233 // There are up to four connections that need to be notified:
191 // . the connection containing |old_focused_window|. 234 // . the connection containing |old_focused_window|.
192 // . the connection with |old_focused_window| as its root. 235 // . the connection with |old_focused_window| as its root.
193 // . the connection containing |new_focused_window|. 236 // . the connection containing |new_focused_window|.
194 // . the connection with |new_focused_window| as its root. 237 // . the connection with |new_focused_window| as its root.
195 // Some of these connections may be the same. The following takes care to 238 // Some of these connections may be the same. The following takes care to
196 // notify each only once. 239 // notify each only once.
197 WindowTreeImpl* owning_connection_old = nullptr; 240 WindowTreeImpl* owning_connection_old = nullptr;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 base::Bind(&base::DoNothing)); 323 base::Bind(&base::DoNothing));
281 } 324 }
282 325
283 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { 326 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) {
284 windows_needing_frame_destruction_.erase(window); 327 windows_needing_frame_destruction_.erase(window);
285 window->RemoveObserver(this); 328 window->RemoveObserver(this);
286 } 329 }
287 330
288 } // namespace ws 331 } // namespace ws
289 } // namespace mus 332 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698