| Index: ui/views/widget/native_widget_aura.cc
|
| ===================================================================
|
| --- ui/views/widget/native_widget_aura.cc (revision 114022)
|
| +++ ui/views/widget/native_widget_aura.cc (working copy)
|
| @@ -6,13 +6,14 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/string_util.h"
|
| +#include "ui/aura/client/activation_client.h"
|
| #include "ui/aura/client/aura_constants.h"
|
| #include "ui/aura/client/drag_drop_client.h"
|
| #include "ui/aura/client/shadow_types.h"
|
| #include "ui/aura/event.h"
|
| #include "ui/aura/root_window.h"
|
| -#include "ui/aura/root_window_observer.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/aura/window_observer.h"
|
| #include "ui/aura/window_types.h"
|
| #include "ui/base/dragdrop/os_exchange_data.h"
|
| #include "ui/base/ui_base_types.h"
|
| @@ -76,20 +77,23 @@
|
|
|
| // Used when SetInactiveRenderingDisabled() is invoked to track when active
|
| // status changes in such a way that we should enable inactive rendering.
|
| -class NativeWidgetAura::RootWindowObserverImpl
|
| - : public aura::RootWindowObserver {
|
| +class NativeWidgetAura::ActiveWindowObserver : public aura::WindowObserver {
|
| public:
|
| - explicit RootWindowObserverImpl(NativeWidgetAura* host)
|
| - : host_(host) {
|
| + explicit ActiveWindowObserver(NativeWidgetAura* host) : host_(host) {
|
| aura::RootWindow::GetInstance()->AddObserver(this);
|
| }
|
| -
|
| - virtual ~RootWindowObserverImpl() {
|
| + virtual ~ActiveWindowObserver() {
|
| aura::RootWindow::GetInstance()->RemoveObserver(this);
|
| }
|
|
|
| - // RootWindowObserver overrides:
|
| - virtual void OnActiveWindowChanged(aura::Window* active) OVERRIDE {
|
| + // Overridden from aura::WindowObserver:
|
| + virtual void OnWindowPropertyChanged(aura::Window* window,
|
| + const char* key,
|
| + void* old) OVERRIDE {
|
| + if (key != aura::kRootWindowActiveWindow)
|
| + return;
|
| + aura::Window* active =
|
| + aura::ActivationClient::GetActivationClient()->GetActiveWindow();
|
| if (!active || (active != host_->window_ &&
|
| active->transient_parent() != host_->window_)) {
|
| host_->delegate_->EnableInactiveRendering();
|
| @@ -99,7 +103,7 @@
|
| private:
|
| NativeWidgetAura* host_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(RootWindowObserverImpl);
|
| + DISALLOW_COPY_AND_ASSIGN(ActiveWindowObserver);
|
| };
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -181,6 +185,8 @@
|
| static_cast<aura::WindowDragDropDelegate*>(this));
|
| }
|
|
|
| + aura::ActivationDelegate::SetActivationDelegate(window_, this);
|
| +
|
| if (window_type == Widget::InitParams::TYPE_MENU ||
|
| window_type == Widget::InitParams::TYPE_TOOLTIP)
|
| window_->SetIntProperty(aura::kShadowTypeKey,
|
| @@ -425,7 +431,7 @@
|
| window_->Show();
|
| if (can_activate_ && (state != ui::SHOW_STATE_INACTIVE ||
|
| !GetWidget()->SetInitialFocus())) {
|
| - window_->Activate();
|
| + Activate();
|
| }
|
| }
|
|
|
| @@ -434,15 +440,16 @@
|
| }
|
|
|
| void NativeWidgetAura::Activate() {
|
| - window_->Activate();
|
| + aura::ActivationClient::GetActivationClient()->ActivateWindow(window_);
|
| }
|
|
|
| void NativeWidgetAura::Deactivate() {
|
| - window_->Deactivate();
|
| + aura::ActivationClient::GetActivationClient()->DeactivateWindow(window_);
|
| }
|
|
|
| bool NativeWidgetAura::IsActive() const {
|
| - return aura::RootWindow::GetInstance()->active_window() == window_;
|
| + return aura::ActivationClient::GetActivationClient()->GetActiveWindow() ==
|
| + window_;
|
| }
|
|
|
| void NativeWidgetAura::SetAlwaysOnTop(bool on_top) {
|
| @@ -532,9 +539,9 @@
|
|
|
| void NativeWidgetAura::SetInactiveRenderingDisabled(bool value) {
|
| if (!value)
|
| - root_window_observer_.reset();
|
| + active_window_observer_.reset();
|
| else
|
| - root_window_observer_.reset(new RootWindowObserverImpl(this));
|
| + active_window_observer_.reset(new ActiveWindowObserver(this));
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -629,22 +636,6 @@
|
| return true;
|
| }
|
|
|
| -bool NativeWidgetAura::ShouldActivate(aura::Event* event) {
|
| - return can_activate_;
|
| -}
|
| -
|
| -void NativeWidgetAura::OnActivated() {
|
| - delegate_->OnNativeWidgetActivationChanged(true);
|
| - if (IsVisible() && GetWidget()->non_client_view())
|
| - GetWidget()->non_client_view()->SchedulePaint();
|
| -}
|
| -
|
| -void NativeWidgetAura::OnLostActive() {
|
| - delegate_->OnNativeWidgetActivationChanged(false);
|
| - if (IsVisible() && GetWidget()->non_client_view())
|
| - GetWidget()->non_client_view()->SchedulePaint();
|
| -}
|
| -
|
| void NativeWidgetAura::OnCaptureLost() {
|
| delegate_->OnMouseCaptureLost();
|
| }
|
| @@ -673,6 +664,28 @@
|
| delegate_->OnNativeWidgetVisibilityChanged(visible);
|
| }
|
|
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// NativeWidgetAura, aura::ActivationDelegate implementation:
|
| +
|
| +bool NativeWidgetAura::ShouldActivate(aura::Event* event) {
|
| + return can_activate_;
|
| +}
|
| +
|
| +void NativeWidgetAura::OnActivated() {
|
| + delegate_->OnNativeWidgetActivationChanged(true);
|
| + if (IsVisible() && GetWidget()->non_client_view())
|
| + GetWidget()->non_client_view()->SchedulePaint();
|
| +}
|
| +
|
| +void NativeWidgetAura::OnLostActive() {
|
| + delegate_->OnNativeWidgetActivationChanged(false);
|
| + if (IsVisible() && GetWidget()->non_client_view())
|
| + GetWidget()->non_client_view()->SchedulePaint();
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// NativeWidgetAura, aura::WindowDragDropDelegate implementation:
|
| +
|
| void NativeWidgetAura::OnDragEntered(const aura::DropTargetEvent& event) {
|
| DCHECK(drop_helper_.get() != NULL);
|
| drop_helper_->OnDragOver(event.data(), event.location(),
|
|
|