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

Unified Diff: components/mus/ws/window_tree.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.cc ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « components/mus/ws/window_server.cc ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698