| Index: ui/views/widget/native_widget_aura.cc
|
| ===================================================================
|
| --- ui/views/widget/native_widget_aura.cc (revision 113647)
|
| +++ ui/views/widget/native_widget_aura.cc (working copy)
|
| @@ -6,6 +6,7 @@
|
|
|
| #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"
|
| @@ -60,24 +61,31 @@
|
| }
|
| }
|
|
|
| +aura::ActivationClient* GetActivationClient() {
|
| + return reinterpret_cast<aura::ActivationClient*>(
|
| + aura::RootWindow::GetInstance()->GetProperty(
|
| + aura::kRootWindowActivationClient));
|
| +}
|
| } // namespace
|
|
|
| // 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::RootWindowObserverImpl : public aura::WindowObserver {
|
| public:
|
| - explicit RootWindowObserverImpl(NativeWidgetAura* host)
|
| - : host_(host) {
|
| + explicit RootWindowObserverImpl(NativeWidgetAura* host) : host_(host) {
|
| aura::RootWindow::GetInstance()->AddObserver(this);
|
| }
|
| -
|
| virtual ~RootWindowObserverImpl() {
|
| 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 = GetActivationClient()->GetActiveWindow();
|
| if (!active || (active != host_->window_ &&
|
| active->transient_parent() != host_->window_)) {
|
| host_->delegate_->EnableInactiveRendering();
|
| @@ -169,6 +177,9 @@
|
| static_cast<aura::WindowDragDropDelegate*>(this));
|
| }
|
|
|
| + window_->SetProperty(aura::kActivationDelegateKey,
|
| + static_cast<aura::ActivationDelegate*>(this));
|
| +
|
| if (window_type == Widget::InitParams::TYPE_MENU ||
|
| window_type == Widget::InitParams::TYPE_TOOLTIP)
|
| window_->SetIntProperty(aura::kShadowTypeKey,
|
| @@ -413,7 +424,7 @@
|
| window_->Show();
|
| if (can_activate_ && (state != ui::SHOW_STATE_INACTIVE ||
|
| !GetWidget()->SetInitialFocus())) {
|
| - window_->Activate();
|
| + Activate();
|
| }
|
| }
|
|
|
| @@ -422,15 +433,15 @@
|
| }
|
|
|
| void NativeWidgetAura::Activate() {
|
| - window_->Activate();
|
| + GetActivationClient()->ActivateWindow(window_);
|
| }
|
|
|
| void NativeWidgetAura::Deactivate() {
|
| - window_->Deactivate();
|
| + GetActivationClient()->DeactivateWindow(window_);
|
| }
|
|
|
| bool NativeWidgetAura::IsActive() const {
|
| - return aura::RootWindow::GetInstance()->active_window() == window_;
|
| + return GetActivationClient()->GetActiveWindow() == window_;
|
| }
|
|
|
| void NativeWidgetAura::SetAlwaysOnTop(bool on_top) {
|
| @@ -617,22 +628,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();
|
| }
|
| @@ -661,6 +656,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(),
|
|
|