| Index: components/mus/ws/window_tree.cc
|
| diff --git a/components/mus/ws/window_tree.cc b/components/mus/ws/window_tree.cc
|
| index 5cde328fe6cc7a3793d47f0df42bb3671912d158..b582d854055131119d0bebafb2dbbce48f170933 100644
|
| --- a/components/mus/ws/window_tree.cc
|
| +++ b/components/mus/ws/window_tree.cc
|
| @@ -269,15 +269,16 @@ bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id,
|
|
|
| bool WindowTree::SetFocus(const ClientWindowId& window_id) {
|
| ServerWindow* window = GetWindowByClientId(window_id);
|
| - // TODO(beng): consider shifting non-policy drawn check logic to VTH's
|
| - // FocusController.
|
| - // TODO(sky): this doesn't work to clear focus. That is because if window is
|
| - // null, then |host| is null and we fail.
|
| + ServerWindow* currently_focused = window_server_->GetFocusedWindow();
|
| + if (!currently_focused && !window)
|
| + return false;
|
| +
|
| Display* display = GetDisplay(window);
|
| - if (!window || !display || !window->IsDrawn() || !window->can_focus() ||
|
| - !access_policy_->CanSetFocus(window)) {
|
| + if (window && (!display || !window->can_focus() || !window->IsDrawn()))
|
| + return false;
|
| +
|
| + if (!access_policy_->CanSetFocus(window))
|
| return false;
|
| - }
|
|
|
| Operation op(this, window_server_, OperationType::SET_FOCUS);
|
| window_server_->SetFocusedWindow(window);
|
| @@ -673,8 +674,9 @@ ClientWindowId WindowTree::ClientWindowIdForWindow(
|
| }
|
|
|
| bool WindowTree::IsValidIdForNewWindow(const ClientWindowId& id) const {
|
| + // Reserve 0 to indicate a null window.
|
| return client_id_to_window_id_map_.count(id) == 0u &&
|
| - access_policy_->IsValidIdForNewWindow(id);
|
| + access_policy_->IsValidIdForNewWindow(id) && id != ClientWindowId();
|
| }
|
|
|
| WindowId WindowTree::GenerateNewWindowId() {
|
|
|