Chromium Code Reviews| 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 |