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

Unified Diff: ui/aura/mus/focus_synchronizer.cc

Issue 2843193002: chromeos: fix focus for mushrome (Closed)
Patch Set: feedback Created 3 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 | « ui/aura/mus/focus_synchronizer.h ('k') | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/focus_synchronizer.cc
diff --git a/ui/aura/mus/focus_synchronizer.cc b/ui/aura/mus/focus_synchronizer.cc
index 1e1e408ad5b9362f1270bf91b3ee1774a8e20fc9..cc24e7e7adf47b3245e79168f3e97a32e3da2f41 100644
--- a/ui/aura/mus/focus_synchronizer.cc
+++ b/ui/aura/mus/focus_synchronizer.cc
@@ -42,7 +42,9 @@ void FocusSynchronizer::SetFocusFromServer(WindowMus* window) {
Window* root = window->GetWindow()->GetRootWindow();
// The client should provide a focus client for all roots.
DCHECK(client::GetFocusClient(root));
- if (active_focus_client_root_ != root)
+ if (is_singleton_focus_client_)
+ DCHECK_EQ(active_focus_client_, client::GetFocusClient(root));
+ else if (active_focus_client_root_ != root)
SetActiveFocusClient(client::GetFocusClient(root), root);
window->GetWindow()->Focus();
} else if (active_focus_client_) {
@@ -54,19 +56,31 @@ void FocusSynchronizer::OnFocusedWindowDestroyed() {
focused_window_ = nullptr;
}
+void FocusSynchronizer::SetSingletonFocusClient(
+ client::FocusClient* focus_client) {
+ SetActiveFocusClient(focus_client, nullptr);
+ if (focus_client)
+ is_singleton_focus_client_ = true;
+}
+
void FocusSynchronizer::SetActiveFocusClient(client::FocusClient* focus_client,
Window* focus_client_root) {
- if (focus_client_root == active_focus_client_root_) {
- DCHECK_EQ(focus_client, active_focus_client_);
+ if (focus_client == active_focus_client_ &&
+ focus_client_root == active_focus_client_root_) {
return;
}
+ is_singleton_focus_client_ = false;
+
if (active_focus_client_root_)
active_focus_client_root_->RemoveObserver(this);
active_focus_client_root_ = focus_client_root;
if (active_focus_client_root_)
active_focus_client_root_->AddObserver(this);
+ if (focus_client == active_focus_client_)
+ return;
+
OnActiveFocusClientChanged(focus_client, focus_client_root);
for (FocusSynchronizerObserver& observer : observers_)
observer.OnActiveFocusClientChanged(focus_client, focus_client_root);
@@ -118,12 +132,14 @@ void FocusSynchronizer::OnWindowFocused(Window* gained_focus,
}
void FocusSynchronizer::OnWindowDestroying(Window* window) {
+ DCHECK(!is_singleton_focus_client_);
SetActiveFocusClient(nullptr, nullptr);
}
void FocusSynchronizer::OnWindowPropertyChanged(Window* window,
const void* key,
intptr_t old) {
+ DCHECK(!is_singleton_focus_client_);
if (key != client::kFocusClientKey)
return;
« no previous file with comments | « ui/aura/mus/focus_synchronizer.h ('k') | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698