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

Unified Diff: components/mus/ws/window_server.cc

Issue 1868783003: Makes SetFocus() notify callback correctly on failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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.h » ('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 14e2c9af87eedefd77ecc5e1c31456d03acc98e7..c5195aa31345c48b6578dc98c9f71ab4830d35c9 100644
--- a/components/mus/ws/window_server.cc
+++ b/components/mus/ws/window_server.cc
@@ -237,7 +237,7 @@ void WindowServer::OnFirstWindowManagerFactorySet() {
delegate_->CreateDefaultDisplays();
}
-void WindowServer::SetFocusedWindow(ServerWindow* window) {
+bool WindowServer::SetFocusedWindow(ServerWindow* window) {
// TODO(sky): this should fail if there is modal dialog active and |window|
// is outside that.
ServerWindow* currently_focused = GetFocusedWindow();
@@ -245,21 +245,21 @@ void WindowServer::SetFocusedWindow(ServerWindow* window) {
currently_focused
? display_manager_->GetDisplayContaining(currently_focused)
: nullptr;
- if (!window) {
- if (focused_display)
- focused_display->SetFocusedWindow(nullptr);
- return;
- }
+ if (!window)
+ return focused_display ? focused_display->SetFocusedWindow(nullptr) : true;
+
Display* display = display_manager_->GetDisplayContaining(window);
DCHECK(display); // It's assumed callers do validation before calling this.
- display->SetFocusedWindow(window);
+ const bool result = display->SetFocusedWindow(window);
// If the focus actually changed, and focus was in another display, then we
// need to notify the previously focused display so that it cleans up state
// and notifies appropriately.
- if (window && display->GetFocusedWindow() && display != focused_display &&
+ if (result && display->GetFocusedWindow() && display != focused_display &&
focused_display) {
- focused_display->SetFocusedWindow(nullptr);
+ const bool cleared_focus = focused_display->SetFocusedWindow(nullptr);
+ DCHECK(cleared_focus);
}
+ return result;
}
ServerWindow* WindowServer::GetFocusedWindow() {
« no previous file with comments | « components/mus/ws/window_server.h ('k') | components/mus/ws/window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698