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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/window_server.cc
diff --git a/components/mus/ws/window_server.cc b/components/mus/ws/window_server.cc
index fdef43cf53095c4c78cdf741325be0bfd20f0e42..14e2c9af87eedefd77ecc5e1c31456d03acc98e7 100644
--- a/components/mus/ws/window_server.cc
+++ b/components/mus/ws/window_server.cc
@@ -240,12 +240,15 @@ void WindowServer::OnFirstWindowManagerFactorySet() {
void WindowServer::SetFocusedWindow(ServerWindow* window) {
// TODO(sky): this should fail if there is modal dialog active and |window|
// is outside that.
- Display* focused_display = nullptr;
- for (Display* display : display_manager_->displays()) {
- if (display->GetFocusedWindow()) {
- focused_display = display;
- break;
- }
+ ServerWindow* currently_focused = GetFocusedWindow();
+ Display* focused_display =
+ currently_focused
+ ? display_manager_->GetDisplayContaining(currently_focused)
+ : nullptr;
+ if (!window) {
+ if (focused_display)
+ focused_display->SetFocusedWindow(nullptr);
+ return;
}
Display* display = display_manager_->GetDisplayContaining(window);
DCHECK(display); // It's assumed callers do validation before calling this.
@@ -259,6 +262,15 @@ void WindowServer::SetFocusedWindow(ServerWindow* window) {
}
}
+ServerWindow* WindowServer::GetFocusedWindow() {
+ for (Display* display : display_manager_->displays()) {
+ ServerWindow* focused_window = display->GetFocusedWindow();
+ if (focused_window)
+ return focused_window;
+ }
+ return nullptr;
+}
+
uint32_t WindowServer::GenerateWindowManagerChangeId(
WindowTree* source,
uint32_t client_change_id) {
« 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