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

Unified Diff: ui/views/mus/desktop_window_tree_host_mus.cc

Issue 2714763002: Change FocusSynchronizer to maintain active focus client and window. (Closed)
Patch Set: fix crash in aura_test_helper tear down Created 3 years, 9 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/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/mus/desktop_window_tree_host_mus_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/desktop_window_tree_host_mus.cc
diff --git a/ui/views/mus/desktop_window_tree_host_mus.cc b/ui/views/mus/desktop_window_tree_host_mus.cc
index 6efc8ffb2e1642b1ae3a9ce73c8e1705061c076f..4b4a98b9bfaca456218c7d4c2c9d7f5fd8ccf47b 100644
--- a/ui/views/mus/desktop_window_tree_host_mus.cc
+++ b/ui/views/mus/desktop_window_tree_host_mus.cc
@@ -14,8 +14,9 @@
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/transient_window_client.h"
-#include "ui/aura/env.h"
+#include "ui/aura/mus/focus_synchronizer.h"
#include "ui/aura/mus/window_port_mus.h"
+#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/mus/window_tree_host_mus.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
@@ -191,8 +192,9 @@ DesktopWindowTreeHostMus::DesktopWindowTreeHostMus(
native_widget_delegate_(native_widget_delegate),
desktop_native_widget_aura_(desktop_native_widget_aura),
close_widget_factory_(this) {
- aura::Env::GetInstance()->AddObserver(this);
MusClient::Get()->AddObserver(this);
+ MusClient::Get()->window_tree_client()->focus_synchronizer()->AddObserver(
+ this);
native_widget_delegate_->AsWidget()->AddObserver(this);
desktop_native_widget_aura_->content_window()->AddObserver(this);
// DesktopNativeWidgetAura registers the association between |content_window_|
@@ -212,7 +214,8 @@ DesktopWindowTreeHostMus::~DesktopWindowTreeHostMus() {
desktop_native_widget_aura_->content_window()->RemoveObserver(this);
native_widget_delegate_->AsWidget()->RemoveObserver(this);
MusClient::Get()->RemoveObserver(this);
- aura::Env::GetInstance()->RemoveObserver(this);
+ MusClient::Get()->window_tree_client()->focus_synchronizer()->RemoveObserver(
+ this);
desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this);
}
@@ -369,6 +372,10 @@ void DesktopWindowTreeHostMus::Close() {
void DesktopWindowTreeHostMus::CloseNow() {
MusClient::Get()->OnCaptureClientUnset(
aura::client::GetCaptureClient(window()));
+ MusClient::Get()
+ ->window_tree_client()
+ ->focus_synchronizer()
+ ->DetachFromFocusClient(aura::client::GetFocusClient(window()));
native_widget_delegate_->OnNativeWidgetDestroying();
@@ -549,8 +556,10 @@ void DesktopWindowTreeHostMus::Activate() {
// This should result in OnActiveFocusClientChanged() being called, which
// triggers a call to DesktopNativeWidgetAura::HandleActivationChanged(),
// which focuses the right window.
- aura::Env::GetInstance()->SetActiveFocusClient(
- aura::client::GetFocusClient(window()), window());
+ MusClient::Get()
+ ->window_tree_client()
+ ->focus_synchronizer()
+ ->AttachToFocusClient(aura::client::GetFocusClient(window()), window());
if (is_active_)
window()->SetProperty(aura::client::kDrawAttentionKey, false);
}
@@ -755,6 +764,16 @@ void DesktopWindowTreeHostMus::OnWidgetActivationChanged(Widget* widget,
is_active_ = active;
}
+void DesktopWindowTreeHostMus::OnActiveFocusClientChanged(
+ aura::client::FocusClient* focus_client,
+ aura::Window* window) {
+ if (window == this->window()) {
sadrul 2017/03/09 02:01:23 Could it not do this by just being a FocusChangeOb
+ desktop_native_widget_aura_->HandleActivationChanged(true);
+ } else if (is_active_) {
+ desktop_native_widget_aura_->HandleActivationChanged(false);
+ }
+}
+
void DesktopWindowTreeHostMus::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
@@ -807,16 +826,4 @@ void DesktopWindowTreeHostMus::SetBoundsInPixels(
}
}
-void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {}
-
-void DesktopWindowTreeHostMus::OnActiveFocusClientChanged(
- aura::client::FocusClient* focus_client,
- aura::Window* window) {
- if (window == this->window()) {
- desktop_native_widget_aura_->HandleActivationChanged(true);
- } else if (is_active_) {
- desktop_native_widget_aura_->HandleActivationChanged(false);
- }
-}
-
} // namespace views
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/mus/desktop_window_tree_host_mus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698