diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-12 22:33:07 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-12 22:33:07 +0000 |
commit | a9ea2b5334e49a3f36b2bb2581b90f301747dc77 (patch) | |
tree | 22d64d958abf32ddc75b66224da7c02c6168ce7e /ui/aura/client | |
parent | 2bfa54889d0c31859bf932759ce93652297ab3ec (diff) | |
download | chromium_src-a9ea2b5334e49a3f36b2bb2581b90f301747dc77.zip chromium_src-a9ea2b5334e49a3f36b2bb2581b90f301747dc77.tar.gz chromium_src-a9ea2b5334e49a3f36b2bb2581b90f301747dc77.tar.bz2 |
Revert 114095 - Move the concept of Activation to the Shell.
The Active Window is now stored in a property on the RootWindow. Classes wishing to observe changes to this can implement WindowObserver and attach to the RootWindow to be notified of changes in this property.
We provide an ActivationClient interface in Aura for customers to use to set/get the active window, and deactivate a window. This is because setting the active window involves more than just changing the property, there is some additional book-keeping that must be done. The ActivationClient is stored in a property on the RootWindow.
We also provide an ActivationDelegate interface in Aura that window owners can use to be notified of changes in activation state, and to specify whether or not a window can be activated. The ActivationDelegate should be stored on the relevant window in a property.
I moved a lot of Activation-related functionality out of Aura, including all of the unit tests, now on ActivationController, and the associated WindowDelegate implementations which have now become a single TestActivationDelegate implementation.
BUG=none
TEST=unit tests
Review URL: http://codereview.chromium.org/8894018
TBR=ben@chromium.org
Review URL: http://codereview.chromium.org/8926004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/client')
-rw-r--r-- | ui/aura/client/activation_client.cc | 23 | ||||
-rw-r--r-- | ui/aura/client/activation_client.h | 42 | ||||
-rw-r--r-- | ui/aura/client/activation_delegate.cc | 24 | ||||
-rw-r--r-- | ui/aura/client/activation_delegate.h | 43 | ||||
-rw-r--r-- | ui/aura/client/aura_constants.cc | 15 | ||||
-rw-r--r-- | ui/aura/client/aura_constants.h | 52 | ||||
-rw-r--r-- | ui/aura/client/stacking_client.h | 8 |
7 files changed, 31 insertions, 176 deletions
diff --git a/ui/aura/client/activation_client.cc b/ui/aura/client/activation_client.cc deleted file mode 100644 index 8106ca2..0000000 --- a/ui/aura/client/activation_client.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/aura/client/activation_client.h" - -#include "ui/aura/client/aura_constants.h" -#include "ui/aura/root_window.h" - -namespace aura { - -// static -void ActivationClient::SetActivationClient(ActivationClient* client) { - RootWindow::GetInstance()->SetProperty(kRootWindowActivationClient, client); -} - -// static -ActivationClient* ActivationClient::GetActivationClient() { - return reinterpret_cast<ActivationClient*>( - RootWindow::GetInstance()->GetProperty(kRootWindowActivationClient)); -} - -} // namespace aura diff --git a/ui/aura/client/activation_client.h b/ui/aura/client/activation_client.h deleted file mode 100644 index 547f9ab..0000000 --- a/ui/aura/client/activation_client.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_AURA_CLIENT_ACTIVATION_CLIENT_H_ -#define UI_AURA_CLIENT_ACTIVATION_CLIENT_H_ -#pragma once - -#include "ui/aura/aura_export.h" - -namespace aura { - -class Window; - -// An interface implemented by an object that manages window activation. -class AURA_EXPORT ActivationClient { - public: - // Sets/Gets the activation client on the RootWindow. - static void SetActivationClient(ActivationClient* client); - static ActivationClient* GetActivationClient(); - - // Activates |window|. If |window| is NULL, nothing happens. - virtual void ActivateWindow(Window* window) = 0; - - // Deactivates |window|. What (if anything) is activated next is up to the - // client. If |window| is NULL, nothing happens. - virtual void DeactivateWindow(Window* window) = 0; - - // Retrieves the active window, or NULL if there is none. - virtual aura::Window* GetActiveWindow() = 0; - - // Returns true if |window| can be focused. To be focusable, |window| must - // exist inside an activatable window. - virtual bool CanFocusWindow(Window* window) const = 0; - - protected: - virtual ~ActivationClient() {} -}; - -} // namespace aura - -#endif // UI_AURA_CLIENT_ACTIVATION_CLIENT_H_ diff --git a/ui/aura/client/activation_delegate.cc b/ui/aura/client/activation_delegate.cc deleted file mode 100644 index 18688f0..0000000 --- a/ui/aura/client/activation_delegate.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/aura/client/activation_delegate.h" - -#include "ui/aura/client/aura_constants.h" -#include "ui/aura/window.h" - -namespace aura { - -// static -void ActivationDelegate::SetActivationDelegate(Window* window, - ActivationDelegate* delegate) { - window->SetProperty(kActivationDelegateKey, delegate); -} - -// static -ActivationDelegate* ActivationDelegate::GetActivationDelegate(Window* window) { - return reinterpret_cast<ActivationDelegate*>( - window->GetProperty(kActivationDelegateKey)); -} - -} // namespace aura diff --git a/ui/aura/client/activation_delegate.h b/ui/aura/client/activation_delegate.h deleted file mode 100644 index dd2933e..0000000 --- a/ui/aura/client/activation_delegate.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_AURA_CLIENT_ACTIVATION_DELEGATE_H_ -#define UI_AURA_CLIENT_ACTIVATION_DELEGATE_H_ -#pragma once - -#include "ui/aura/aura_export.h" - -namespace aura { - -class Event; -class Window; - -// An interface implemented by an object that configures and responds to changes -// to a window's activation state. -class AURA_EXPORT ActivationDelegate { - public: - // Sets/Gets the ActivationDelegate on the Window. No ownership changes. - static void SetActivationDelegate(Window* window, - ActivationDelegate* delegate); - static ActivationDelegate* GetActivationDelegate(Window* window); - - // Returns true if the window should be activated. |event| is either the mouse - // event supplied if the activation is the result of a mouse, or the touch - // event if the activation is the result of a touch, or NULL if activation is - // attempted for another reason. - virtual bool ShouldActivate(Event* event) = 0; - - // Sent when the window is activated. - virtual void OnActivated() = 0; - - // Sent when the window loses active status. - virtual void OnLostActive() = 0; - - protected: - virtual ~ActivationDelegate() {} -}; - -} // namespace aura - -#endif // UI_AURA_CLIENT_ACTIVATION_DELEGATE_H_ diff --git a/ui/aura/client/aura_constants.cc b/ui/aura/client/aura_constants.cc index c1d0d6e..9536a1f 100644 --- a/ui/aura/client/aura_constants.cc +++ b/ui/aura/client/aura_constants.cc @@ -6,19 +6,14 @@ namespace aura { -// Alphabetical sort. -const char kActivationDelegateKey[] = "ActivationDelegate"; const char kAlwaysOnTopKey[] = "AlwaysOnTop"; -const char kDragDropDelegateKey[] = "DragDropDelegate"; -const char kModalKey[] = "Modal"; const char kRestoreBoundsKey[] = "RestoreBounds"; -const char kRootWindowDragDropClientKey[] = "RootWindowDragDropClient"; -const char kRootWindowTooltipClientKey[] = "RootWindowTooltipClient"; -const char kRootWindowActiveWindow[] = "RootWindowActiveWindow"; -const char kRootWindowActivationClient[] = "RootWindowActivationClient"; -const char kShadowTypeKey[] = "ShadowType"; const char kShowStateKey[] = "ShowState"; const char kTooltipTextKey[] = "TooltipText"; -// Alphabetical sort. +const char kModalKey[] = "Modal"; +const char kShadowTypeKey[] = "ShadowType"; +const char kRootWindowDragDropClientKey[] = "RootWindowDragDropClient"; +const char kDragDropDelegateKey[] = "DragDropDelegate"; +const char kRootWindowTooltipClientKey[] = "RootWindowTooltipClient"; } // namespace aura diff --git a/ui/aura/client/aura_constants.h b/ui/aura/client/aura_constants.h index f5f2920..c756396 100644 --- a/ui/aura/client/aura_constants.h +++ b/ui/aura/client/aura_constants.h @@ -9,47 +9,15 @@ #include "ui/aura/aura_export.h" namespace aura { - -// Alphabetical sort. - -// A property key to store the activation delegate for a window. The type of the -// value is |aura::ActivationDelegate*|. -AURA_EXPORT extern const char kActivationDelegateKey[]; +// Window property keys that are shared between aura_shell and chrome/views. // A property key to store always-on-top flag. The type of the value is boolean. AURA_EXPORT extern const char kAlwaysOnTopKey[]; -// A property key to store the drag and drop delegate for a window. The type of -// the value is |aura::WindowDragDropDelegate*|. -AURA_EXPORT extern const char kDragDropDelegateKey[]; - -// A property key to store the boolean property of window modality. -AURA_EXPORT extern const char kModalKey[]; - // A property key to store the restore bounds for a window. The type // of the value is |gfx::Rect*|. AURA_EXPORT extern const char kRestoreBoundsKey[]; -// A property key to store the drag and drop client for the root window. The -// type of the value is |aura::DragDropClient*|. -AURA_EXPORT extern const char kRootWindowDragDropClientKey[]; - -// A property key to store the tooltip client for the root window. The type of -// the value is |aura::TooltipClient*|. -AURA_EXPORT extern const char kRootWindowTooltipClientKey[]; - -// A property key to store what the client defines as the active window on the -// RootWindow. The type of the value is |aura::Window*|. -AURA_EXPORT extern const char kRootWindowActiveWindow[]; - -// A property key to store a client that handles window activation. The type of -// the value is |aura::ActivationClient*|. -AURA_EXPORT extern const char kRootWindowActivationClient[]; - -// A property key for a value from aura::ShadowType describing the drop shadow -// that should be displayed under the window. If unset, no shadow is displayed. -AURA_EXPORT extern const char kShadowTypeKey[]; - // A property key to store ui::WindowShowState for a window. // See ui/base/ui_base_types.h for its definition. AURA_EXPORT extern const char kShowStateKey[]; @@ -58,8 +26,24 @@ AURA_EXPORT extern const char kShowStateKey[]; // is |string16*|. AURA_EXPORT extern const char kTooltipTextKey[]; -// Alphabetical sort. +// A property key to store the boolean property of window modality. +AURA_EXPORT extern const char kModalKey[]; + +// A property key for a value from aura::ShadowType describing the drop shadow +// that should be displayed under the window. If unset, no shadow is displayed. +AURA_EXPORT extern const char kShadowTypeKey[]; + +// A property key to store the drag and drop client for the root window. The +// type of the value is |aura::DragDropClient*|. +AURA_EXPORT extern const char kRootWindowDragDropClientKey[]; + +// A property key to store the drag and drop delegate for a window. The type of +// the value is |aura::WindowDragDropDelegate*|. +AURA_EXPORT extern const char kDragDropDelegateKey[]; +// A property key to store the tooltip client for the root window. The type of +// the value is |aura::TooltipClient*|. +AURA_EXPORT extern const char kRootWindowTooltipClientKey[]; } // namespace aura #endif // UI_AURA_CLIENT_AURA_CONSTANTS_H_ diff --git a/ui/aura/client/stacking_client.h b/ui/aura/client/stacking_client.h index 6e89636..26d137b 100644 --- a/ui/aura/client/stacking_client.h +++ b/ui/aura/client/stacking_client.h @@ -21,6 +21,14 @@ class AURA_EXPORT StackingClient { // an opportunity to inspect the window and add it to a default parent window // of its choosing. virtual void AddChildToDefaultParent(Window* window) = 0; + + // Returns true if |window| can be activated or deactivated. + // A window manager typically defines some notion of "top level window" that + // supports activation/deactivation. + virtual bool CanActivateWindow(Window* window) const = 0; + + // Returns the window that should be activated other than |ignore|. + virtual Window* GetTopmostWindowToActivate(Window* ignore) const = 0; }; } // namespace aura |