diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 03:28:46 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 03:28:46 +0000 |
commit | 8cfb672c1560ea3354b0a51fa2efca3de8249beb (patch) | |
tree | 9e4e4dba8001b6b37a6b2b15070544c26f5008be /ui | |
parent | 9bf222b0ada03412fbbb61a5dcf2f6205bb1f0d8 (diff) | |
download | chromium_src-8cfb672c1560ea3354b0a51fa2efca3de8249beb.zip chromium_src-8cfb672c1560ea3354b0a51fa2efca3de8249beb.tar.gz chromium_src-8cfb672c1560ea3354b0a51fa2efca3de8249beb.tar.bz2 |
Rework FocusManager as FocusClient.
This allows us to have multiple focus system implementations.
http://crbug.com/162100
R=sky@chromium.org
Review URL: https://codereview.chromium.org/11299219
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
26 files changed, 186 insertions, 126 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index cac39fd..45f4da0 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -48,6 +48,9 @@ 'client/drag_drop_delegate.h', 'client/event_client.cc', 'client/event_client.h', + 'client/focus_change_observer.h', + 'client/focus_client.cc', + 'client/focus_client.h', 'client/screen_position_client.cc', 'client/screen_position_client.h', 'client/stacking_client.cc', @@ -69,7 +72,6 @@ 'env.cc', 'env.h', 'env_observer.h', - 'focus_change_observer.h', 'focus_manager.cc', 'focus_manager.h', 'layout_manager.cc', diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc index 6d255ec..eb620f0 100644 --- a/ui/aura/bench/bench_main.cc +++ b/ui/aura/bench/bench_main.cc @@ -308,8 +308,8 @@ int main(int argc, char** argv) { root_window.get(), new aura::client::DefaultCaptureClient(root_window.get())); - scoped_ptr<aura::FocusManager> focus_manager(new aura::FocusManager); - root_window->set_focus_manager(focus_manager.get()); + scoped_ptr<aura::client::FocusClient> focus_client(new aura::FocusManager); + aura::client::SetFocusClient(root_window.get(), focus_client.get()); // add layers ColoredLayer background(SK_ColorRED); @@ -353,7 +353,7 @@ int main(int argc, char** argv) { root_window->ShowRootWindow(); MessageLoopForUI::current()->Run(); - focus_manager.reset(); + focus_client.reset(); root_window.reset(); ui::CompositorTestSupport::Terminate(); diff --git a/ui/aura/focus_change_observer.h b/ui/aura/client/focus_change_observer.h index 2acf2d9b..217342d 100644 --- a/ui/aura/focus_change_observer.h +++ b/ui/aura/client/focus_change_observer.h @@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_AURA_FOCUS_CHANGE_OBSERVER_H_ -#define UI_AURA_FOCUS_CHANGE_OBSERVER_H_ +#ifndef UI_AURA_CLIENT_FOCUS_CHANGE_OBSERVER_H_ +#define UI_AURA_CLIENT_FOCUS_CHANGE_OBSERVER_H_ #include "ui/aura/aura_export.h" namespace aura { - class Window; +namespace client { +// TODO(beng): this interface will be OBSOLETE by FocusChangeEvent. class AURA_EXPORT FocusChangeObserver { public: // Called when |window| gains focus. @@ -20,6 +21,7 @@ class AURA_EXPORT FocusChangeObserver { virtual ~FocusChangeObserver() {} }; +} // namespace client } // namespace aura -#endif // UI_AURA_FOCUS_CHANGE_OBSERVER_H_ +#endif // UI_AURA_CLIENT_FOCUS_CHANGE_OBSERVER_H_ diff --git a/ui/aura/client/focus_client.cc b/ui/aura/client/focus_client.cc new file mode 100644 index 0000000..83ad1a9 --- /dev/null +++ b/ui/aura/client/focus_client.cc @@ -0,0 +1,33 @@ +// 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/aura/client/focus_client.h" + +#include "ui/aura/root_window.h" +#include "ui/aura/window_property.h" + +DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, aura::Window*) +DECLARE_WINDOW_PROPERTY_TYPE(aura::client::FocusClient*) + +namespace aura { +namespace client { + +DEFINE_WINDOW_PROPERTY_KEY(FocusClient*, kRootWindowFocusClientKey, NULL); + +void SetFocusClient(RootWindow* root_window, FocusClient* client) { + root_window->SetProperty(kRootWindowFocusClientKey, client); +} + +FocusClient* GetFocusClient(Window* window) { + return GetFocusClient(static_cast<const Window*>(window)); +} + +FocusClient* GetFocusClient(const Window* window) { + const RootWindow* root_window = window->GetRootWindow(); + return root_window ? + root_window->GetProperty(kRootWindowFocusClientKey) : NULL; +} + +} // namespace client +} // namespace aura diff --git a/ui/aura/client/focus_client.h b/ui/aura/client/focus_client.h new file mode 100644 index 0000000..6f5d00a --- /dev/null +++ b/ui/aura/client/focus_client.h @@ -0,0 +1,46 @@ +// 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_AURA_CLIENT_FOCUS_CLIENT_H_ +#define UI_AURA_CLIENT_FOCUS_CLIENT_H_ + +#include "ui/aura/aura_export.h" + +namespace ui { +class Event; +} + +namespace aura { +class RootWindow; +class Window; + +namespace client { +class FocusChangeObserver; + +// An interface implemented by an object that manages window focus. +class AURA_EXPORT FocusClient { + public: + virtual ~FocusClient() {} + + // TODO(beng): these methods will be OBSOLETE by FocusChangeEvent. + virtual void AddObserver(FocusChangeObserver* observer) = 0; + virtual void RemoveObserver(FocusChangeObserver* observer) = 0; + + // Focuses |window|. Passing NULL clears focus. + // TODO(beng): |event| may be obsolete. + virtual void FocusWindow(Window* window, const ui::Event* event) = 0; + + // Retrieves the focused window, or NULL if there is none. + virtual Window* GetFocusedWindow() = 0; +}; + +// Sets/Gets the focus client on the RootWindow. +AURA_EXPORT void SetFocusClient(RootWindow* root_window, FocusClient* client); +AURA_EXPORT FocusClient* GetFocusClient(Window* window); +AURA_EXPORT FocusClient* GetFocusClient(const Window* window); + +} // namespace clients +} // namespace aura + +#endif // UI_AURA_CLIENT_FOCUS_CLIENT_H_ diff --git a/ui/aura/focus_manager.cc b/ui/aura/focus_manager.cc index 04fd09b..2fcaa65 100644 --- a/ui/aura/focus_manager.cc +++ b/ui/aura/focus_manager.cc @@ -5,26 +5,32 @@ #include "ui/aura/focus_manager.h" #include "ui/aura/client/activation_client.h" -#include "ui/aura/focus_change_observer.h" +#include "ui/aura/client/focus_change_observer.h" #include "ui/aura/window_delegate.h" namespace aura { + +//////////////////////////////////////////////////////////////////////////////// +// FocusManager, public: + FocusManager::FocusManager() : focused_window_(NULL) { } FocusManager::~FocusManager() { } -void FocusManager::AddObserver(FocusChangeObserver* observer) { +//////////////////////////////////////////////////////////////////////////////// +// FocusManager, client::FocusClient implementation: + +void FocusManager::AddObserver(client::FocusChangeObserver* observer) { observers_.AddObserver(observer); } -void FocusManager::RemoveObserver(FocusChangeObserver* observer) { +void FocusManager::RemoveObserver(client::FocusChangeObserver* observer) { observers_.RemoveObserver(observer); } -void FocusManager::SetFocusedWindow(Window* focused_window, - const ui::Event* event) { +void FocusManager::FocusWindow(Window* focused_window, const ui::Event* event) { if (focused_window == focused_window_) return; if (focused_window && !focused_window->CanFocus()) @@ -50,7 +56,7 @@ void FocusManager::SetFocusedWindow(Window* focused_window, if (focused_window_ && focused_window_->delegate()) focused_window_->delegate()->OnFocus(old_focused_window); if (focused_window_) { - FOR_EACH_OBSERVER(FocusChangeObserver, observers_, + FOR_EACH_OBSERVER(client::FocusChangeObserver, observers_, OnWindowFocused(focused_window)); } } @@ -59,8 +65,4 @@ Window* FocusManager::GetFocusedWindow() { return focused_window_; } -bool FocusManager::IsFocusedWindow(const Window* window) const { - return focused_window_ == window; -} - -} // namespace ash +} // namespace aura diff --git a/ui/aura/focus_manager.h b/ui/aura/focus_manager.h index 1e47eaf..1a0e6d3c 100644 --- a/ui/aura/focus_manager.h +++ b/ui/aura/focus_manager.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/observer_list.h" #include "ui/aura/aura_export.h" +#include "ui/aura/client/focus_client.h" namespace ui { class Event; @@ -15,36 +16,26 @@ class Event; namespace aura { -class FocusChangeObserver; class Window; // An interface implemented by the Desktop to expose the focused window and // allow for it to be changed. -class AURA_EXPORT FocusManager { +class AURA_EXPORT FocusManager : public client::FocusClient { public: FocusManager(); - ~FocusManager(); + virtual ~FocusManager(); - void AddObserver(FocusChangeObserver* observer); - void RemoveObserver(FocusChangeObserver* observer); - - // Sets the currently focused window. Before the currently focused window is - // changed, the previous focused window's delegate is sent a blur - // notification, and after it is changed the new focused window is sent a - // focused notification. Nothing happens if |window| and GetFocusedWindow() - // match. - void SetFocusedWindow(Window* window, const ui::Event* event); - - // Returns the currently focused window or NULL if there is none. - Window* GetFocusedWindow(); - - // Returns true if |window| is the focused window. - bool IsFocusedWindow(const Window* window) const; + private: + // Overridden from client::FocusClient: + virtual void AddObserver(client::FocusChangeObserver* observer) OVERRIDE; + virtual void RemoveObserver(client::FocusChangeObserver* observer) OVERRIDE; + virtual void FocusWindow(Window* window, const ui::Event* event) OVERRIDE; + virtual Window* GetFocusedWindow() OVERRIDE; protected: aura::Window* focused_window_; - ObserverList<FocusChangeObserver> observers_; + ObserverList<client::FocusChangeObserver> observers_; DISALLOW_COPY_AND_ASSIGN(FocusManager); }; diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index a19c7c5..8853bff 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -17,9 +17,9 @@ #include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/client/event_client.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window_host.h" #include "ui/aura/root_window_observer.h" #include "ui/aura/window.h" @@ -103,7 +103,6 @@ RootWindow::RootWindow(const CreateParams& params) mouse_moved_handler_(NULL), mouse_event_dispatch_target_(NULL), event_dispatch_target_(NULL), - focus_manager_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST( gesture_recognizer_(ui::GestureRecognizer::Create(this))), synthesize_mouse_move_(false), @@ -528,10 +527,6 @@ bool RootWindow::CanReceiveEvents() const { return IsVisible(); } -FocusManager* RootWindow::GetFocusManager() { - return focus_manager_; -} - //////////////////////////////////////////////////////////////////////////////// // RootWindow, overridden from aura::client::CaptureDelegate: @@ -692,8 +687,8 @@ void RootWindow::OnWindowHidden(Window* invisible, // the exception for the case where the focus managers change (otherwise a // focus manager might dereference a deleted root window). if (reason != WINDOW_MOVING || - (new_root->GetFocusManager() != focus_manager_)) { - Window* focused_window = focus_manager_->GetFocusedWindow(); + (client::GetFocusClient(new_root) != client::GetFocusClient(this))) { + Window* focused_window = client::GetFocusClient(this)->GetFocusedWindow(); if (invisible->Contains(focused_window)) { Window* focus_to = invisible->transient_parent(); if (focus_to) { @@ -714,7 +709,7 @@ void RootWindow::OnWindowHidden(Window* invisible, NULL)))) { focus_to = NULL; } - GetFocusManager()->SetFocusedWindow(focus_to, NULL); + client::GetFocusClient(this)->FocusWindow(focus_to, NULL); } } @@ -793,9 +788,9 @@ bool RootWindow::OnHostKeyEvent(ui::KeyEvent* event) { if (event->key_code() == ui::VKEY_UNKNOWN) return false; client::EventClient* client = client::GetEventClient(GetRootWindow()); - Window* focused_window = focus_manager_->GetFocusedWindow(); + Window* focused_window = client::GetFocusClient(this)->GetFocusedWindow(); if (client && !client->CanProcessEventsWithinSubtree(focused_window)) { - GetFocusManager()->SetFocusedWindow(NULL, NULL); + client::GetFocusClient(this)->FocusWindow(NULL, NULL); return false; } return ProcessKeyEvent(focused_window, event); diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 86c15c9..67498cf 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -47,7 +47,6 @@ class ViewProp; namespace aura { -class FocusManager; class RootWindow; class RootWindowHost; class RootWindowObserver; @@ -85,10 +84,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, gfx::NativeCursor last_cursor() const { return last_cursor_; } Window* mouse_pressed_handler() { return mouse_pressed_handler_; } - void set_focus_manager(FocusManager* focus_manager) { - focus_manager_ = focus_manager; - } - // Initializes the root window. void Init(); @@ -254,7 +249,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, // Overridden from Window: virtual bool CanFocus() const OVERRIDE; virtual bool CanReceiveEvents() const OVERRIDE; - virtual FocusManager* GetFocusManager() OVERRIDE; // Overridden from aura::client::CaptureDelegate: virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE; @@ -386,7 +380,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, Window* mouse_moved_handler_; Window* mouse_event_dispatch_target_; Window* event_dispatch_target_; - FocusManager* focus_manager_; // The gesture_recognizer_ for this. scoped_ptr<ui::GestureRecognizer> gesture_recognizer_; diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index ec35d99..fdf93f0 100644 --- a/ui/aura/root_window_unittest.cc +++ b/ui/aura/root_window_unittest.cc @@ -102,6 +102,10 @@ Window* CreateWindow(int id, Window* parent, WindowDelegate* delegate) { return window; } +bool IsFocusedWindow(aura::Window* window) { + return client::GetFocusClient(window)->GetFocusedWindow() == window; +} + } // namespace typedef test::AuraTestBase RootWindowTest; @@ -333,21 +337,21 @@ TEST_F(RootWindowTest, CanProcessEventsWithinSubtree) { client.GetLockWindow())); w1->Focus(); - EXPECT_TRUE(w1->GetFocusManager()->IsFocusedWindow(w1)); + EXPECT_TRUE(IsFocusedWindow(w1)); client.Lock(); // Since we're locked, the attempt to focus w2 will be ignored. w2->Focus(); - EXPECT_TRUE(w1->GetFocusManager()->IsFocusedWindow(w1)); - EXPECT_FALSE(w1->GetFocusManager()->IsFocusedWindow(w2)); + EXPECT_TRUE(IsFocusedWindow(w1)); + EXPECT_FALSE(IsFocusedWindow(w2)); { // Attempting to send a key event to w1 (not in the lock container) should // cause focus to be reset. test::EventGenerator generator(root_window()); generator.PressKey(ui::VKEY_SPACE, 0); - EXPECT_EQ(NULL, w1->GetFocusManager()->GetFocusedWindow()); + EXPECT_EQ(NULL, client::GetFocusClient(w1)->GetFocusedWindow()); } { @@ -702,7 +706,7 @@ TEST_F(RootWindowTest, DeleteWindowDuringDispatch) { WindowTracker tracker; DeletingEventFilter* w1_filter = new DeletingEventFilter; w1->SetEventFilter(w1_filter); - w1->GetFocusManager()->SetFocusedWindow(w11, NULL); + client::GetFocusClient(w1.get())->FocusWindow(w11, NULL); test::EventGenerator generator(root_window(), w11); diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc index d6db502..343afef 100644 --- a/ui/aura/test/aura_test_helper.cc +++ b/ui/aura/test/aura_test_helper.cc @@ -8,6 +8,7 @@ #include "base/run_loop.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/default_capture_client.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/env.h" #include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" @@ -42,21 +43,21 @@ AuraTestHelper::~AuraTestHelper() { void AuraTestHelper::SetUp() { setup_called_ = true; - aura::Env::GetInstance(); + Env::GetInstance(); test_screen_.reset(new TestScreen()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); - focus_manager_.reset(new FocusManager); - root_window_->set_focus_manager(focus_manager_.get()); + focus_client_.reset(new FocusManager); + client::SetFocusClient(root_window_.get(), focus_client_.get()); stacking_client_.reset(new TestStackingClient(root_window_.get())); test_activation_client_.reset( new test::TestActivationClient(root_window_.get())); capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); test_input_method_.reset(new ui::test::DummyInputMethod); root_window_->SetProperty( - aura::client::kRootWindowInputMethodKey, + client::kRootWindowInputMethodKey, test_input_method_.get()); root_window_->Show(); @@ -70,11 +71,11 @@ void AuraTestHelper::TearDown() { stacking_client_.reset(); test_activation_client_.reset(); capture_client_.reset(); - focus_manager_.reset(); + focus_client_.reset(); root_window_.reset(); test_screen_.reset(); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); - aura::Env::DeleteInstance(); + Env::DeleteInstance(); } void AuraTestHelper::RunAllPendingInMessageLoop() { diff --git a/ui/aura/test/aura_test_helper.h b/ui/aura/test/aura_test_helper.h index 8b8e007..5f47255 100644 --- a/ui/aura/test/aura_test_helper.h +++ b/ui/aura/test/aura_test_helper.h @@ -15,11 +15,11 @@ class InputMethod; } namespace aura { -class FocusManager; class RootWindow; class TestScreen; namespace client { class DefaultCaptureClient; +class FocusClient; } namespace test { class TestActivationClient; @@ -36,8 +36,8 @@ class AuraTestHelper { // Creates and initializes (shows and sizes) the RootWindow for use in tests. void SetUp(); - // Clean up objects that are created for tests. This also delete - // aura::Env object. + // Clean up objects that are created for tests. This also deletes the Env + // object. void TearDown(); // Flushes message loop. @@ -55,8 +55,8 @@ class AuraTestHelper { scoped_ptr<TestActivationClient> test_activation_client_; scoped_ptr<client::DefaultCaptureClient> capture_client_; scoped_ptr<ui::InputMethod> test_input_method_; - scoped_ptr<FocusManager> focus_manager_; - scoped_ptr<aura::TestScreen> test_screen_; + scoped_ptr<client::FocusClient> focus_client_; + scoped_ptr<TestScreen> test_screen_; DISALLOW_COPY_AND_ASSIGN(AuraTestHelper); }; diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 1a2df24..5bd9429 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -525,18 +525,20 @@ Window* Window::GetToplevelWindow() { } void Window::Focus() { - DCHECK(GetFocusManager()); - GetFocusManager()->SetFocusedWindow(this, NULL); + client::FocusClient* client = client::GetFocusClient(this); + DCHECK(client); + client->FocusWindow(this, NULL); } void Window::Blur() { - DCHECK(GetFocusManager()); - GetFocusManager()->SetFocusedWindow(NULL, NULL); + client::FocusClient* client = client::GetFocusClient(this); + DCHECK(client); + client->FocusWindow(NULL, NULL); } bool Window::HasFocus() const { - const FocusManager* focus_manager = GetFocusManager(); - return focus_manager ? focus_manager->IsFocusedWindow(this) : false; + client::FocusClient* client = client::GetFocusClient(this); + return client && client->GetFocusedWindow() == this; } bool Window::CanFocus() const { @@ -565,15 +567,6 @@ bool Window::CanReceiveEvents() const { return parent_ && IsVisible() && parent_->CanReceiveEvents(); } -FocusManager* Window::GetFocusManager() { - return const_cast<FocusManager*>( - static_cast<const Window*>(this)->GetFocusManager()); -} - -const FocusManager* Window::GetFocusManager() const { - return parent_ ? parent_->GetFocusManager() : NULL; -} - void Window::SetCapture() { if (!IsVisible()) return; diff --git a/ui/aura/window.h b/ui/aura/window.h index ccfdc48..985391d 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -40,7 +40,6 @@ class Texture; namespace aura { -class FocusManager; class LayoutManager; class RootWindow; class WindowDelegate; @@ -307,11 +306,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate, // Returns true if the Window can receive events. virtual bool CanReceiveEvents() const; - // Returns the FocusManager for the Window, which may be attached to a parent - // Window. Can return NULL if the Window has no FocusManager. - virtual FocusManager* GetFocusManager(); - virtual const FocusManager* GetFocusManager() const; - // Does a capture on the window. This does nothing if the window isn't showing // (VISIBILITY_SHOWN) or isn't contained in a valid window hierarchy. void SetCapture(); diff --git a/ui/views/controls/native/native_view_host_aura.cc b/ui/views/controls/native/native_view_host_aura.cc index 26c3285..61a6638 100644 --- a/ui/views/controls/native/native_view_host_aura.cc +++ b/ui/views/controls/native/native_view_host_aura.cc @@ -81,8 +81,9 @@ void NativeViewHostAura::HideWidget() { void NativeViewHostAura::SetFocus() { aura::Window* window = host_->native_view(); - if (window->GetFocusManager()) - window->GetFocusManager()->SetFocusedWindow(window, NULL); + aura::client::FocusClient* client = aura::client::GetFocusClient(window); + if (client) + client->FocusWindow(window, NULL); } gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() { diff --git a/ui/views/focus/focus_manager_unittest.cc b/ui/views/focus/focus_manager_unittest.cc index 509bd87..5c5dcf7 100644 --- a/ui/views/focus/focus_manager_unittest.cc +++ b/ui/views/focus/focus_manager_unittest.cc @@ -17,7 +17,7 @@ #include "ui/views/widget/widget.h" #if defined(USE_AURA) -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/window.h" #else #include "ui/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" @@ -28,7 +28,7 @@ namespace views { void FocusNativeView(gfx::NativeView view) { #if defined(USE_AURA) - view->GetFocusManager()->SetFocusedWindow(view, NULL); + aura::client::GetFocusClient(view)->FocusWindow(view, NULL); #elif defined(OS_WIN) SetFocus(view); #else diff --git a/ui/views/widget/desktop_aura/desktop_activation_client.cc b/ui/views/widget/desktop_aura/desktop_activation_client.cc index 0714490..b529ebe 100644 --- a/ui/views/widget/desktop_aura/desktop_activation_client.cc +++ b/ui/views/widget/desktop_aura/desktop_activation_client.cc @@ -8,7 +8,7 @@ #include "base/compiler_specific.h" #include "ui/aura/client/activation_delegate.h" #include "ui/aura/client/activation_change_observer.h" -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" @@ -19,12 +19,12 @@ DesktopActivationClient::DesktopActivationClient(aura::RootWindow* root_window) current_active_(NULL), updating_activation_(false), ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) { - root_window->GetFocusManager()->AddObserver(this); + aura::client::GetFocusClient(root_window_)->AddObserver(this); aura::client::SetActivationClient(root_window_, this); } DesktopActivationClient::~DesktopActivationClient() { - root_window_->GetFocusManager()->RemoveObserver(this); + aura::client::GetFocusClient(root_window_)->RemoveObserver(this); aura::client::SetActivationClient(root_window_, NULL); } @@ -54,8 +54,9 @@ void DesktopActivationClient::ActivateWindow(aura::Window* window) { // Switch internal focus before we change the activation. Will probably cause // recursion. if (window && - !window->Contains(window->GetFocusManager()->GetFocusedWindow())) { - window->GetFocusManager()->SetFocusedWindow(window, NULL); + !window->Contains(aura::client::GetFocusClient(window)-> + GetFocusedWindow())) { + aura::client::GetFocusClient(window)->FocusWindow(window, NULL); } aura::Window* old_active = current_active_; diff --git a/ui/views/widget/desktop_aura/desktop_activation_client.h b/ui/views/widget/desktop_aura/desktop_activation_client.h index b63f225..9554ef6 100644 --- a/ui/views/widget/desktop_aura/desktop_activation_client.h +++ b/ui/views/widget/desktop_aura/desktop_activation_client.h @@ -9,8 +9,8 @@ #include "base/observer_list.h" #include "base/scoped_observer.h" #include "ui/aura/client/activation_client.h" +#include "ui/aura/client/focus_change_observer.h" #include "ui/aura/env_observer.h" -#include "ui/aura/focus_change_observer.h" #include "ui/aura/root_window_observer.h" #include "ui/aura/window_observer.h" #include "ui/views/views_export.h" @@ -32,7 +32,7 @@ namespace views { class VIEWS_EXPORT DesktopActivationClient : public aura::client::ActivationClient, public aura::WindowObserver, - public aura::FocusChangeObserver { + public aura::client::FocusChangeObserver { public: explicit DesktopActivationClient(aura::RootWindow* root_window); virtual ~DesktopActivationClient(); @@ -52,7 +52,7 @@ class VIEWS_EXPORT DesktopActivationClient // Overridden from aura::WindowObserver: virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; - // Overridden from aura::FocusChangeObserver: + // Overridden from aura::client::FocusChangeObserver: virtual void OnWindowFocused(aura::Window* window) OVERRIDE; private: diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 0ef8970..a659a95 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -451,7 +451,7 @@ void DesktopNativeWidgetAura::OnBlur() { GetWidget()->GetFocusManager()->StoreFocusedView(); desktop_root_window_host_->OnNativeWidgetBlur(); native_widget_delegate_->OnNativeBlur( - window_->GetFocusManager()->GetFocusedWindow()); + aura::client::GetFocusClient(window_)->GetFocusedWindow()); } gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc index ee77cc1..2411cca 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc @@ -214,8 +214,8 @@ aura::RootWindow* DesktopRootWindowHostLinux::InitRootWindow( // messages to us. X11DesktopHandler::get(); - focus_manager_.reset(new aura::FocusManager); - root_window_->set_focus_manager(focus_manager_.get()); + focus_client_.reset(new aura::FocusManager); + aura::client::SetFocusClient(root_window_.get(), focus_client_.get()); activation_client_.reset(new DesktopActivationClient(root_window_)); @@ -250,7 +250,7 @@ aura::RootWindow* DesktopRootWindowHostLinux::InitRootWindow( aura::client::SetWindowMoveClient(root_window_, x11_window_move_client_.get()); - focus_manager_->SetFocusedWindow(content_window_, NULL); + focus_client_->FocusWindow(content_window_, NULL); return root_window_; } @@ -532,8 +532,9 @@ void DesktopRootWindowHostLinux::ClearNativeFocus() { // of focus changes into views. if (content_window_ && content_window_->GetFocusManager() && content_window_->Contains( - content_window_->GetFocusManager()->GetFocusedWindow())) { - content_window_->GetFocusManager()->SetFocusedWindow(content_window_, NULL); + aura::client::GetFocusClient(content_window_)->GetFocusedWindow())) { + aura::client::GetFocusClient(content_window_)->FocusWindow( + content_window_, NULL); } } diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h index 3f705f2..e8748f5 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h @@ -22,9 +22,9 @@ #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" namespace aura { -class FocusManager; namespace client { class DefaultCaptureClient; +class FocusClient; class ScreenPositionClient; } } @@ -209,7 +209,7 @@ class VIEWS_EXPORT DesktopRootWindowHostLinux // aura:: objects that we own. scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; - scoped_ptr<aura::FocusManager> focus_manager_; + scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<DesktopActivationClient> activation_client_; scoped_ptr<DesktopCursorClient> cursor_client_; scoped_ptr<DesktopDispatcherClient> dispatcher_client_; diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index b046d77..829b1a1 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -117,8 +117,8 @@ aura::RootWindow* DesktopRootWindowHostWin::Init( capture_client_.reset(new aura::client::DefaultCaptureClient(root_window_)); aura::client::SetCaptureClient(root_window_, capture_client_.get()); - focus_manager_.reset(new aura::FocusManager); - root_window_->set_focus_manager(focus_manager_.get()); + focus_client_.reset(new aura::FocusManager); + aura::client::SetFocusClient(root_window_, focus_client_.get()); activation_client_.reset(new DesktopActivationClient(root_window_)); @@ -144,7 +144,7 @@ aura::RootWindow* DesktopRootWindowHostWin::Init( input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_); root_window_event_filter_->AddHandler(input_method_filter_.get()); - focus_manager_->SetFocusedWindow(content_window_, NULL); + focus_client_->FocusWindow(content_window_, NULL); root_window_->SetProperty(kContentWindowForRootWindow, content_window_); ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_)); diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h index b9cf037..927123b 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h @@ -11,9 +11,9 @@ #include "ui/views/win/hwnd_message_handler_delegate.h" namespace aura { -class FocusManager; namespace client { class DefaultCaptureClient; +class FocusClient; class ScreenPositionClient; } } @@ -210,7 +210,7 @@ class VIEWS_EXPORT DesktopRootWindowHostWin scoped_ptr<HWNDMessageHandler> message_handler_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; scoped_ptr<DesktopDispatcherClient> dispatcher_client_; - scoped_ptr<aura::FocusManager> focus_manager_; + scoped_ptr<aura::client::FocusClient> focus_client_; // Depends on focus_manager_. scoped_ptr<DesktopActivationClient> activation_client_; scoped_ptr<corewm::InputMethodEventFilter> input_method_filter_; diff --git a/ui/views/widget/desktop_aura/desktop_stacking_client.cc b/ui/views/widget/desktop_aura/desktop_stacking_client.cc index 464549a..46ffe9c 100644 --- a/ui/views/widget/desktop_aura/desktop_stacking_client.cc +++ b/ui/views/widget/desktop_aura/desktop_stacking_client.cc @@ -37,12 +37,12 @@ aura::Window* DesktopStackingClient::GetDefaultParent(aura::Window* context, } void DesktopStackingClient::CreateNULLParent() { - focus_manager_.reset(new aura::FocusManager); + focus_client_.reset(new aura::FocusManager); null_parent_.reset(new aura::RootWindow( aura::RootWindow::CreateParams(gfx::Rect(100, 100)))); null_parent_->Init(); - null_parent_->set_focus_manager(focus_manager_.get()); + aura::client::SetFocusClient(null_parent_.get(), focus_client_.get()); activation_client_.reset(new DesktopActivationClient(null_parent_.get())); diff --git a/ui/views/widget/desktop_aura/desktop_stacking_client.h b/ui/views/widget/desktop_aura/desktop_stacking_client.h index 239064a..56abc60 100644 --- a/ui/views/widget/desktop_aura/desktop_stacking_client.h +++ b/ui/views/widget/desktop_aura/desktop_stacking_client.h @@ -13,11 +13,11 @@ #include "ui/views/views_export.h" namespace aura { -class FocusManager; class RootWindow; class Window; namespace client { class DefaultCaptureClient; +class FocusClient; } } @@ -48,7 +48,7 @@ class VIEWS_EXPORT DesktopStackingClient : public aura::client::StackingClient { // All the member variables below are necessary for the NULL parent root // window to function. - scoped_ptr<aura::FocusManager> focus_manager_; + scoped_ptr<aura::client::FocusClient> focus_client_; // Depends on focus_manager_. scoped_ptr<DesktopActivationClient> activation_client_; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 995e9b9..ec9cd7c 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -581,9 +581,9 @@ void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { } void NativeWidgetAura::ClearNativeFocus() { - if (window_ && window_->GetFocusManager() && - window_->Contains(window_->GetFocusManager()->GetFocusedWindow())) - window_->GetFocusManager()->SetFocusedWindow(window_, NULL); + aura::client::FocusClient* client = aura::client::GetFocusClient(window_); + if (window_ && client && window_->Contains(client->GetFocusedWindow())) + client->FocusWindow(window_, NULL); } gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { @@ -680,7 +680,8 @@ void NativeWidgetAura::OnBlur() { else DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); - delegate_->OnNativeBlur(window_->GetFocusManager()->GetFocusedWindow()); + delegate_->OnNativeBlur( + aura::client::GetFocusClient(window_)->GetFocusedWindow()); } gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |