diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 17:49:27 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 17:49:27 +0000 |
commit | 7721b8d8e5d2ca2044b40e11c783af918f2b3013 (patch) | |
tree | 907ad174397f6ead3d79d982414881db28c80ddd | |
parent | 47f73c9ede1ed4998ee4d291417433fe73bff017 (diff) | |
download | chromium_src-7721b8d8e5d2ca2044b40e11c783af918f2b3013.zip chromium_src-7721b8d8e5d2ca2044b40e11c783af918f2b3013.tar.gz chromium_src-7721b8d8e5d2ca2044b40e11c783af918f2b3013.tar.bz2 |
Remove a bunch of stuff related to Focus/Activation events.
http://crbug.com/162100
R=sadrul@chromium.org
Review URL: https://codereview.chromium.org/11537019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172624 0039d316-1c4b-4281-b951-d872f2087c98
33 files changed, 128 insertions, 453 deletions
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc index 9de5b8c..793e03c 100644 --- a/ash/root_window_controller_unittest.cc +++ b/ash/root_window_controller_unittest.cc @@ -22,7 +22,6 @@ #include "ui/aura/window.h" #include "ui/aura/window_tracker.h" #include "ui/views/controls/menu/menu_controller.h" -#include "ui/views/corewm/focus_change_event.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" diff --git a/ash/shell.cc b/ash/shell.cc index de1721d..1651251 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -87,7 +87,6 @@ #include "ui/ui_controls/ui_controls.h" #include "ui/views/corewm/compound_event_filter.h" #include "ui/views/corewm/corewm_switches.h" -#include "ui/views/corewm/focus_change_event.h" #include "ui/views/corewm/focus_controller.h" #include "ui/views/corewm/input_method_event_filter.h" #include "ui/views/corewm/shadow_controller.h" @@ -414,6 +413,7 @@ void Shell::Init() { new views::corewm::FocusController(new wm::AshFocusRules); focus_client_.reset(focus_controller); activation_client_ = focus_controller; + activation_client_->AddObserver(this); } else { focus_client_.reset(new aura::FocusManager); activation_controller_.reset( @@ -891,11 +891,14 @@ ui::EventTarget* Shell::GetParentTarget() { } void Shell::OnEvent(ui::Event* event) { - if (event->type() == - views::corewm::FocusChangeEvent::activation_changed_event_type()) { - active_root_window_ = - static_cast<aura::Window*>(event->target())->GetRootWindow(); - } +} + +//////////////////////////////////////////////////////////////////////////////// +// Shell, aura::client::ActivationChangeObserver implementation: + +void Shell::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + active_root_window_ = gained_active->GetRootWindow(); } } // namespace ash diff --git a/ash/shell.h b/ash/shell.h index b63010b..5bd0fbf 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -18,6 +18,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/base/events/event_target.h" #include "ui/gfx/insets.h" #include "ui/gfx/screen.h" @@ -126,8 +127,10 @@ class ShellTestApi; // // Upon creation, the Shell sets itself as the RootWindow's delegate, which // takes ownership of the Shell. -class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate, - public ui::EventTarget { +class ASH_EXPORT Shell + : public internal::SystemModalContainerEventFilterDelegate, + public ui::EventTarget, + public aura::client::ActivationChangeObserver { public: typedef std::vector<aura::RootWindow*> RootWindowList; typedef std::vector<internal::RootWindowController*> RootWindowControllerList; @@ -451,6 +454,10 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate, virtual EventTarget* GetParentTarget() OVERRIDE; virtual void OnEvent(ui::Event* event) OVERRIDE; + // Overridden from aura::client::ActivationChangeObserver: + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; + static Shell* instance_; // If set before the Shell is initialized, the mouse cursor will be hidden diff --git a/ash/test/test_activation_delegate.cc b/ash/test/test_activation_delegate.cc index 5c57609..5ad14d0 100644 --- a/ash/test/test_activation_delegate.cc +++ b/ash/test/test_activation_delegate.cc @@ -8,7 +8,6 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/window.h" #include "ui/base/events/event.h" -#include "ui/views/corewm/focus_change_event.h" namespace ash { namespace test { diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index d21e19f..bcc85e5 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -82,8 +82,7 @@ gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) { // AppListController, public: AppListController::AppListController() - : FocusChangeShim(Shell::GetInstance()), - pagination_model_(new app_list::PaginationModel), + : pagination_model_(new app_list::PaginationModel), is_visible_(false), view_(NULL), should_snap_back_(false) { diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h index 07314aa..9111370 100644 --- a/ash/wm/app_list_controller.h +++ b/ash/wm/app_list_controller.h @@ -11,11 +11,11 @@ #include "base/compiler_specific.h" #include "base/timer.h" #include "ui/app_list/pagination_model_observer.h" +#include "ui/aura/client/focus_change_observer.h" #include "ui/aura/root_window_observer.h" #include "ui/base/events/event_handler.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/gfx/rect.h" -#include "ui/views/corewm/focus_change_shim.h" #include "ui/views/widget/widget_observer.h" namespace app_list { @@ -34,7 +34,8 @@ namespace internal { // It creates AppListView and schedules showing/hiding animation. // While the UI is visible, it monitors things such as app list widget's // activation state and desktop mouse click to auto dismiss the UI. -class AppListController : public views::corewm::FocusChangeShim, +class AppListController : public ui::EventHandler, + public aura::client::FocusChangeObserver, public aura::RootWindowObserver, public ui::ImplicitAnimationObserver, public views::WidgetObserver, diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index 87c2567..f811bad 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -11,13 +11,13 @@ #include "ash/wm/window_properties.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/workspace_window_resizer.h" +#include "ui/aura/client/activation_client.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/base/ui_base_types.h" #include "ui/compositor/layer.h" #include "ui/gfx/screen.h" -#include "ui/views/corewm/focus_change_event.h" #include "ui/views/corewm/window_util.h" namespace ash { @@ -27,16 +27,15 @@ namespace internal { // BaseLayoutManager, public: BaseLayoutManager::BaseLayoutManager(aura::RootWindow* root_window) - : root_window_(root_window) { + : root_window_(root_window), + added_observer_(false) { Shell::GetInstance()->AddShellObserver(this); root_window_->AddRootWindowObserver(this); root_window_->AddObserver(this); - root_window_->AddPreTargetHandler(this); } BaseLayoutManager::~BaseLayoutManager() { if (root_window_) { - root_window_->RemovePreTargetHandler(this); root_window_->RemoveObserver(this); root_window_->RemoveRootWindowObserver(this); } @@ -67,6 +66,10 @@ void BaseLayoutManager::OnWindowResized() { } void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) { + if (!added_observer_) { + added_observer_ = true; + aura::client::GetActivationClient(root_window_)->AddObserver(this); + } windows_.insert(child); child->AddObserver(this); // Only update the bounds if the window has a show state that depends on the @@ -150,16 +153,13 @@ void BaseLayoutManager::OnWindowDestroying(aura::Window* window) { } ////////////////////////////////////////////////////////////////////////////// -// BaseLayoutManager, ui::EventHandler implementation: - -void BaseLayoutManager::OnEvent(ui::Event* event) { - if (event->type() == - views::corewm::FocusChangeEvent::activation_changed_event_type()) { - aura::Window* activated = static_cast<aura::Window*>(event->target()); - if (wm::IsWindowMinimized(activated)) { - activated->Show(); - DCHECK(!wm::IsWindowMinimized(activated)); - } +// BaseLayoutManager, aura::client::ActivationChangeObserver implementation: + +void BaseLayoutManager::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + if (gained_active && wm::IsWindowMinimized(gained_active)) { + gained_active->Show(); + DCHECK(!wm::IsWindowMinimized(gained_active)); } } diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h index 312e8ae..1ad6ffb 100644 --- a/ash/wm/base_layout_manager.h +++ b/ash/wm/base_layout_manager.h @@ -11,11 +11,12 @@ #include "ash/shell_observer.h" #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/layout_manager.h" #include "ui/aura/root_window_observer.h" +#include "ui/aura/window_observer.h" #include "ui/base/events/event_handler.h" #include "ui/base/ui_base_types.h" -#include "ui/aura/window_observer.h" namespace aura { class RootWindow; @@ -30,11 +31,12 @@ namespace internal { // window appropriately. Subclasses should be sure to invoke the base class // for adding and removing windows, otherwise show state will not be tracked // properly. -class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, - public aura::RootWindowObserver, - public ash::ShellObserver, - public aura::WindowObserver, - public ui::EventHandler { +class ASH_EXPORT BaseLayoutManager + : public aura::LayoutManager, + public aura::RootWindowObserver, + public ash::ShellObserver, + public aura::WindowObserver, + public aura::client::ActivationChangeObserver { public: typedef std::set<aura::Window*> WindowSet; @@ -72,8 +74,9 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, intptr_t old) OVERRIDE; virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; - // ui::EventHandler overrides: - virtual void OnEvent(ui::Event* event) OVERRIDE; + // aura::client::ActivationChangeObserver overrides: + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; protected: // Invoked from OnWindowPropertyChanged() if |kShowStateKey| changes. @@ -93,6 +96,8 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, aura::RootWindow* root_window_; + bool added_observer_; + DISALLOW_COPY_AND_ASSIGN(BaseLayoutManager); }; diff --git a/ash/wm/panel_layout_manager.cc b/ash/wm/panel_layout_manager.cc index 1c22001..7aa9207 100644 --- a/ash/wm/panel_layout_manager.cc +++ b/ash/wm/panel_layout_manager.cc @@ -122,8 +122,7 @@ void FanOutPanels(std::vector<VisiblePanelPositionInfo>::iterator first, //////////////////////////////////////////////////////////////////////////////// // PanelLayoutManager public implementation: PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) - : ActivationChangeShim(Shell::GetInstance()), - panel_container_(panel_container), + : panel_container_(panel_container), in_layout_(false), dragged_panel_(NULL), launcher_(NULL), @@ -284,11 +283,13 @@ void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, //////////////////////////////////////////////////////////////////////////////// // PanelLayoutManager, aura::client::ActivationChangeObserver implementation: -void PanelLayoutManager::OnWindowActivated(aura::Window* active, - aura::Window* old_active) { - if (active && active->type() == aura::client::WINDOW_TYPE_PANEL) { - UpdateStacking(active); - UpdateCallout(active); + +void PanelLayoutManager::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + if (gained_active && + gained_active->type() == aura::client::WINDOW_TYPE_PANEL) { + UpdateStacking(gained_active); + UpdateCallout(gained_active); } else { UpdateCallout(NULL); } diff --git a/ash/wm/panel_layout_manager.h b/ash/wm/panel_layout_manager.h index 5418a3e..eb10cbe 100644 --- a/ash/wm/panel_layout_manager.h +++ b/ash/wm/panel_layout_manager.h @@ -13,9 +13,9 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/layout_manager.h" #include "ui/aura/window_observer.h" -#include "ui/views/corewm/activation_change_shim.h" namespace aura { class Window; @@ -47,7 +47,7 @@ class ASH_EXPORT PanelLayoutManager : public aura::LayoutManager, public ash::LauncherIconObserver, public aura::WindowObserver, - public views::corewm::ActivationChangeShim { + public aura::client::ActivationChangeObserver { public: explicit PanelLayoutManager(aura::Window* panel_container); virtual ~PanelLayoutManager(); @@ -78,8 +78,8 @@ class ASH_EXPORT PanelLayoutManager intptr_t old) OVERRIDE; // Overridden from aura::client::ActivationChangeObserver - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; private: friend class PanelLayoutManagerTest; diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index e37e486..dce2fd2 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -144,9 +144,7 @@ class ShelfLayoutManager::UpdateShelfObserver // ShelfLayoutManager ---------------------------------------------------------- ShelfLayoutManager::ShelfLayoutManager(StatusAreaWidget* status_area_widget) - : ActivationChangeShim( - status_area_widget->GetNativeView()->GetRootWindow()), - root_window_(status_area_widget->GetNativeView()->GetRootWindow()), + : root_window_(status_area_widget->GetNativeView()->GetRootWindow()), in_layout_(false), auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER), alignment_(SHELF_ALIGNMENT_BOTTOM), @@ -470,8 +468,8 @@ void ShelfLayoutManager::OnLockStateChanged(bool locked) { UpdateVisibilityState(); } -void ShelfLayoutManager::OnWindowActivated(aura::Window* active, - aura::Window* old_active) { +void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { UpdateAutoHideStateNow(); } diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h index 0a4a018..f58a4dc 100644 --- a/ash/wm/shelf_layout_manager.h +++ b/ash/wm/shelf_layout_manager.h @@ -14,10 +14,10 @@ #include "base/logging.h" #include "base/observer_list.h" #include "base/timer.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/layout_manager.h" #include "ui/gfx/insets.h" #include "ui/gfx/rect.h" -#include "ui/views/corewm/activation_change_shim.h" namespace aura { class RootWindow; @@ -44,7 +44,7 @@ class WorkspaceController; class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager, public ash::ShellObserver, - public views::corewm::ActivationChangeShim { + public aura::client::ActivationChangeObserver { public: class ASH_EXPORT Observer { public: @@ -154,8 +154,8 @@ class ASH_EXPORT ShelfLayoutManager : virtual void OnLockStateChanged(bool locked) OVERRIDE; // Overriden from aura::client::ActivationChangeObserver: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; // TODO(harrym|oshima): These templates will be moved to // new Shelf class. diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc index 92f1363..4158451 100644 --- a/ash/wm/window_cycle_controller.cc +++ b/ash/wm/window_cycle_controller.cc @@ -89,8 +89,7 @@ void AddCycleWindows(aura::RootWindow* root, WindowCycleController::WindowCycleController( aura::client::ActivationClient* activation_client) - : ActivationChangeShim(Shell::GetInstance()), - activation_client_(activation_client) { + : activation_client_(activation_client) { activation_client_->AddObserver(this); } @@ -267,11 +266,12 @@ void WindowCycleController::InstallEventFilter() { Shell::GetInstance()->AddPreTargetHandler(event_handler_.get()); } -void WindowCycleController::OnWindowActivated(aura::Window* active, - aura::Window* old_active) { - if (active && !IsCycling() && IsTrackedContainer(active->parent())) { - mru_windows_.remove(active); - mru_windows_.push_front(active); +void WindowCycleController::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + if (gained_active && !IsCycling() && + IsTrackedContainer(gained_active->parent())) { + mru_windows_.remove(gained_active); + mru_windows_.push_front(gained_active); } } diff --git a/ash/wm/window_cycle_controller.h b/ash/wm/window_cycle_controller.h index b568e92..e673892 100644 --- a/ash/wm/window_cycle_controller.h +++ b/ash/wm/window_cycle_controller.h @@ -11,8 +11,8 @@ #include "ash/ash_export.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/window_observer.h" -#include "ui/views/corewm/activation_change_shim.h" namespace aura { class RootWindow; @@ -38,7 +38,7 @@ class WindowCycleList; // at the beginning of the gesture so you can cycle through in a consistent // order. class ASH_EXPORT WindowCycleController - : public views::corewm::ActivationChangeShim, + : public aura::client::ActivationChangeObserver, public aura::WindowObserver { public: enum Direction { @@ -97,9 +97,9 @@ class ASH_EXPORT WindowCycleController // Checks if the window represents a container whose children we track. static bool IsTrackedContainer(aura::Window* window); - // Overridden from views::corewm::ActivationChangeShim: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; + // Overridden from aura::client::ActivationChangeObserver: + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; // Overridden from WindowObserver: virtual void OnWindowAdded(aura::Window* window) OVERRIDE; diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc index 0232d76..3ca70d6 100644 --- a/ash/wm/workspace_controller.cc +++ b/ash/wm/workspace_controller.cc @@ -18,8 +18,7 @@ namespace ash { namespace internal { WorkspaceController::WorkspaceController(aura::Window* viewport) - : ActivationChangeShim(viewport->GetRootWindow()), - viewport_(viewport), + : viewport_(viewport), workspace_cycler_(NULL) { aura::RootWindow* root_window = viewport->GetRootWindow(); workspace_manager_.reset(new WorkspaceManager(viewport)); @@ -56,10 +55,12 @@ void WorkspaceController::DoInitialAnimation() { workspace_manager_->DoInitialAnimation(); } -void WorkspaceController::OnWindowActivated(aura::Window* window, - aura::Window* old_active) { - if (!window || window->GetRootWindow() == viewport_->GetRootWindow()) - workspace_manager_->SetActiveWorkspaceByWindow(window); +void WorkspaceController::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + if (!gained_active || + gained_active->GetRootWindow() == viewport_->GetRootWindow()) { + workspace_manager_->SetActiveWorkspaceByWindow(gained_active); + } } } // namespace internal diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h index 028ae7a..a77863a 100644 --- a/ash/wm/workspace_controller.h +++ b/ash/wm/workspace_controller.h @@ -9,7 +9,7 @@ #include "ash/wm/workspace/workspace_types.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#include "ui/views/corewm/activation_change_shim.h" +#include "ui/aura/client/activation_change_observer.h" namespace aura { class Window; @@ -27,7 +27,7 @@ class WorkspaceManager; // WorkspaceController acts as a central place that ties together all the // various workspace pieces. class ASH_EXPORT WorkspaceController - : public views::corewm::ActivationChangeShim { + : public aura::client::ActivationChangeObserver { public: explicit WorkspaceController(aura::Window* viewport); virtual ~WorkspaceController(); @@ -47,8 +47,8 @@ class ASH_EXPORT WorkspaceController void DoInitialAnimation(); // aura::client::ActivationChangeObserver overrides: - virtual void OnWindowActivated(aura::Window* window, - aura::Window* old_active) OVERRIDE; + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; private: friend class WorkspaceControllerTestHelper; diff --git a/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc index a040a42..55e688c 100644 --- a/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc @@ -184,9 +184,7 @@ class ShellWindowLauncherController::AppLauncherItemController ShellWindowLauncherController::ShellWindowLauncherController( ChromeLauncherController* owner) - : ActivationChangeShim(ash::Shell::HasInstance() ? - ash::Shell::GetInstance() : NULL), - owner_(owner), + : owner_(owner), registry_(extensions::ShellWindowRegistry::Get(owner->profile())), activation_client_(NULL) { registry_->AddObserver(this); diff --git a/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h b/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h index b154bcd..9dba82a 100644 --- a/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h +++ b/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h @@ -10,8 +10,8 @@ #include <string> #include "chrome/browser/extensions/shell_window_registry.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/window_observer.h" -#include "ui/views/corewm/activation_change_shim.h" namespace aura { @@ -33,7 +33,7 @@ class ShellWindow; class ShellWindowLauncherController : public extensions::ShellWindowRegistry::Observer, public aura::WindowObserver, - public views::corewm::ActivationChangeShim { + public aura::client::ActivationChangeObserver { public: explicit ShellWindowLauncherController(ChromeLauncherController* owner); virtual ~ShellWindowLauncherController(); @@ -47,8 +47,8 @@ class ShellWindowLauncherController virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; // Overriden from client::ActivationChangeObserver: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; private: class AppLauncherItemController; diff --git a/ui/views/controls/menu/menu_controller_aura.cc b/ui/views/controls/menu/menu_controller_aura.cc index d5c6295..3051903 100644 --- a/ui/views/controls/menu/menu_controller_aura.cc +++ b/ui/views/controls/menu/menu_controller_aura.cc @@ -5,13 +5,13 @@ #include "ui/views/controls/menu/menu_controller.h" #include "base/run_loop.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/dispatcher_client.h" #include "ui/aura/client/drag_drop_client.h" #include "ui/aura/root_window.h" #include "ui/aura/window_observer.h" #include "ui/gfx/screen.h" -#include "ui/views/corewm/activation_change_shim.h" #include "ui/views/widget/widget.h" namespace views { @@ -22,13 +22,12 @@ namespace { // the menu. Additionally it listens for the root window to be destroyed and // cancel the menu as well. class ActivationChangeObserverImpl - : public corewm::ActivationChangeShim, + : public aura::client::ActivationChangeObserver, public aura::WindowObserver { public: ActivationChangeObserverImpl(MenuController* controller, aura::RootWindow* root) - : ActivationChangeShim(root), - controller_(controller), + : controller_(controller), root_(root) { aura::client::GetActivationClient(root_)->AddObserver(this); root_->AddObserver(this); @@ -39,8 +38,8 @@ class ActivationChangeObserverImpl } // aura::client::ActivationChangeObserver overrides: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE { + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE { if (!controller_->drag_in_progress()) controller_->CancelAll(); } diff --git a/ui/views/corewm/activation_change_shim.cc b/ui/views/corewm/activation_change_shim.cc deleted file mode 100644 index 97c8b82..0000000 --- a/ui/views/corewm/activation_change_shim.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2012 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/views/corewm/activation_change_shim.h" - -#include "ui/aura/window.h" -#include "ui/base/events/event_target.h" -#include "ui/views/corewm/corewm_switches.h" -#include "ui/views/corewm/focus_change_event.h" - -namespace views { -namespace corewm { - -ActivationChangeShim::ActivationChangeShim(ui::EventTarget* target) - : target_(target) { - if (UseFocusController() && target_) - target_->AddPreTargetHandler(this); -} - -ActivationChangeShim::~ActivationChangeShim() { - if (UseFocusController() && target_) - target_->RemovePreTargetHandler(this); -} - -void ActivationChangeShim::OnWindowActivated(aura::Window* active, - aura::Window* old_active) { -} - -void ActivationChangeShim::OnEvent(ui::Event* event) { - if (event->type() == FocusChangeEvent::activation_changed_event_type()) { - DCHECK(UseFocusController()); - FocusChangeEvent* fce = static_cast<FocusChangeEvent*>(event); - OnWindowActivated(static_cast<aura::Window*>(event->target()), - static_cast<aura::Window*>(fce->last_focus())); - } - EventHandler::OnEvent(event); -} - -} // namespace corewm -} // namespace views diff --git a/ui/views/corewm/activation_change_shim.h b/ui/views/corewm/activation_change_shim.h deleted file mode 100644 index 77bed97..0000000 --- a/ui/views/corewm/activation_change_shim.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2012 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_VIEWS_COREWM_ACTIVATION_CHANGE_SHIM_ -#define UI_VIEWS_COREWM_ACTIVATION_CHANGE_SHIM_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/client/activation_change_observer.h" -#include "ui/base/events/event_handler.h" -#include "ui/views/corewm/focus_change_event.h" -#include "ui/views/views_export.h" - -namespace ui { -class EventTarget; -} - -namespace views { -namespace corewm { - -// A class that converts FocusChangeEvents to calls to an -// ActivationChangeObserver. An interim bandaid that allows us to incrementally -// convert observers to use the new FocusController. -class VIEWS_EXPORT ActivationChangeShim - : public aura::client::ActivationChangeObserver, - public ui::EventHandler { - protected: - explicit ActivationChangeShim(ui::EventTarget* target); - virtual ~ActivationChangeShim(); - - // Overridden from aura::client::ActivationChangeObserver: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; - - // Overridden from ui::EventHandler: - virtual void OnEvent(ui::Event* event) OVERRIDE; - - private: - ui::EventTarget* target_; - - DISALLOW_COPY_AND_ASSIGN(ActivationChangeShim); -}; - -} // namespace corewm -} // namespace views - -#endif // UI_VIEWS_COREWM_ACTIVATION_CHANGE_SHIM_ diff --git a/ui/views/corewm/focus_change_event.cc b/ui/views/corewm/focus_change_event.cc deleted file mode 100644 index 90a943e..0000000 --- a/ui/views/corewm/focus_change_event.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2012 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/views/corewm/focus_change_event.h" - -#include "base/time.h" -#include "ui/base/events/event_utils.h" - -namespace views { -namespace corewm { - -namespace { - -std::string FocusChangeEventName(int type) { - if (type == FocusChangeEvent::focus_changing_event_type()) - return "FOCUS_CHANGING"; - if (type == FocusChangeEvent::focus_changed_event_type()) - return "FOCUS_CHANGED"; - if (type == FocusChangeEvent::activation_changing_event_type()) - return "ACTIVATION_CHANGING"; - if (type == FocusChangeEvent::activation_changed_event_type()) - return "ACTIVATION_CHANGED"; - NOTREACHED(); - return std::string(); -} - -} // namespace - -// static -int FocusChangeEvent::focus_changing_event_type_ = ui::ET_UNKNOWN; -int FocusChangeEvent::focus_changed_event_type_ = ui::ET_UNKNOWN; -int FocusChangeEvent::activation_changing_event_type_ = ui::ET_UNKNOWN; -int FocusChangeEvent::activation_changed_event_type_ = ui::ET_UNKNOWN; - -FocusChangeEvent::FocusChangeEvent(int type) - : Event(static_cast<ui::EventType>(type), - base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT()), - 0), - last_focus_(NULL) { - DCHECK_NE(type, ui::ET_UNKNOWN) << - "Call RegisterEventTypes() before instantiating this class"; - set_cancelable(false); - set_dispatch_to_hidden_targets(true); - set_name(FocusChangeEventName(type)); -} - -FocusChangeEvent::~FocusChangeEvent() { -} - -// static -void FocusChangeEvent::RegisterEventTypes() { - static bool registered = false; - if (!registered) { - registered = true; - focus_changing_event_type_ = ui::RegisterCustomEventType(); - focus_changed_event_type_ = ui::RegisterCustomEventType(); - activation_changing_event_type_ = ui::RegisterCustomEventType(); - activation_changed_event_type_ = ui::RegisterCustomEventType(); - } -} - -} // namespace corewm -} // namespace views diff --git a/ui/views/corewm/focus_change_event.h b/ui/views/corewm/focus_change_event.h deleted file mode 100644 index 8222bae..0000000 --- a/ui/views/corewm/focus_change_event.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2012 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_VIEWS_COREWM_FOCUS_CHANGE_EVENT_H_ -#define UI_VIEWS_COREWM_FOCUS_CHANGE_EVENT_H_ - -#include "ui/base/events/event.h" -#include "ui/base/events/event_target.h" -#include "ui/views/views_export.h" - -namespace views { -namespace corewm { - -// FocusChangeEvent notifies a change in focus or activation state. -// Focus refers to the target that can receive key events. -// Activation is the key "top level window" as defined by the window management -// scheme in use. -// Focus and activation are closely related, and the rules governing their -// change are numerous and complex. The implementation of the dispatch of this -// event is handled by the FocusController. See that class and its unit tests -// for specifics. -class VIEWS_EXPORT FocusChangeEvent : public ui::Event { - public: - // An API used by the code in FocusController that dispatches - // FocusChangeEvents. - class DispatcherApi : public ui::Event::DispatcherApi { - public: - explicit DispatcherApi(FocusChangeEvent* event) - : ui::Event::DispatcherApi(event), event_(event) {} - - void set_last_focus(ui::EventTarget* last_focus) { - event_->last_focus_ = last_focus; - } - - private: - FocusChangeEvent* event_; - - DISALLOW_COPY_AND_ASSIGN(DispatcherApi); - }; - - // |type| is one of the possible FocusChangeEvent types registered by calling - // RegisterEventTypes() before instantiating this class. See below. - explicit FocusChangeEvent(int type); - virtual ~FocusChangeEvent(); - - // Must be called before instantiating this class. - static void RegisterEventTypes(); - - // -ing events are sent when focus or activation is about to be changed. This - // gives the target and its pre- and post- handlers the ability to abort the - // or re-target the change before the FocusController makes it. - static int focus_changing_event_type() { return focus_changing_event_type_; } - static int activation_changing_event_type() { - return activation_changing_event_type_; - } - - // -ed events are sent when focus or activation has been changed in the - // FocusController. It is possible to stop propagation of this event but that - // only affects handlers downstream from being notified of the change already - // made in the FocusController. - static int focus_changed_event_type() { return focus_changed_event_type_; } - static int activation_changed_event_type() { - return activation_changed_event_type_; - } - - ui::EventTarget* last_focus() { return last_focus_; } - - private: - FocusChangeEvent(); - - // The EventTarget that had focus or activation prior to this event. - ui::EventTarget* last_focus_; - - static int focus_changing_event_type_; - static int focus_changed_event_type_; - static int activation_changing_event_type_; - static int activation_changed_event_type_; - - DISALLOW_COPY_AND_ASSIGN(FocusChangeEvent); -}; - -} // namespace corewm -} // namespace views - -#endif // UI_VIEWS_COREWM_FOCUS_CHANGE_EVENT_H_ diff --git a/ui/views/corewm/focus_change_shim.cc b/ui/views/corewm/focus_change_shim.cc deleted file mode 100644 index 6db643d..0000000 --- a/ui/views/corewm/focus_change_shim.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 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/views/corewm/focus_change_shim.h" - -#include "ui/aura/window.h" -#include "ui/base/events/event_target.h" -#include "ui/views/corewm/corewm_switches.h" -#include "ui/views/corewm/focus_change_event.h" - -namespace views { -namespace corewm { - -FocusChangeShim::FocusChangeShim(ui::EventTarget* target) - : target_(target) { - if (views::corewm::UseFocusController() && target_) - target_->AddPreTargetHandler(this); -} - -FocusChangeShim::~FocusChangeShim() { - if (views::corewm::UseFocusController() && target_) - target_->RemovePreTargetHandler(this); -} - -void FocusChangeShim::OnWindowFocused(aura::Window* gained_focus, - aura::Window* lost_focus) { -} - -void FocusChangeShim::OnEvent(ui::Event* event) { - if (event->type() == FocusChangeEvent::focus_changed_event_type()) { - DCHECK(views::corewm::UseFocusController()); - OnWindowFocused(static_cast<aura::Window*>(event->target()), NULL); - } - EventHandler::OnEvent(event); -} - -} // namespace corewm -} // namespace views diff --git a/ui/views/corewm/focus_change_shim.h b/ui/views/corewm/focus_change_shim.h deleted file mode 100644 index 1f0f496..0000000 --- a/ui/views/corewm/focus_change_shim.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2012 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_VIEWS_COREWM_FOCUS_CHANGE_SHIM_ -#define UI_VIEWS_COREWM_FOCUS_CHANGE_SHIM_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/client/focus_change_observer.h" -#include "ui/base/events/event_handler.h" -#include "ui/views/corewm/focus_change_event.h" -#include "ui/views/views_export.h" - -namespace ui { -class EventTarget; -} - -namespace views { -namespace corewm { - -// A class that converts FocusChangeEvents to calls to an -// FocusChangeObserver. An interim bandaid that allows us to incrementally -// convert observers to use the new FocusController. -class VIEWS_EXPORT FocusChangeShim - : public aura::client::FocusChangeObserver, - public ui::EventHandler { - protected: - explicit FocusChangeShim(ui::EventTarget* target); - virtual ~FocusChangeShim(); - - // Overridden from aura::client::FocusChangeObserver: - virtual void OnWindowFocused(aura::Window* gained_focus, - aura::Window* lost_focus) OVERRIDE; - - // Overridden from ui::EventHandler: - virtual void OnEvent(ui::Event* event) OVERRIDE; - - private: - ui::EventTarget* target_; - - DISALLOW_COPY_AND_ASSIGN(FocusChangeShim); -}; - -} // namespace corewm -} // namespace views - -#endif // UI_VIEWS_COREWM_FOCUS_CHANGE_SHIM_ diff --git a/ui/views/corewm/focus_controller.cc b/ui/views/corewm/focus_controller.cc index 41d6c61..088f837 100644 --- a/ui/views/corewm/focus_controller.cc +++ b/ui/views/corewm/focus_controller.cc @@ -9,6 +9,7 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/focus_change_observer.h" #include "ui/aura/env.h" +#include "ui/base/events/event.h" #include "ui/views/corewm/focus_rules.h" namespace views { diff --git a/ui/views/corewm/focus_controller.h b/ui/views/corewm/focus_controller.h index f799d62..780ee15 100644 --- a/ui/views/corewm/focus_controller.h +++ b/ui/views/corewm/focus_controller.h @@ -11,7 +11,6 @@ #include "ui/aura/client/focus_client.h" #include "ui/aura/env_observer.h" #include "ui/aura/window_observer.h" -#include "ui/base/events/event_dispatcher.h" #include "ui/views/views_export.h" namespace views { @@ -22,7 +21,8 @@ class FocusRules; // FocusController handles focus and activation changes for an environment // encompassing one or more RootWindows. Within an environment there can be // only one focused and one active window at a time. When focus or activation -// changes a FocusChangeEvent is dispatched. +// changes notifications are sent using the +// aura::client::Focus/ActivationChangeObserver interfaces. // Changes to focus and activation can be from three sources: // . the Aura Client API (implemented here in aura::client::ActivationClient). // (The FocusController must be set as the ActivationClient implementation diff --git a/ui/views/corewm/focus_controller_unittest.cc b/ui/views/corewm/focus_controller_unittest.cc index 3ca5c21..a74346d 100644 --- a/ui/views/corewm/focus_controller_unittest.cc +++ b/ui/views/corewm/focus_controller_unittest.cc @@ -18,7 +18,6 @@ #include "ui/aura/window_tracker.h" #include "ui/base/events/event_handler.h" #include "ui/views/corewm/base_focus_rules.h" -#include "ui/views/corewm/focus_change_event.h" namespace views { namespace corewm { diff --git a/ui/views/corewm/shadow_controller.cc b/ui/views/corewm/shadow_controller.cc index 0c587b3..5ab2106 100644 --- a/ui/views/corewm/shadow_controller.cc +++ b/ui/views/corewm/shadow_controller.cc @@ -67,8 +67,7 @@ Shadow::Style GetShadowStyleForWindowLosingActive( } // namespace ShadowController::ShadowController(aura::RootWindow* root_window) - : ActivationChangeShim(root_window), - ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)), + : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)), root_window_(root_window) { aura::Env::GetInstance()->AddObserver(this); // Watch for window activation changes. @@ -108,18 +107,18 @@ void ShadowController::OnWindowDestroyed(aura::Window* window) { observer_manager_.Remove(window); } -void ShadowController::OnWindowActivated(aura::Window* gaining_active, - aura::Window* losing_active) { - if (gaining_active) { - Shadow* shadow = GetShadowForWindow(gaining_active); - if (shadow && !ShouldUseSmallShadowForWindow(gaining_active)) +void ShadowController::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + if (gained_active) { + Shadow* shadow = GetShadowForWindow(gained_active); + if (shadow && !ShouldUseSmallShadowForWindow(gained_active)) shadow->SetStyle(Shadow::STYLE_ACTIVE); } - if (losing_active) { - Shadow* shadow = GetShadowForWindow(losing_active); - if (shadow && !ShouldUseSmallShadowForWindow(losing_active)) { - shadow->SetStyle(GetShadowStyleForWindowLosingActive(losing_active, - gaining_active)); + if (lost_active) { + Shadow* shadow = GetShadowForWindow(lost_active); + if (shadow && !ShouldUseSmallShadowForWindow(lost_active)) { + shadow->SetStyle(GetShadowStyleForWindowLosingActive(lost_active, + gained_active)); } } } diff --git a/ui/views/corewm/shadow_controller.h b/ui/views/corewm/shadow_controller.h index 8c8bd72..68381fc 100644 --- a/ui/views/corewm/shadow_controller.h +++ b/ui/views/corewm/shadow_controller.h @@ -11,9 +11,9 @@ #include "base/compiler_specific.h" #include "base/memory/linked_ptr.h" #include "base/scoped_observer.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/env_observer.h" #include "ui/aura/window_observer.h" -#include "ui/views/corewm/activation_change_shim.h" #include "ui/views/views_export.h" namespace aura { @@ -34,7 +34,7 @@ class Shadow; class VIEWS_EXPORT ShadowController : public aura::EnvObserver, public aura::WindowObserver, - public ActivationChangeShim { + public aura::client::ActivationChangeObserver { public: class TestApi { public: @@ -66,9 +66,9 @@ class VIEWS_EXPORT ShadowController : const gfx::Rect& new_bounds) OVERRIDE; virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; - // ActivationChangeShim overrides: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; + // aura::client::ActivationChangeObserver overrides: + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; private: typedef std::map<aura::Window*, linked_ptr<Shadow> > WindowShadowMap; diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 38f72cc..adbe911 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -237,18 +237,12 @@ 'controls/tree/tree_view_views.h', 'controls/tree/tree_view_win.cc', 'controls/tree/tree_view_win.h', - 'corewm/activation_change_shim.cc', - 'corewm/activation_change_shim.h', 'corewm/base_focus_rules.cc', 'corewm/base_focus_rules.h', 'corewm/compound_event_filter.cc', 'corewm/compound_event_filter.h', 'corewm/corewm_switches.cc', 'corewm/corewm_switches.h', - 'corewm/focus_change_event.cc', - 'corewm/focus_change_event.h', - 'corewm/focus_change_shim.cc', - 'corewm/focus_change_shim.h', 'corewm/focus_controller.cc', 'corewm/focus_controller.h', 'corewm/focus_rules.h', diff --git a/ui/views/widget/native_widget_aura_window_observer.cc b/ui/views/widget/native_widget_aura_window_observer.cc index dc101b4..3be33dd 100644 --- a/ui/views/widget/native_widget_aura_window_observer.cc +++ b/ui/views/widget/native_widget_aura_window_observer.cc @@ -13,8 +13,7 @@ namespace views { NativeWidgetAuraWindowObserver::NativeWidgetAuraWindowObserver( gfx::NativeView native_view, internal::NativeWidgetDelegate* delegate) - : ActivationChangeShim(native_view->GetRootWindow()), - native_view_(native_view), + : native_view_(native_view), delegate_(delegate) { native_view_->GetRootWindow()->AddObserver(this); native_view_->AddObserver(this); @@ -27,11 +26,10 @@ NativeWidgetAuraWindowObserver::~NativeWidgetAuraWindowObserver() { } void NativeWidgetAuraWindowObserver::OnWindowActivated( - aura::Window* active, - aura::Window* old_active) { - if (!active || active->transient_parent() != native_view_) { + aura::Window* gained_active, + aura::Window* lost_active) { + if (!gained_active || gained_active->transient_parent() != native_view_) delegate_->EnableInactiveRendering(); - } } void NativeWidgetAuraWindowObserver::OnWindowRemovingFromRootWindow( diff --git a/ui/views/widget/native_widget_aura_window_observer.h b/ui/views/widget/native_widget_aura_window_observer.h index 380a7fb..70a6037 100644 --- a/ui/views/widget/native_widget_aura_window_observer.h +++ b/ui/views/widget/native_widget_aura_window_observer.h @@ -6,9 +6,9 @@ #define UI_VIEWS_WIDGET_NATIVE_WIDGET_AURA_WINDOW_OBSERVER_H_ #include "base/compiler_specific.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/window_observer.h" #include "ui/gfx/native_widget_types.h" -#include "ui/views/corewm/activation_change_shim.h" #include "ui/views/widget/native_widget_private.h" namespace views { @@ -18,7 +18,7 @@ namespace views { // changes in such a way that we should enable inactive rendering. class NativeWidgetAuraWindowObserver : public aura::WindowObserver, - public corewm::ActivationChangeShim { + public aura::client::ActivationChangeObserver { public: explicit NativeWidgetAuraWindowObserver( gfx::NativeView native_view, @@ -26,8 +26,8 @@ class NativeWidgetAuraWindowObserver virtual ~NativeWidgetAuraWindowObserver(); // Overridden from aura::client::ActivationChangeObserver: - virtual void OnWindowActivated(aura::Window* active, - aura::Window* old_active) OVERRIDE; + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; // Overridden from aura::WindowObserver: virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE; |