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

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

Issue 1862853002: Makes WindowTree::SetFocus(null) work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar cleanup Created 4 years, 8 months 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
« no previous file with comments | « components/mus/ws/window_server.h ('k') | components/mus/ws/window_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_server.h" 5 #include "components/mus/ws/window_server.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/mus/ws/display.h" 9 #include "components/mus/ws/display.h"
10 #include "components/mus/ws/display_binding.h" 10 #include "components/mus/ws/display_binding.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 // We've been supplied a WindowManagerFactory and no displays have been 234 // We've been supplied a WindowManagerFactory and no displays have been
235 // created yet. Treat this as a signal to create a Display. 235 // created yet. Treat this as a signal to create a Display.
236 // TODO(sky): we need a better way to determine this, most likely a switch. 236 // TODO(sky): we need a better way to determine this, most likely a switch.
237 delegate_->CreateDefaultDisplays(); 237 delegate_->CreateDefaultDisplays();
238 } 238 }
239 239
240 void WindowServer::SetFocusedWindow(ServerWindow* window) { 240 void WindowServer::SetFocusedWindow(ServerWindow* window) {
241 // TODO(sky): this should fail if there is modal dialog active and |window| 241 // TODO(sky): this should fail if there is modal dialog active and |window|
242 // is outside that. 242 // is outside that.
243 Display* focused_display = nullptr; 243 ServerWindow* currently_focused = GetFocusedWindow();
244 for (Display* display : display_manager_->displays()) { 244 Display* focused_display =
245 if (display->GetFocusedWindow()) { 245 currently_focused
246 focused_display = display; 246 ? display_manager_->GetDisplayContaining(currently_focused)
247 break; 247 : nullptr;
248 } 248 if (!window) {
249 if (focused_display)
250 focused_display->SetFocusedWindow(nullptr);
251 return;
249 } 252 }
250 Display* display = display_manager_->GetDisplayContaining(window); 253 Display* display = display_manager_->GetDisplayContaining(window);
251 DCHECK(display); // It's assumed callers do validation before calling this. 254 DCHECK(display); // It's assumed callers do validation before calling this.
252 display->SetFocusedWindow(window); 255 display->SetFocusedWindow(window);
253 // If the focus actually changed, and focus was in another display, then we 256 // If the focus actually changed, and focus was in another display, then we
254 // need to notify the previously focused display so that it cleans up state 257 // need to notify the previously focused display so that it cleans up state
255 // and notifies appropriately. 258 // and notifies appropriately.
256 if (window && display->GetFocusedWindow() && display != focused_display && 259 if (window && display->GetFocusedWindow() && display != focused_display &&
257 focused_display) { 260 focused_display) {
258 focused_display->SetFocusedWindow(nullptr); 261 focused_display->SetFocusedWindow(nullptr);
259 } 262 }
260 } 263 }
261 264
265 ServerWindow* WindowServer::GetFocusedWindow() {
266 for (Display* display : display_manager_->displays()) {
267 ServerWindow* focused_window = display->GetFocusedWindow();
268 if (focused_window)
269 return focused_window;
270 }
271 return nullptr;
272 }
273
262 uint32_t WindowServer::GenerateWindowManagerChangeId( 274 uint32_t WindowServer::GenerateWindowManagerChangeId(
263 WindowTree* source, 275 WindowTree* source,
264 uint32_t client_change_id) { 276 uint32_t client_change_id) {
265 const uint32_t wm_change_id = next_wm_change_id_++; 277 const uint32_t wm_change_id = next_wm_change_id_++;
266 in_flight_wm_change_map_[wm_change_id] = {source->id(), client_change_id}; 278 in_flight_wm_change_map_[wm_change_id] = {source->id(), client_change_id};
267 return wm_change_id; 279 return wm_change_id;
268 } 280 }
269 281
270 void WindowServer::WindowManagerChangeCompleted( 282 void WindowServer::WindowManagerChangeCompleted(
271 uint32_t window_manager_change_id, 283 uint32_t window_manager_change_id,
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 void WindowServer::OnFirstDisplayReady() { 635 void WindowServer::OnFirstDisplayReady() {
624 delegate_->OnFirstDisplayReady(); 636 delegate_->OnFirstDisplayReady();
625 } 637 }
626 638
627 void WindowServer::OnNoMoreDisplays() { 639 void WindowServer::OnNoMoreDisplays() {
628 delegate_->OnNoMoreDisplays(); 640 delegate_->OnNoMoreDisplays();
629 } 641 }
630 642
631 } // namespace ws 643 } // namespace ws
632 } // namespace mus 644 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_server.h ('k') | components/mus/ws/window_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698