diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 05:19:32 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 05:19:32 +0000 |
commit | 056ce05075d1eccc591007b553acf1a77c9984da (patch) | |
tree | 0120aab5ede38d13baf801b95b18f2c073657721 | |
parent | 21d32ecf459324e55d24a84a4fc89d9166fa4fc8 (diff) | |
download | chromium_src-056ce05075d1eccc591007b553acf1a77c9984da.zip chromium_src-056ce05075d1eccc591007b553acf1a77c9984da.tar.gz chromium_src-056ce05075d1eccc591007b553acf1a77c9984da.tar.bz2 |
Rename RootWindow -> WindowEventDispatcher.
http://crbug.com/308843
R=sky@chromium.org
Review URL: https://codereview.chromium.org/172743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252501 0039d316-1c4b-4281-b951-d872f2087c98
101 files changed, 943 insertions, 913 deletions
diff --git a/apps/shell/browser/shell_browser_main_parts.cc b/apps/shell/browser/shell_browser_main_parts.cc index 6532351..924eb39 100644 --- a/apps/shell/browser/shell_browser_main_parts.cc +++ b/apps/shell/browser/shell_browser_main_parts.cc @@ -136,7 +136,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { // TODO(jamescook): For demo purposes create a window with a WebView just // to ensure that the content module is properly initialized. webview_window_.reset(CreateWebViewWindow(browser_context_.get(), - wm_test_helper_->root_window()->window())); + wm_test_helper_->dispatcher()->window())); webview_window_->Show(); } } @@ -162,7 +162,7 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() { } void ShellBrowserMainParts::OnWindowTreeHostCloseRequested( - const aura::RootWindow* root) { + const aura::WindowEventDispatcher* dispatcher) { base::MessageLoop::current()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } @@ -176,16 +176,16 @@ void ShellBrowserMainParts::CreateRootWindow() { // Set up basic pieces of views::corewm. wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); // Ensure the X window gets mapped. - wm_test_helper_->root_window()->host()->Show(); + wm_test_helper_->dispatcher()->host()->Show(); // Watch for the user clicking the close box. - wm_test_helper_->root_window()->AddRootWindowObserver(this); + wm_test_helper_->dispatcher()->AddRootWindowObserver(this); } void ShellBrowserMainParts::DestroyRootWindow() { // We should close widget before destroying root window. webview_window_.reset(); - wm_test_helper_->root_window()->RemoveRootWindowObserver(this); - wm_test_helper_->root_window()->PrepareForShutdown(); + wm_test_helper_->dispatcher()->RemoveRootWindowObserver(this); + wm_test_helper_->dispatcher()->PrepareForShutdown(); wm_test_helper_.reset(); ui::ShutdownInputMethodForTesting(); } @@ -193,7 +193,7 @@ void ShellBrowserMainParts::DestroyRootWindow() { void ShellBrowserMainParts::CreateViewsDelegate() { DCHECK(!views::ViewsDelegate::views_delegate); views::ViewsDelegate::views_delegate = - new ShellViewsDelegate(wm_test_helper_->root_window()->window()); + new ShellViewsDelegate(wm_test_helper_->dispatcher()->window()); } void ShellBrowserMainParts::DestroyViewsDelegate() { diff --git a/apps/shell/browser/shell_browser_main_parts.h b/apps/shell/browser/shell_browser_main_parts.h index 3a97ba7..f9fae2e 100644 --- a/apps/shell/browser/shell_browser_main_parts.h +++ b/apps/shell/browser/shell_browser_main_parts.h @@ -69,8 +69,8 @@ class ShellBrowserMainParts : public content::BrowserMainParts, virtual void PostMainMessageLoopRun() OVERRIDE; // aura::RootWindowObserver overrides: - virtual void OnWindowTreeHostCloseRequested(const aura::RootWindow* root) - OVERRIDE; + virtual void OnWindowTreeHostCloseRequested( + const aura::WindowEventDispatcher* dispatcher) OVERRIDE; private: // Creates the window that hosts the apps. diff --git a/ash/desktop_background/wallpaper_resizer_unittest.cc b/ash/desktop_background/wallpaper_resizer_unittest.cc index 7ff0435..12adaf3 100644 --- a/ash/desktop_background/wallpaper_resizer_unittest.cc +++ b/ash/desktop_background/wallpaper_resizer_unittest.cc @@ -10,7 +10,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/image/image_skia_rep.h" -using aura::RootWindow; using aura::Window; namespace { diff --git a/ash/display/cursor_window_controller.cc b/ash/display/cursor_window_controller.cc index c931414..4e20022 100644 --- a/ash/display/cursor_window_controller.cc +++ b/ash/display/cursor_window_controller.cc @@ -120,9 +120,9 @@ void CursorWindowController::UpdateContainer() { if (is_cursor_compositing_enabled_) { SetDisplay(display_); } else { - aura::RootWindow* mirror_root_window = Shell::GetInstance()-> - display_controller()->mirror_window_controller()->root_window(); - SetContainer(mirror_root_window ? mirror_root_window->window() : NULL); + aura::WindowEventDispatcher* mirror_dispatcher = Shell::GetInstance()-> + display_controller()->mirror_window_controller()->dispatcher(); + SetContainer(mirror_dispatcher ? mirror_dispatcher->window() : NULL); } } diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index 4099c8d..bb78558 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -77,7 +77,7 @@ internal::DisplayManager* GetDisplayManager() { return Shell::GetInstance()->display_manager(); } -void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, +void SetDisplayPropertiesOnHostWindow(aura::WindowEventDispatcher* dispatcher, const gfx::Display& display) { internal::DisplayInfo info = GetDisplayManager()->GetDisplayInfo(display.id()); @@ -110,7 +110,7 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, } int internal = display.IsInternal() ? 1 : 0; - gfx::AcceleratedWidget xwindow = root->host()->GetAcceleratedWidget(); + gfx::AcceleratedWidget xwindow = dispatcher->host()->GetAcceleratedWidget(); ui::SetIntProperty(xwindow, kInternalProp, kCARDINAL, internal); ui::SetIntProperty(xwindow, kRotationProp, kCARDINAL, xrandr_rotation); ui::SetIntProperty(xwindow, @@ -119,15 +119,17 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, 100 * display.device_scale_factor()); #endif scoped_ptr<aura::RootWindowTransformer> transformer( - internal::CreateRootWindowTransformerForDisplay(root->window(), display)); - root->host()->SetRootWindowTransformer(transformer.Pass()); + internal::CreateRootWindowTransformerForDisplay(dispatcher->window(), + display)); + dispatcher->host()->SetRootWindowTransformer(transformer.Pass()); internal::DisplayMode mode; if (GetDisplayManager()->GetSelectedModeForDisplayId(display.id(), &mode) && mode.refresh_rate > 0.0f) { - root->host()->compositor()->vsync_manager()->SetAuthoritativeVSyncInterval( - base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / - mode.refresh_rate)); + dispatcher->host()->compositor()->vsync_manager()-> + SetAuthoritativeVSyncInterval( + base::TimeDelta::FromMicroseconds( + base::Time::kMicrosecondsPerSecond / mode.refresh_rate)); } } @@ -286,8 +288,9 @@ void DisplayController::InitSecondaryDisplays() { for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { const gfx::Display& display = display_manager->GetDisplayAt(i); if (primary_display_id != display.id()) { - aura::RootWindow* root = AddRootWindowForDisplay(display); - internal::RootWindowController::CreateForSecondaryDisplay(root); + aura::WindowEventDispatcher* dispatcher = + AddRootWindowForDisplay(display); + internal::RootWindowController::CreateForSecondaryDisplay(dispatcher); } } UpdateHostWindowNames(); @@ -565,8 +568,9 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) { if (primary_display_id == gfx::Display::kInvalidDisplayID) primary_display_id = display.id(); DCHECK(!root_windows_.empty()); - aura::RootWindow* root = AddRootWindowForDisplay(display); - internal::RootWindowController::CreateForSecondaryDisplay(root); + aura::WindowEventDispatcher* dispatcher = + AddRootWindowForDisplay(display); + internal::RootWindowController::CreateForSecondaryDisplay(dispatcher); } } @@ -614,14 +618,15 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) { base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); } -void DisplayController::OnWindowTreeHostResized(const aura::RootWindow* root) { +void DisplayController::OnWindowTreeHostResized( + const aura::WindowEventDispatcher* dispatcher) { gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( - const_cast<aura::Window*>(root->window())); + const_cast<aura::Window*>(dispatcher->window())); internal::DisplayManager* display_manager = GetDisplayManager(); if (display_manager->UpdateDisplayBounds( display.id(), - root->host()->GetBounds())) { + dispatcher->host()->GetBounds())) { mirror_window_controller_->UpdateWindow(); cursor_window_controller_->UpdateContainer(); } @@ -698,37 +703,38 @@ void DisplayController::PostDisplayConfigurationChange() { EnsurePointerInDisplays(); } -aura::RootWindow* DisplayController::AddRootWindowForDisplay( +aura::WindowEventDispatcher* DisplayController::AddRootWindowForDisplay( const gfx::Display& display) { - static int root_window_count = 0; + static int dispatcher_count = 0; const internal::DisplayInfo& display_info = GetDisplayManager()->GetDisplayInfo(display.id()); const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); - aura::RootWindow::CreateParams params(bounds_in_native); + aura::WindowEventDispatcher::CreateParams params(bounds_in_native); params.host = Shell::GetInstance()->window_tree_host_factory()-> CreateWindowTreeHost(bounds_in_native); - aura::RootWindow* root_window = new aura::RootWindow(params); - root_window->window()->SetName( - base::StringPrintf("RootWindow-%d", root_window_count++)); - root_window->host()->compositor()->SetBackgroundColor(SK_ColorBLACK); + aura::WindowEventDispatcher* dispatcher = + new aura::WindowEventDispatcher(params); + dispatcher->window()->SetName( + base::StringPrintf("RootWindow-%d", dispatcher_count++)); + dispatcher->host()->compositor()->SetBackgroundColor(SK_ColorBLACK); // No need to remove RootWindowObserver because // the DisplayController object outlives RootWindow objects. - root_window->AddRootWindowObserver(this); - internal::InitRootWindowSettings(root_window->window())->display_id = + dispatcher->AddRootWindowObserver(this); + internal::InitRootWindowSettings(dispatcher->window())->display_id = display.id(); - root_window->host()->InitHost(); + dispatcher->host()->InitHost(); - root_windows_[display.id()] = root_window->window(); - SetDisplayPropertiesOnHostWindow(root_window, display); + root_windows_[display.id()] = dispatcher->window(); + SetDisplayPropertiesOnHostWindow(dispatcher, display); #if defined(OS_CHROMEOS) static bool force_constrain_pointer_to_root = CommandLine::ForCurrentProcess()->HasSwitch( switches::kAshConstrainPointerToRoot); if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root) - root_window->host()->ConfineCursorToRootWindow(); + dispatcher->host()->ConfineCursorToRootWindow(); #endif - return root_window; + return dispatcher; } void DisplayController::OnFadeOutForSwapDisplayFinished() { diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h index c44ccd1..dfc432e 100644 --- a/ash/display/display_controller.h +++ b/ash/display/display_controller.h @@ -23,7 +23,7 @@ namespace aura { class Display; -class RootWindow; +class WindowEventDispatcher; } namespace base { @@ -150,7 +150,8 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; // RootWindowObserver overrides: - virtual void OnWindowTreeHostResized(const aura::RootWindow* root) OVERRIDE; + virtual void OnWindowTreeHostResized( + const aura::WindowEventDispatcher* root) OVERRIDE; // aura::DisplayManager::Delegate overrides: virtual void CreateOrUpdateNonDesktopDisplay( @@ -167,7 +168,8 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, // Creates a root window for |display| and stores it in the |root_windows_| // map. - aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display); + aura::WindowEventDispatcher* AddRootWindowForDisplay( + const gfx::Display& display); void OnFadeOutForSwapDisplayFinished(); diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc index 9b85654..cb9b3464 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/display_controller_unittest.cc @@ -289,9 +289,9 @@ void GetPrimaryAndSeconary(aura::Window** primary, *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0]; } -std::string GetXWindowName(aura::RootWindow* window) { +std::string GetXWindowName(aura::WindowTreeHost* host) { char* name = NULL; - XFetchName(gfx::GetXDisplay(), window->host()->GetAcceleratedWidget(), &name); + XFetchName(gfx::GetXDisplay(), host->GetAcceleratedWidget(), &name); std::string ret(name); XFree(name); return ret; @@ -1311,26 +1311,26 @@ TEST_F(DisplayControllerTest, DockToSingle) { #if defined(USE_X11) TEST_F(DisplayControllerTest, XWidowNameForRootWindow) { EXPECT_EQ("aura_root_0", GetXWindowName( - Shell::GetPrimaryRootWindow()->GetDispatcher())); + Shell::GetPrimaryRootWindow()->GetDispatcher()->host())); // Multiple display. UpdateDisplay("200x200,300x300"); aura::Window* primary, *secondary; GetPrimaryAndSeconary(&primary, &secondary); - EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher())); - EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher())); + EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher()->host())); + EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()->host())); // Swap primary. primary = secondary = NULL; Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); GetPrimaryAndSeconary(&primary, &secondary); - EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher())); - EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher())); + EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher()->host())); + EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()->host())); // Switching back to single display. UpdateDisplay("300x400"); EXPECT_EQ("aura_root_0", GetXWindowName( - Shell::GetPrimaryRootWindow()->GetDispatcher())); + Shell::GetPrimaryRootWindow()->GetDispatcher()->host())); } #endif diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index 5b43b1b..93fa285 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -1015,13 +1015,13 @@ class TestDisplayObserver : public gfx::DisplayObserver { virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { // Mirror window should already be delete before restoring // the external dispay. - EXPECT_FALSE(test_api.GetRootWindow()); + EXPECT_FALSE(test_api.GetDispatcher()); changed_ = true; } virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { // Mirror window should not be created until the external display // is removed. - EXPECT_FALSE(test_api.GetRootWindow()); + EXPECT_FALSE(test_api.GetDispatcher()); changed_ = true; } @@ -1045,7 +1045,7 @@ TEST_F(DisplayManagerTest, SoftwareMirroring) { UpdateDisplay("300x400,400x500"); test::MirrorWindowTestApi test_api; - EXPECT_EQ(NULL, test_api.GetRootWindow()); + EXPECT_EQ(NULL, test_api.GetDispatcher()); TestDisplayObserver display_observer; Shell::GetScreen()->AddObserver(&display_observer); @@ -1058,14 +1058,14 @@ TEST_F(DisplayManagerTest, SoftwareMirroring) { EXPECT_EQ("0,0 300x400", Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("400x500", - test_api.GetRootWindow()->host()->GetBounds().size().ToString()); + test_api.GetDispatcher()->host()->GetBounds().size().ToString()); EXPECT_EQ("300x400", - test_api.GetRootWindow()->window()->bounds().size().ToString()); + test_api.GetDispatcher()->window()->bounds().size().ToString()); EXPECT_TRUE(display_manager->IsMirrored()); display_manager->SetMirrorMode(false); EXPECT_TRUE(display_observer.changed_and_reset()); - EXPECT_EQ(NULL, test_api.GetRootWindow()); + EXPECT_EQ(NULL, test_api.GetDispatcher()); EXPECT_EQ(2U, display_manager->GetNumDisplays()); EXPECT_FALSE(display_manager->IsMirrored()); @@ -1077,28 +1077,28 @@ TEST_F(DisplayManagerTest, SoftwareMirroring) { UpdateDisplay("300x400@0.5,400x500"); EXPECT_FALSE(display_observer.changed_and_reset()); EXPECT_EQ("300x400", - test_api.GetRootWindow()->window()->bounds().size().ToString()); + test_api.GetDispatcher()->window()->bounds().size().ToString()); UpdateDisplay("310x410*2,400x500"); EXPECT_FALSE(display_observer.changed_and_reset()); EXPECT_EQ("310x410", - test_api.GetRootWindow()->window()->bounds().size().ToString()); + test_api.GetDispatcher()->window()->bounds().size().ToString()); UpdateDisplay("320x420/r,400x500"); EXPECT_FALSE(display_observer.changed_and_reset()); EXPECT_EQ("320x420", - test_api.GetRootWindow()->window()->bounds().size().ToString()); + test_api.GetDispatcher()->window()->bounds().size().ToString()); UpdateDisplay("330x440/r,400x500"); EXPECT_FALSE(display_observer.changed_and_reset()); EXPECT_EQ("330x440", - test_api.GetRootWindow()->window()->bounds().size().ToString()); + test_api.GetDispatcher()->window()->bounds().size().ToString()); // Overscan insets are ignored. UpdateDisplay("400x600/o,600x800/o"); EXPECT_FALSE(display_observer.changed_and_reset()); EXPECT_EQ("400x600", - test_api.GetRootWindow()->window()->bounds().size().ToString()); + test_api.GetDispatcher()->window()->bounds().size().ToString()); Shell::GetScreen()->RemoveObserver(&display_observer); } diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc index 68253b3..f946028 100644 --- a/ash/display/mirror_window_controller.cc +++ b/ash/display/mirror_window_controller.cc @@ -79,47 +79,47 @@ MirrorWindowController::~MirrorWindowController() { } void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { - static int mirror_root_window_count = 0; + static int mirror_dispatcher_count = 0; - if (!root_window_.get()) { + if (!dispatcher_.get()) { const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); - aura::RootWindow::CreateParams params(bounds_in_native); + aura::WindowEventDispatcher::CreateParams params(bounds_in_native); params.host = Shell::GetInstance()->window_tree_host_factory()-> CreateWindowTreeHost(bounds_in_native); - root_window_.reset(new aura::RootWindow(params)); - root_window_->window()->SetName( - base::StringPrintf("MirrorRootWindow-%d", mirror_root_window_count++)); - root_window_->host()->compositor()->SetBackgroundColor(SK_ColorBLACK); - // No need to remove RootWindowObserver because - // the DisplayController object outlives RootWindow objects. - root_window_->AddRootWindowObserver( + dispatcher_.reset(new aura::WindowEventDispatcher(params)); + dispatcher_->window()->SetName( + base::StringPrintf("MirrorRootWindow-%d", mirror_dispatcher_count++)); + dispatcher_->host()->compositor()->SetBackgroundColor(SK_ColorBLACK); + // No need to remove RootWindowObserver because the DisplayController object + // outlives WindowEventDispatcher objects. + dispatcher_->AddRootWindowObserver( Shell::GetInstance()->display_controller()); - root_window_->AddRootWindowObserver(this); + dispatcher_->AddRootWindowObserver(this); // TODO(oshima): TouchHUD is using idkey. - InitRootWindowSettings(root_window_->window())->display_id = + InitRootWindowSettings(dispatcher_->window())->display_id = display_info.id(); - root_window_->host()->InitHost(); + dispatcher_->host()->InitHost(); #if defined(USE_X11) - DisableInput(root_window_->host()->GetAcceleratedWidget()); + DisableInput(dispatcher_->host()->GetAcceleratedWidget()); #endif - aura::client::SetCaptureClient(root_window_->window(), + aura::client::SetCaptureClient(dispatcher_->window(), new NoneCaptureClient()); - root_window_->host()->Show(); + dispatcher_->host()->Show(); // TODO(oshima): Start mirroring. aura::Window* mirror_window = new aura::Window(NULL); mirror_window->Init(aura::WINDOW_LAYER_TEXTURED); - root_window_->window()->AddChild(mirror_window); - mirror_window->SetBounds(root_window_->window()->bounds()); + dispatcher_->window()->AddChild(mirror_window); + mirror_window->SetBounds(dispatcher_->window()->bounds()); mirror_window->Show(); reflector_ = ui::ContextFactory::GetInstance()->CreateReflector( Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->compositor(), mirror_window->layer()); } else { - GetRootWindowSettings(root_window_->window())->display_id = + GetRootWindowSettings(dispatcher_->window())->display_id = display_info.id(); - root_window_->host()->SetBounds(display_info.bounds_in_native()); + dispatcher_->host()->SetBounds(display_info.bounds_in_native()); } DisplayManager* display_manager = Shell::GetInstance()->display_manager(); @@ -130,11 +130,11 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { internal::CreateRootWindowTransformerForMirroredDisplay( source_display_info, display_info)); - root_window_->host()->SetRootWindowTransformer(transformer.Pass()); + dispatcher_->host()->SetRootWindowTransformer(transformer.Pass()); } void MirrorWindowController::UpdateWindow() { - if (root_window_.get()) { + if (dispatcher_.get()) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( display_manager->mirrored_display_id()); @@ -143,30 +143,30 @@ void MirrorWindowController::UpdateWindow() { } void MirrorWindowController::Close() { - if (root_window_.get()) { + if (dispatcher_.get()) { ui::ContextFactory::GetInstance()->RemoveReflector(reflector_); reflector_ = NULL; NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( - aura::client::GetCaptureClient(root_window_->window())); - aura::client::SetCaptureClient(root_window_->window(), NULL); + aura::client::GetCaptureClient(dispatcher_->window())); + aura::client::SetCaptureClient(dispatcher_->window(), NULL); delete capture_client; - root_window_->RemoveRootWindowObserver( + dispatcher_->RemoveRootWindowObserver( Shell::GetInstance()->display_controller()); - root_window_->RemoveRootWindowObserver(this); - root_window_.reset(); + dispatcher_->RemoveRootWindowObserver(this); + dispatcher_.reset(); } } void MirrorWindowController::OnWindowTreeHostResized( - const aura::RootWindow* root) { + const aura::WindowEventDispatcher* dispatcher) { // Do not use |old_size| as it contains RootWindow's (but not host's) size, // and this parameter wil be removed soon. - if (mirror_window_host_size_ == root->host()->GetBounds().size()) + if (mirror_window_host_size_ == dispatcher->host()->GetBounds().size()) return; - mirror_window_host_size_ = root->host()->GetBounds().size(); + mirror_window_host_size_ = dispatcher->host()->GetBounds().size(); reflector_->OnMirroringCompositorResized(); - root_window_->host()->SetRootWindowTransformer( + dispatcher_->host()->SetRootWindowTransformer( CreateRootWindowTransformer().Pass()); Shell::GetInstance()->display_controller()->cursor_window_controller()-> UpdateLocation(); diff --git a/ash/display/mirror_window_controller.h b/ash/display/mirror_window_controller.h index 06a586e..5f1cc27 100644 --- a/ash/display/mirror_window_controller.h +++ b/ash/display/mirror_window_controller.h @@ -16,9 +16,9 @@ #include "ui/gfx/size.h" namespace aura { -class RootWindow; class RootWindowTransformer; class Window; +class WindowEventDispatcher; } namespace ui { @@ -53,10 +53,11 @@ class ASH_EXPORT MirrorWindowController : public aura::RootWindowObserver { void Close(); // aura::RootWindowObserver overrides: - virtual void OnWindowTreeHostResized(const aura::RootWindow* root) OVERRIDE; + virtual void OnWindowTreeHostResized( + const aura::WindowEventDispatcher* root) OVERRIDE; // Returns the mirror root window. - aura::RootWindow* root_window() const { return root_window_.get(); } + aura::WindowEventDispatcher* dispatcher() const { return dispatcher_.get(); } private: friend class test::MirrorWindowTestApi; @@ -65,7 +66,7 @@ class ASH_EXPORT MirrorWindowController : public aura::RootWindowObserver { // configuration. scoped_ptr<aura::RootWindowTransformer> CreateRootWindowTransformer() const; - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; gfx::Size mirror_window_host_size_; scoped_refptr<ui::Reflector> reflector_; diff --git a/ash/display/mirror_window_controller_unittest.cc b/ash/display/mirror_window_controller_unittest.cc index a94f285..0889fee 100644 --- a/ash/display/mirror_window_controller_unittest.cc +++ b/ash/display/mirror_window_controller_unittest.cc @@ -284,7 +284,7 @@ TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { EXPECT_TRUE(display_manager->IsMirrored()); RunAllPendingInMessageLoop(); test::MirrorWindowTestApi test_api; - EXPECT_TRUE(test_api.GetRootWindow()); + EXPECT_TRUE(test_api.GetDispatcher()); } } // namsspace internal diff --git a/ash/display/virtual_keyboard_window_controller.cc b/ash/display/virtual_keyboard_window_controller.cc index 55b5fc1..fdc6348 100644 --- a/ash/display/virtual_keyboard_window_controller.cc +++ b/ash/display/virtual_keyboard_window_controller.cc @@ -41,34 +41,36 @@ void VirtualKeyboardWindowController::UpdateWindow( static int virtual_keyboard_root_window_count = 0; if (!root_window_controller_.get()) { const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); - aura::RootWindow::CreateParams params(bounds_in_native); + aura::WindowEventDispatcher::CreateParams params(bounds_in_native); params.host = Shell::GetInstance()->window_tree_host_factory()-> CreateWindowTreeHost(bounds_in_native); - aura::RootWindow* root_window = new aura::RootWindow(params); + aura::WindowEventDispatcher* dispatcher = + new aura::WindowEventDispatcher(params); - root_window->window()->SetName( + dispatcher->window()->SetName( base::StringPrintf("VirtualKeyboardRootWindow-%d", virtual_keyboard_root_window_count++)); // No need to remove RootWindowObserver because // the DisplayController object outlives RootWindow objects. - root_window->AddRootWindowObserver( + dispatcher->AddRootWindowObserver( Shell::GetInstance()->display_controller()); - InitRootWindowSettings(root_window->window())->display_id = + InitRootWindowSettings(dispatcher->window())->display_id = display_info.id(); - root_window->host()->InitHost(); - RootWindowController::CreateForVirtualKeyboardDisplay(root_window); + dispatcher->host()->InitHost(); + RootWindowController::CreateForVirtualKeyboardDisplay(dispatcher); root_window_controller_.reset(GetRootWindowController( - root_window->window())); + dispatcher->window())); root_window_controller_->dispatcher()->host()->Show(); root_window_controller_->ActivateKeyboard( Shell::GetInstance()->keyboard_controller()); FlipDisplay(); } else { - aura::RootWindow* root_window = root_window_controller_->dispatcher(); - GetRootWindowSettings(root_window->window())->display_id = + aura::WindowEventDispatcher* dispatcher = + root_window_controller_->dispatcher(); + GetRootWindowSettings(dispatcher->window())->display_id = display_info.id(); - root_window->host()->SetBounds(display_info.bounds_in_native()); + dispatcher->host()->SetBounds(display_info.bounds_in_native()); } } @@ -91,11 +93,12 @@ void VirtualKeyboardWindowController::FlipDisplay() { display_manager->SetDisplayRotation( display_manager->non_desktop_display().id(), gfx::Display::ROTATE_180); - aura::RootWindow* root_window = root_window_controller_->dispatcher(); + aura::WindowEventDispatcher* dispatcher = + root_window_controller_->dispatcher(); scoped_ptr<aura::RootWindowTransformer> transformer( - internal::CreateRootWindowTransformerForDisplay(root_window->window(), + internal::CreateRootWindowTransformerForDisplay(dispatcher->window(), display_manager->non_desktop_display())); - root_window->host()->SetRootWindowTransformer(transformer.Pass()); + dispatcher->host()->SetRootWindowTransformer(transformer.Pass()); } } // namespace internal diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index 4d41fce..67cd919 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -778,13 +778,13 @@ TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { // The lock window should get events on both root windows. aura::test::EventGenerator& event_generator(GetEventGenerator()); - event_generator.set_current_root_window(root_windows[0]->GetDispatcher()); + event_generator.set_current_dispatcher(root_windows[0]->GetDispatcher()); event_generator.PressKey(ui::VKEY_A, 0); event_generator.ReleaseKey(ui::VKEY_A, 0); EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); EXPECT_EQ("a", UTF16ToASCII(textfield->text())); - event_generator.set_current_root_window(root_windows[1]->GetDispatcher()); + event_generator.set_current_dispatcher(root_windows[1]->GetDispatcher()); event_generator.PressKey(ui::VKEY_B, 0); event_generator.ReleaseKey(ui::VKEY_B, 0); EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); @@ -801,13 +801,13 @@ TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { // on both root windows. UpdateDisplay("100x100,200x200"); root_windows = Shell::GetAllRootWindows(); - event_generator.set_current_root_window(root_windows[0]->GetDispatcher()); + event_generator.set_current_dispatcher(root_windows[0]->GetDispatcher()); event_generator.PressKey(ui::VKEY_D, 0); event_generator.ReleaseKey(ui::VKEY_D, 0); EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); - event_generator.set_current_root_window(root_windows[1]->GetDispatcher()); + event_generator.set_current_dispatcher(root_windows[1]->GetDispatcher()); event_generator.PressKey(ui::VKEY_E, 0); event_generator.ReleaseKey(ui::VKEY_E, 0); EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc index 3f2feff9..77428dc 100644 --- a/ash/magnifier/magnification_controller.cc +++ b/ash/magnifier/magnification_controller.cc @@ -44,11 +44,10 @@ const float kScrollScaleChangeFactor = 0.05f; // |kPanningMergin| from the edge, the view-port moves. const int kPanningMergin = 100; -void MoveCursorTo(aura::RootWindow* root_window, - const gfx::Point& root_location) { +void MoveCursorTo(aura::WindowTreeHost* host, const gfx::Point& root_location) { gfx::Point3F host_location_3f(root_location); - root_window->host()->GetRootTransform().TransformPoint(&host_location_3f); - root_window->host()->MoveCursorToHostLocation( + host->GetRootTransform().TransformPoint(&host_location_3f); + host->MoveCursorToHostLocation( gfx::ToCeiledPoint(host_location_3f.AsPointF())); } @@ -362,7 +361,7 @@ void MagnificationControllerImpl::OnMouseMove(const gfx::Point& location) { if (ret) { // If the magnified region is moved, hides the mouse cursor and moves it. if (x_diff != 0 || y_diff != 0) - MoveCursorTo(root_window_->GetDispatcher(), mouse); + MoveCursorTo(root_window_->GetDispatcher()->host(), mouse); } } } @@ -419,7 +418,8 @@ void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { return; if (move_cursor_after_animation_) { - MoveCursorTo(root_window_->GetDispatcher(), position_after_animation_); + MoveCursorTo(root_window_->GetDispatcher()->host(), + position_after_animation_); move_cursor_after_animation_ = false; aura::client::CursorClient* cursor_client = diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index 801f89d..91b46df 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -263,20 +263,21 @@ class EmptyWindowDelegate : public aura::WindowDelegate { namespace internal { void RootWindowController::CreateForPrimaryDisplay( - aura::RootWindow* root) { - RootWindowController* controller = new RootWindowController(root); + aura::WindowEventDispatcher* dispatcher) { + RootWindowController* controller = new RootWindowController(dispatcher); controller->Init(RootWindowController::PRIMARY, Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); } -void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) { - RootWindowController* controller = new RootWindowController(root); +void RootWindowController::CreateForSecondaryDisplay( + aura::WindowEventDispatcher* dispatcher) { + RootWindowController* controller = new RootWindowController(dispatcher); controller->Init(RootWindowController::SECONDARY, false /* first run */); } void RootWindowController::CreateForVirtualKeyboardDisplay( - aura::RootWindow * root) { - RootWindowController* controller = new RootWindowController(root); + aura::WindowEventDispatcher* dispatcher) { + RootWindowController* controller = new RootWindowController(dispatcher); controller->Init(RootWindowController::VIRTUAL_KEYBOARD, false /* first run */); } @@ -308,7 +309,7 @@ aura::Window* RootWindowController::GetContainerForWindow( RootWindowController::~RootWindowController() { Shutdown(); - root_window_.reset(); + dispatcher_.reset(); // The CaptureClient needs to be around for as long as the RootWindow is // valid. capture_client_.reset(); @@ -353,7 +354,7 @@ void RootWindowController::Shutdown() { internal::GetRootWindowSettings(root_window())->display_id = gfx::Display::kInvalidDisplayID; // And this root window should no longer process events. - root_window_->PrepareForShutdown(); + dispatcher_->PrepareForShutdown(); system_background_.reset(); } @@ -384,7 +385,7 @@ aura::Window* RootWindowController::GetContainer(int container_id) { } const aura::Window* RootWindowController::GetContainer(int container_id) const { - return root_window_->window()->GetChildById(container_id); + return dispatcher_->window()->GetChildById(container_id); } void RootWindowController::ShowShelf() { @@ -635,21 +636,22 @@ void RootWindowController::DeactivateKeyboard( //////////////////////////////////////////////////////////////////////////////// // RootWindowController, private: -RootWindowController::RootWindowController(aura::RootWindow* root_window) - : root_window_(root_window), +RootWindowController::RootWindowController( + aura::WindowEventDispatcher* dispatcher) + : dispatcher_(dispatcher), root_window_layout_(NULL), docked_layout_manager_(NULL), panel_layout_manager_(NULL), touch_hud_debug_(NULL), touch_hud_projection_(NULL) { - GetRootWindowSettings(root_window_->window())->controller = this; - screen_dimmer_.reset(new ScreenDimmer(root_window_->window())); + GetRootWindowSettings(dispatcher_->window())->controller = this; + screen_dimmer_.reset(new ScreenDimmer(dispatcher_->window())); stacking_controller_.reset(new StackingController); - aura::client::SetWindowTreeClient(root_window_->window(), + aura::client::SetWindowTreeClient(dispatcher_->window(), stacking_controller_.get()); capture_client_.reset( - new views::corewm::ScopedCaptureClient(root_window_->window())); + new views::corewm::ScopedCaptureClient(dispatcher_->window())); } void RootWindowController::Init(RootWindowType root_window_type, @@ -657,8 +659,8 @@ void RootWindowController::Init(RootWindowType root_window_type, Shell* shell = Shell::GetInstance(); shell->InitRootWindow(root_window()); - root_window_->host()->SetCursor(ui::kCursorPointer); - CreateContainersInRootWindow(root_window_->window()); + dispatcher_->host()->SetCursor(ui::kCursorPointer); + CreateContainersInRootWindow(dispatcher_->window()); if (root_window_type == VIRTUAL_KEYBOARD) { shell->InitKeyboard(); @@ -684,9 +686,8 @@ void RootWindowController::Init(RootWindowType root_window_type, } else { root_window_layout()->OnWindowResized(); shell->desktop_background_controller()->OnRootWindowAdded(root_window()); - shell->high_contrast_controller()->OnRootWindowAdded( - root_window_->window()); - root_window_->host()->Show(); + shell->high_contrast_controller()->OnRootWindowAdded(dispatcher_->window()); + dispatcher_->host()->Show(); // Create a shelf if a user is already logged in. if (shell->session_state_delegate()->NumberOfLoggedInUsers()) @@ -778,7 +779,7 @@ void RootWindowController::CreateSystemBackground( switches::kAshCopyHostBackgroundAtBoot) || CommandLine::ForCurrentProcess()->HasSwitch( switches::kAshAnimateFromBootSplashScreen))) - boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); + boot_splash_screen_.reset(new BootSplashScreen(dispatcher_.get())); #endif } diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index aa1ec2b..849ce07 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -78,19 +78,21 @@ class BootSplashScreen; // indirectly owned and deleted by |DisplayController|. // The RootWindowController for particular root window is stored in // its property (RootWindowSettings) and can be obtained using -// |GetRootWindowController(aura::RootWindow*)| function. +// |GetRootWindowController(aura::WindowEventDispatcher*)| function. class ASH_EXPORT RootWindowController : public ShellObserver { public: // Creates and Initialize the RootWindowController for primary display. - static void CreateForPrimaryDisplay(aura::RootWindow* root_window); + static void CreateForPrimaryDisplay(aura::WindowEventDispatcher* dispatcher); // Creates and Initialize the RootWindowController for secondary displays. - static void CreateForSecondaryDisplay(aura::RootWindow* root_window); + static void CreateForSecondaryDisplay( + aura::WindowEventDispatcher* dispatcher); // Creates and Initialize the RootWindowController for virtual // keyboard displays. - static void CreateForVirtualKeyboardDisplay(aura::RootWindow* root_window); + static void CreateForVirtualKeyboardDisplay( + aura::WindowEventDispatcher* dispatcher); // Returns a RootWindowController that has a shelf for given // |window|. This returns the RootWindowController for the |window|'s @@ -110,7 +112,7 @@ class ASH_EXPORT RootWindowController : public ShellObserver { virtual ~RootWindowController(); aura::Window* root_window() { return dispatcher()->window(); } - aura::WindowEventDispatcher* dispatcher() { return root_window_.get(); } + aura::WindowEventDispatcher* dispatcher() { return dispatcher_.get(); } RootWindowLayoutManager* root_window_layout() { return root_window_layout_; } @@ -233,7 +235,7 @@ class ASH_EXPORT RootWindowController : public ShellObserver { void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller); private: - explicit RootWindowController(aura::RootWindow* root_window); + explicit RootWindowController(aura::WindowEventDispatcher* dispatcher); enum RootWindowType { PRIMARY, SECONDARY, @@ -265,7 +267,7 @@ class ASH_EXPORT RootWindowController : public ShellObserver { virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE; - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; RootWindowLayoutManager* root_window_layout_; scoped_ptr<StackingController> stacking_controller_; diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index c1b03ac..1edd14e 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -58,7 +58,7 @@ class AshEventGeneratorDelegate : public aura::test::EventGeneratorDelegate { virtual ~AshEventGeneratorDelegate() {} // aura::test::EventGeneratorDelegate overrides: - virtual aura::RootWindow* GetRootWindowAt( + virtual aura::WindowEventDispatcher* GetDispatcherAt( const gfx::Point& point_in_screen) const OVERRIDE { gfx::Screen* screen = Shell::GetScreen(); gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); diff --git a/ash/test/mirror_window_test_api.cc b/ash/test/mirror_window_test_api.cc index 92be78b..4c098f2 100644 --- a/ash/test/mirror_window_test_api.cc +++ b/ash/test/mirror_window_test_api.cc @@ -14,9 +14,9 @@ namespace ash { namespace test { -const aura::RootWindow* MirrorWindowTestApi::GetRootWindow() const { +const aura::WindowEventDispatcher* MirrorWindowTestApi::GetDispatcher() const { return Shell::GetInstance()->display_controller()-> - mirror_window_controller()->root_window_.get(); + mirror_window_controller()->dispatcher_.get(); } int MirrorWindowTestApi::GetCurrentCursorType() const { diff --git a/ash/test/mirror_window_test_api.h b/ash/test/mirror_window_test_api.h index c6013c5..72f062c 100644 --- a/ash/test/mirror_window_test_api.h +++ b/ash/test/mirror_window_test_api.h @@ -9,9 +9,9 @@ #include "base/memory/scoped_ptr.h" namespace aura { -class RootWindow; class RootWindowTransformer; class Window; +class WindowEventDispatcher; } namespace gfx { @@ -26,7 +26,7 @@ class MirrorWindowTestApi { MirrorWindowTestApi() {} ~MirrorWindowTestApi() {} - const aura::RootWindow* GetRootWindow() const; + const aura::WindowEventDispatcher* GetDispatcher() const; int GetCurrentCursorType() const; const gfx::Point& GetCursorHotPoint() const; diff --git a/ash/wm/boot_splash_screen_chromeos.cc b/ash/wm/boot_splash_screen_chromeos.cc index ca862fa..374b1b6 100644 --- a/ash/wm/boot_splash_screen_chromeos.cc +++ b/ash/wm/boot_splash_screen_chromeos.cc @@ -20,8 +20,8 @@ namespace internal { class BootSplashScreen::CopyHostContentLayerDelegate : public ui::LayerDelegate { public: - explicit CopyHostContentLayerDelegate(aura::RootWindow* root_window) - : root_window_(root_window) { + explicit CopyHostContentLayerDelegate(aura::WindowTreeHost* host) + : host_(host) { } virtual ~CopyHostContentLayerDelegate() {} @@ -35,8 +35,8 @@ class BootSplashScreen::CopyHostContentLayerDelegate // TODO(derat): Instead of copying the data, use GLX_EXT_texture_from_pixmap // to create a zero-copy texture (when possible): // https://codereview.chromium.org/10543125 - ui::CopyAreaToCanvas(root_window_->host()->GetAcceleratedWidget(), - root_window_->host()->GetBounds(), gfx::Point(), canvas); + ui::CopyAreaToCanvas(host_->GetAcceleratedWidget(), + host_->GetBounds(), gfx::Point(), canvas); } virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {} @@ -46,18 +46,18 @@ class BootSplashScreen::CopyHostContentLayerDelegate } private: - aura::RootWindow* root_window_; // not owned + aura::WindowTreeHost* host_; // not owned DISALLOW_COPY_AND_ASSIGN(CopyHostContentLayerDelegate); }; -BootSplashScreen::BootSplashScreen(aura::RootWindow* root_window) - : layer_delegate_(new CopyHostContentLayerDelegate(root_window)), +BootSplashScreen::BootSplashScreen(aura::WindowEventDispatcher* dispatcher) + : layer_delegate_(new CopyHostContentLayerDelegate(dispatcher->host())), layer_(new ui::Layer(ui::LAYER_TEXTURED)) { layer_->set_delegate(layer_delegate_.get()); - ui::Layer* root_layer = root_window->window()->layer(); - layer_->SetBounds(gfx::Rect(root_layer->bounds().size())); + ui::Layer* root_layer = dispatcher->window()->layer(); + layer_->SetBounds(gfx::Rect(dispatcher->window()->bounds().size())); root_layer->Add(layer_.get()); root_layer->StackAtTop(layer_.get()); } diff --git a/ash/wm/boot_splash_screen_chromeos.h b/ash/wm/boot_splash_screen_chromeos.h index e844275..fcf97e3 100644 --- a/ash/wm/boot_splash_screen_chromeos.h +++ b/ash/wm/boot_splash_screen_chromeos.h @@ -12,7 +12,7 @@ #include "base/time/time.h" namespace aura { -class RootWindow; +class WindowEventDispatcher; } namespace ui { @@ -30,7 +30,7 @@ namespace internal { // animate the transition between the splash screen and the login screen. class BootSplashScreen { public: - explicit BootSplashScreen(aura::RootWindow* root_window); + explicit BootSplashScreen(aura::WindowEventDispatcher* dispatcher); ~BootSplashScreen(); // Begins animating |layer_|'s opacity to 0 over |duration|. diff --git a/ash/wm/lock_state_controller.cc b/ash/wm/lock_state_controller.cc index 3cc3438..768bffb 100644 --- a/ash/wm/lock_state_controller.cc +++ b/ash/wm/lock_state_controller.cc @@ -290,7 +290,7 @@ void LockStateController::SetLockScreenDisplayedCallback( } void LockStateController::OnWindowTreeHostCloseRequested( - const aura::RootWindow*) { + const aura::WindowEventDispatcher* dispatcher) { Shell::GetInstance()->delegate()->Exit(); } diff --git a/ash/wm/lock_state_controller.h b/ash/wm/lock_state_controller.h index bcfd64f..5a70ad4 100644 --- a/ash/wm/lock_state_controller.h +++ b/ash/wm/lock_state_controller.h @@ -199,7 +199,7 @@ class ASH_EXPORT LockStateController : public aura::RootWindowObserver, // RootWindowObserver override: virtual void OnWindowTreeHostCloseRequested( - const aura::RootWindow* root) OVERRIDE; + const aura::WindowEventDispatcher* dispatcher) OVERRIDE; // ShellObserver overrides: virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; diff --git a/chrome/browser/chromeos/events/event_rewriter.cc b/chrome/browser/chromeos/events/event_rewriter.cc index 21c8a9c..612ac26 100644 --- a/chrome/browser/chromeos/events/event_rewriter.cc +++ b/chrome/browser/chromeos/events/event_rewriter.cc @@ -196,7 +196,8 @@ void EventRewriter::RewriteForTesting(XEvent* event) { Rewrite(event); } -void EventRewriter::OnKeyboardMappingChanged(const aura::RootWindow* root) { +void EventRewriter::OnKeyboardMappingChanged( + const aura::WindowEventDispatcher* dispatcher) { RefreshKeycodes(); } diff --git a/chrome/browser/chromeos/events/event_rewriter.h b/chrome/browser/chromeos/events/event_rewriter.h index 6a5e644..967058b 100644 --- a/chrome/browser/chromeos/events/event_rewriter.h +++ b/chrome/browser/chromeos/events/event_rewriter.h @@ -70,7 +70,8 @@ class EventRewriter : public aura::RootWindowObserver, friend class EventRewriterTest; // aura::RootWindowObserver overrides: - virtual void OnKeyboardMappingChanged(const aura::RootWindow* root) OVERRIDE; + virtual void OnKeyboardMappingChanged( + const aura::WindowEventDispatcher* dispatcher) OVERRIDE; // base::MessagePumpObserver overrides: virtual base::EventStatus WillProcessEvent( diff --git a/chrome/browser/ui/aura/active_desktop_monitor.cc b/chrome/browser/ui/aura/active_desktop_monitor.cc index 7fc541b..67fba14 100644 --- a/chrome/browser/ui/aura/active_desktop_monitor.cc +++ b/chrome/browser/ui/aura/active_desktop_monitor.cc @@ -38,16 +38,17 @@ chrome::HostDesktopType ActiveDesktopMonitor::GetLastActivatedDesktopType() { } // static -bool ActiveDesktopMonitor::IsDesktopWindow(aura::RootWindow* root_window) { +bool ActiveDesktopMonitor::IsDesktopWindow( + aura::WindowEventDispatcher* dispatcher) { // Only windows hosted by a DesktopWindowTreeHost implementation can be mapped // back to a content Window. All others, therefore, must be the root window // for an Ash display. #if defined(OS_WIN) return views::DesktopWindowTreeHostWin::GetContentWindowForHWND( - root_window->host()->GetAcceleratedWidget()) != NULL; + dispatcher->host()->GetAcceleratedWidget()) != NULL; #elif defined(USE_X11) return views::DesktopWindowTreeHostX11::GetContentWindowForXID( - root_window->host()->GetAcceleratedWidget()) != NULL; + dispatcher->host()->GetAcceleratedWidget()) != NULL; #else NOTREACHED(); return true; @@ -57,8 +58,8 @@ bool ActiveDesktopMonitor::IsDesktopWindow(aura::RootWindow* root_window) { void ActiveDesktopMonitor::OnWindowInitialized(aura::Window* window) {} void ActiveDesktopMonitor::OnRootWindowActivated( - aura::RootWindow* root_window) { - if (IsDesktopWindow(root_window)) + aura::WindowEventDispatcher* dispatcher) { + if (IsDesktopWindow(dispatcher)) last_activated_desktop_ = chrome::HOST_DESKTOP_TYPE_NATIVE; else last_activated_desktop_ = chrome::HOST_DESKTOP_TYPE_ASH; diff --git a/chrome/browser/ui/aura/active_desktop_monitor.h b/chrome/browser/ui/aura/active_desktop_monitor.h index 9272016..b5485e0 100644 --- a/chrome/browser/ui/aura/active_desktop_monitor.h +++ b/chrome/browser/ui/aura/active_desktop_monitor.h @@ -26,12 +26,13 @@ class ActiveDesktopMonitor : public aura::EnvObserver { static chrome::HostDesktopType GetLastActivatedDesktopType(); private: - // Returns true if |root_window| is hosted by a DesktopWindowTreeHost. - static bool IsDesktopWindow(aura::RootWindow* root_window); + // Returns true if |dispatcher| is hosted by a DesktopWindowTreeHost. + static bool IsDesktopWindow(aura::WindowEventDispatcher* dispatcher); // aura::EnvObserver methods. virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; - virtual void OnRootWindowActivated(aura::RootWindow* root_window) OVERRIDE; + virtual void OnRootWindowActivated( + aura::WindowEventDispatcher* dispatcher) OVERRIDE; static ActiveDesktopMonitor* g_instance_; chrome::HostDesktopType last_activated_desktop_; diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.cc b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.cc index a60608b..b208f72 100644 --- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.cc +++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.cc @@ -43,7 +43,7 @@ bool BrowserDesktopWindowTreeHostX11::UsesNativeSystemMenu() const { void BrowserDesktopWindowTreeHostX11::Init( aura::Window* content_window, const views::Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) { + aura::WindowEventDispatcher::CreateParams* rw_create_params) { views::DesktopWindowTreeHostX11::Init(content_window, params, rw_create_params); diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h index 5b53e5e..d104b95 100644 --- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h +++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h @@ -36,7 +36,7 @@ class BrowserDesktopWindowTreeHostX11 virtual void Init( aura::Window* content_window, const views::Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) OVERRIDE; + aura::WindowEventDispatcher::CreateParams* rw_create_params) OVERRIDE; virtual void CloseNow() OVERRIDE; BrowserView* browser_view_; diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc index 26d070a..201661c 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc @@ -220,7 +220,7 @@ class ScreenEventGeneratorDelegate : public aura::test::EventGeneratorDelegate { virtual ~ScreenEventGeneratorDelegate() {} // EventGeneratorDelegate overrides: - virtual aura::RootWindow* GetRootWindowAt( + virtual aura::WindowEventDispatcher* GetDispatcherAt( const gfx::Point& point) const OVERRIDE { return root_window_->GetDispatcher(); } diff --git a/chrome/browser/ui/views/tabs/window_finder_x11.cc b/chrome/browser/ui/views/tabs/window_finder_x11.cc index 1bb8941..09c3e29 100644 --- a/chrome/browser/ui/views/tabs/window_finder_x11.cc +++ b/chrome/browser/ui/views/tabs/window_finder_x11.cc @@ -142,7 +142,7 @@ class LocalProcessWindowFinder : public BaseWindowFinder { return false; // Check if this window is in our process. - if (!aura::RootWindow::GetForAcceleratedWidget(window)) + if (!aura::WindowEventDispatcher::GetForAcceleratedWidget(window)) return false; if (!ui::IsWindowVisible(window)) diff --git a/content/browser/renderer_host/compositor_resize_lock_aura.cc b/content/browser/renderer_host/compositor_resize_lock_aura.cc index 53c2c5b..33d8d5b 100644 --- a/content/browser/renderer_host/compositor_resize_lock_aura.cc +++ b/content/browser/renderer_host/compositor_resize_lock_aura.cc @@ -11,20 +11,21 @@ namespace content { -CompositorResizeLock::CompositorResizeLock(aura::RootWindow* root_window, - const gfx::Size new_size, - bool defer_compositor_lock, - const base::TimeDelta& timeout) +CompositorResizeLock::CompositorResizeLock( + aura::WindowEventDispatcher* dispatcher, + const gfx::Size new_size, + bool defer_compositor_lock, + const base::TimeDelta& timeout) : ResizeLock(new_size, defer_compositor_lock), - root_window_(root_window), + dispatcher_(dispatcher), weak_ptr_factory_(this), cancelled_(false) { - DCHECK(root_window_); + DCHECK(dispatcher_); TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this, "width", expected_size().width(), "height", expected_size().height()); - root_window_->HoldPointerMoves(); + dispatcher_->HoldPointerMoves(); BrowserThread::PostDelayedTask( BrowserThread::UI, FROM_HERE, @@ -51,7 +52,7 @@ void CompositorResizeLock::UnlockCompositor() { void CompositorResizeLock::LockCompositor() { ResizeLock::LockCompositor(); - compositor_lock_ = root_window_->host()->compositor()->GetCompositorLock(); + compositor_lock_ = dispatcher_->host()->compositor()->GetCompositorLock(); } void CompositorResizeLock::CancelLock() { @@ -59,7 +60,7 @@ void CompositorResizeLock::CancelLock() { return; cancelled_ = true; UnlockCompositor(); - root_window_->ReleasePointerMoves(); + dispatcher_->ReleasePointerMoves(); } } // namespace content diff --git a/content/browser/renderer_host/compositor_resize_lock_aura.h b/content/browser/renderer_host/compositor_resize_lock_aura.h index 6963ac2..211aabe 100644 --- a/content/browser/renderer_host/compositor_resize_lock_aura.h +++ b/content/browser/renderer_host/compositor_resize_lock_aura.h @@ -10,19 +10,22 @@ #include "base/time/time.h" #include "content/browser/compositor/resize_lock.h" -namespace aura { class RootWindow; } - -namespace ui { class CompositorLock; } +namespace aura { +class WindowEventDispatcher; +} +namespace ui { +class CompositorLock; +} namespace content { // Used to prevent further resizes while a resize is pending. class CompositorResizeLock : public ResizeLock { public: - CompositorResizeLock(aura::RootWindow* root_window, - const gfx::Size new_size, - bool defer_compositor_lock, - const base::TimeDelta& timeout); + CompositorResizeLock(aura::WindowEventDispatcher* dispatcher, + const gfx::Size new_size, + bool defer_compositor_lock, + const base::TimeDelta& timeout); virtual ~CompositorResizeLock(); virtual bool GrabDeferredLock() OVERRIDE; @@ -33,7 +36,7 @@ class CompositorResizeLock : public ResizeLock { void CancelLock(); private: - aura::RootWindow* root_window_; + aura::WindowEventDispatcher* dispatcher_; scoped_refptr<ui::CompositorLock> compositor_lock_; base::WeakPtrFactory<CompositorResizeLock> weak_ptr_factory_; bool cancelled_; diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_aura.h b/content/browser/renderer_host/input/synthetic_gesture_target_aura.h index ec1c6ae..bd0d761 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_target_aura.h +++ b/content/browser/renderer_host/input/synthetic_gesture_target_aura.h @@ -10,9 +10,8 @@ #include "content/common/input/synthetic_gesture_params.h" namespace aura { -class RootWindow; -typedef RootWindow WindowEventDispatcher; class Window; +class WindowEventDispatcher; namespace client { class ScreenPositionClient; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 5782e06..1399a20 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -3154,7 +3154,7 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus, // RenderWidgetHostViewAura, aura::RootWindowObserver implementation: void RenderWidgetHostViewAura::OnWindowTreeHostMoved( - const aura::RootWindow* root, + const aura::WindowEventDispatcher* dispatcher, const gfx::Point& new_origin) { TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnWindowTreeHostMoved", "new_origin", new_origin.ToString()); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 0e01067..0b46d7f 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -325,8 +325,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura aura::Window* lost_focus) OVERRIDE; // Overridden from aura::RootWindowObserver: - virtual void OnWindowTreeHostMoved(const aura::RootWindow* root, - const gfx::Point& new_origin) OVERRIDE; + virtual void OnWindowTreeHostMoved( + const aura::WindowEventDispatcher* dispatcher, + const gfx::Point& new_origin) OVERRIDE; // SoftwareFrameManagerClient implementation: virtual void SoftwareFrameWasFreed( @@ -467,10 +468,10 @@ class CONTENT_EXPORT RenderWidgetHostViewAura // Add on compositing commit callback. void AddOnCommitCallbackAndDisableLocks(const base::Closure& callback); - // Called after |window_| is parented to a RootWindow. + // Called after |window_| is parented to a WindowEventDispatcher. void AddedToRootWindow(); - // Called prior to removing |window_| from a RootWindow. + // Called prior to removing |window_| from a WindowEventDispatcher. void RemovingFromRootWindow(); // Called after commit for the last reference to the texture going away diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index aa3be21..44b6457 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -617,8 +617,9 @@ class WebContentsViewAura::WindowObserver } // Overridden RootWindowObserver: - virtual void OnWindowTreeHostMoved(const aura::RootWindow* root, - const gfx::Point& new_origin) OVERRIDE { + virtual void OnWindowTreeHostMoved( + const aura::WindowEventDispatcher* dispatcher, + const gfx::Point& new_origin) OVERRIDE { TRACE_EVENT1("ui", "WebContentsViewAura::WindowObserver::OnWindowTreeHostMoved", "new_origin", new_origin.ToString()); diff --git a/content/shell/browser/shell_platform_data_aura.cc b/content/shell/browser/shell_platform_data_aura.cc index f5c5a9a..3de6e50 100644 --- a/content/shell/browser/shell_platform_data_aura.cc +++ b/content/shell/browser/shell_platform_data_aura.cc @@ -25,7 +25,7 @@ namespace { class FillLayout : public aura::LayoutManager { public: - explicit FillLayout(aura::RootWindow* root) + explicit FillLayout(aura::Window* root) : root_(root) { } @@ -37,7 +37,7 @@ class FillLayout : public aura::LayoutManager { } virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { - child->SetBounds(root_->window()->bounds()); + child->SetBounds(root_->bounds()); } virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE { @@ -55,7 +55,7 @@ class FillLayout : public aura::LayoutManager { SetChildBoundsDirect(child, requested_bounds); } - aura::RootWindow* root_; + aura::Window* root_; DISALLOW_COPY_AND_ASSIGN(FillLayout); }; @@ -63,20 +63,20 @@ class FillLayout : public aura::LayoutManager { class MinimalInputEventFilter : public ui::internal::InputMethodDelegate, public ui::EventHandler { public: - explicit MinimalInputEventFilter(aura::RootWindow* root) - : root_(root), + explicit MinimalInputEventFilter(aura::WindowEventDispatcher* dispatcher) + : dispatcher_(dispatcher), input_method_(ui::CreateInputMethod(this, gfx::kNullAcceleratedWidget)) { input_method_->Init(true); - root_->window()->AddPreTargetHandler(this); - root_->window()->SetProperty(aura::client::kRootWindowInputMethodKey, - input_method_.get()); + dispatcher_->window()->AddPreTargetHandler(this); + dispatcher_->window()->SetProperty(aura::client::kRootWindowInputMethodKey, + input_method_.get()); } virtual ~MinimalInputEventFilter() { - root_->window()->RemovePreTargetHandler(this); - root_->window()->SetProperty(aura::client::kRootWindowInputMethodKey, - static_cast<ui::InputMethod*>(NULL)); + dispatcher_->window()->RemovePreTargetHandler(this); + dispatcher_->window()->SetProperty(aura::client::kRootWindowInputMethodKey, + static_cast<ui::InputMethod*>(NULL)); } private: @@ -97,11 +97,12 @@ class MinimalInputEventFilter : public ui::internal::InputMethodDelegate, // ui::internal::InputMethodDelegate: virtual bool DispatchKeyEventPostIME(const ui::KeyEvent& event) OVERRIDE { ui::TranslatedKeyEvent aura_event(event); - ui::EventDispatchDetails details = root_->OnEventFromSource(&aura_event); + ui::EventDispatchDetails details = + dispatcher_->OnEventFromSource(&aura_event); return aura_event.handled() || details.dispatcher_destroyed; } - aura::RootWindow* root_; + aura::WindowEventDispatcher* dispatcher_; scoped_ptr<ui::InputMethod> input_method_; DISALLOW_COPY_AND_ASSIGN(MinimalInputEventFilter); @@ -113,32 +114,33 @@ ShellPlatformDataAura* Shell::platform_ = NULL; ShellPlatformDataAura::ShellPlatformDataAura(const gfx::Size& initial_size) { aura::Env::CreateInstance(); - root_window_.reset(new aura::RootWindow( - aura::RootWindow::CreateParams(gfx::Rect(initial_size)))); - root_window_->host()->InitHost(); - root_window_->window()->SetLayoutManager(new FillLayout(root_window_.get())); + dispatcher_.reset(new aura::WindowEventDispatcher( + aura::WindowEventDispatcher::CreateParams(gfx::Rect(initial_size)))); + dispatcher_->host()->InitHost(); + dispatcher_->window()->SetLayoutManager( + new FillLayout(dispatcher_->window())); focus_client_.reset(new aura::test::TestFocusClient()); - aura::client::SetFocusClient(root_window_->window(), focus_client_.get()); + aura::client::SetFocusClient(dispatcher_->window(), focus_client_.get()); activation_client_.reset( - new aura::client::DefaultActivationClient(root_window_->window())); + new aura::client::DefaultActivationClient(dispatcher_->window())); capture_client_.reset( - new aura::client::DefaultCaptureClient(root_window_->window())); + new aura::client::DefaultCaptureClient(dispatcher_->window())); window_tree_client_.reset( - new aura::test::TestWindowTreeClient(root_window_->window())); - ime_filter_.reset(new MinimalInputEventFilter(root_window_.get())); + new aura::test::TestWindowTreeClient(dispatcher_->window())); + ime_filter_.reset(new MinimalInputEventFilter(dispatcher_.get())); } ShellPlatformDataAura::~ShellPlatformDataAura() { } void ShellPlatformDataAura::ShowWindow() { - root_window_->host()->Show(); + dispatcher_->host()->Show(); } void ShellPlatformDataAura::ResizeWindow(const gfx::Size& size) { - root_window_->host()->SetBounds(gfx::Rect(size)); + dispatcher_->host()->SetBounds(gfx::Rect(size)); } diff --git a/content/shell/browser/shell_platform_data_aura.h b/content/shell/browser/shell_platform_data_aura.h index 9b7ea2b..1a50cec 100644 --- a/content/shell/browser/shell_platform_data_aura.h +++ b/content/shell/browser/shell_platform_data_aura.h @@ -8,13 +8,13 @@ #include "base/memory/scoped_ptr.h" namespace aura { +class WindowEventDispatcher; namespace client { class DefaultActivationClient; class DefaultCaptureClient; class FocusClient; class WindowTreeClient; } -class RootWindow; } namespace gfx { @@ -35,10 +35,10 @@ class ShellPlatformDataAura { void ShowWindow(); void ResizeWindow(const gfx::Size& size); - aura::RootWindow* window() { return root_window_.get(); } + aura::WindowEventDispatcher* dispatcher() { return dispatcher_.get(); } private: - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<aura::client::DefaultActivationClient> activation_client_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc index ccd1e4c..5a661d6 100644 --- a/content/shell/browser/shell_views.cc +++ b/content/shell/browser/shell_views.cc @@ -513,7 +513,7 @@ void Shell::PlatformSetContents() { if (headless_) { CHECK(platform_); aura::Window* content = web_contents_->GetView()->GetNativeView(); - aura::Window* parent = platform_->window()->window(); + aura::Window* parent = platform_->dispatcher()->window(); if (!parent->Contains(content)) { parent->AddChild(content); content->Show(); diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc index 07b1e8b..9d1e093 100644 --- a/mojo/examples/aura_demo/aura_demo.cc +++ b/mojo/examples/aura_demo/aura_demo.cc @@ -134,28 +134,28 @@ class AuraDemo : public Application { private: void HostContextCreated() { - aura::RootWindow::CreateParams params( + aura::WindowEventDispatcher::CreateParams params( gfx::Rect(window_tree_host_->bounds().size())); params.host = window_tree_host_.get(); - root_window_.reset(new aura::RootWindow(params)); - window_tree_host_->set_delegate(root_window_.get()); - root_window_->host()->InitHost(); + dispatcher_.reset(new aura::WindowEventDispatcher(params)); + window_tree_host_->set_delegate(dispatcher_.get()); + dispatcher_->host()->InitHost(); - window_tree_client_.reset(new DemoWindowTreeClient(root_window_->window())); + window_tree_client_.reset(new DemoWindowTreeClient(dispatcher_->window())); delegate1_.reset(new DemoWindowDelegate(SK_ColorBLUE)); window1_ = new aura::Window(delegate1_.get()); window1_->Init(aura::WINDOW_LAYER_TEXTURED); window1_->SetBounds(gfx::Rect(100, 100, 400, 400)); window1_->Show(); - root_window_->window()->AddChild(window1_); + dispatcher_->window()->AddChild(window1_); delegate2_.reset(new DemoWindowDelegate(SK_ColorRED)); window2_ = new aura::Window(delegate2_.get()); window2_->Init(aura::WINDOW_LAYER_TEXTURED); window2_->SetBounds(gfx::Rect(200, 200, 350, 350)); window2_->Show(); - root_window_->window()->AddChild(window2_); + dispatcher_->window()->AddChild(window2_); delegate21_.reset(new DemoWindowDelegate(SK_ColorGREEN)); window21_ = new aura::Window(delegate21_.get()); @@ -164,7 +164,7 @@ class AuraDemo : public Application { window21_->Show(); window2_->AddChild(window21_); - root_window_->host()->Show(); + dispatcher_->host()->Show(); } scoped_ptr<DemoScreen> screen_; @@ -180,7 +180,7 @@ class AuraDemo : public Application { aura::Window* window21_; scoped_ptr<WindowTreeHostMojo> window_tree_host_; - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; }; } // namespace examples diff --git a/mojo/examples/aura_demo/window_tree_host_mojo.cc b/mojo/examples/aura_demo/window_tree_host_mojo.cc index 38c66e3..c867b47 100644 --- a/mojo/examples/aura_demo/window_tree_host_mojo.cc +++ b/mojo/examples/aura_demo/window_tree_host_mojo.cc @@ -56,10 +56,6 @@ WindowTreeHostMojo::~WindowTreeHostMojo() {} //////////////////////////////////////////////////////////////////////////////// // WindowTreeHostMojo, aura::WindowTreeHost implementation: -aura::RootWindow* WindowTreeHostMojo::GetRootWindow() { - return delegate_->AsRootWindow(); -} - gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() { NOTIMPLEMENTED() << "GetAcceleratedWidget"; return gfx::kNullAcceleratedWidget; diff --git a/mojo/examples/aura_demo/window_tree_host_mojo.h b/mojo/examples/aura_demo/window_tree_host_mojo.h index 6cbd197..11eaadd 100644 --- a/mojo/examples/aura_demo/window_tree_host_mojo.h +++ b/mojo/examples/aura_demo/window_tree_host_mojo.h @@ -33,7 +33,6 @@ class WindowTreeHostMojo : public aura::WindowTreeHost, private: // WindowTreeHost: - virtual aura::RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; diff --git a/mojo/examples/launcher/launcher.cc b/mojo/examples/launcher/launcher.cc index 70a9d8c..2054c30 100644 --- a/mojo/examples/launcher/launcher.cc +++ b/mojo/examples/launcher/launcher.cc @@ -221,14 +221,14 @@ class LauncherImpl : public Application, // Overridden from Launcher: virtual void Show() OVERRIDE { - if (!root_window_.get()) { + if (!dispatcher_.get()) { pending_show_ = true; return; } - root_window_->host()->Show(); + dispatcher_->host()->Show(); } virtual void Hide() OVERRIDE { - root_window_->host()->Hide(); + dispatcher_->host()->Hide(); } // Overridden from URLReceiver: @@ -238,25 +238,25 @@ class LauncherImpl : public Application, } void HostContextCreated() { - aura::RootWindow::CreateParams params(gfx::Rect(450, 60)); + aura::WindowEventDispatcher::CreateParams params(gfx::Rect(450, 60)); params.host = window_tree_host_.get(); - root_window_.reset(new aura::RootWindow(params)); - window_tree_host_->set_delegate(root_window_.get()); - root_window_->host()->InitHost(); - root_window_->window()->SetBounds(gfx::Rect(450, 60)); + dispatcher_.reset(new aura::WindowEventDispatcher(params)); + window_tree_host_->set_delegate(dispatcher_.get()); + dispatcher_->host()->InitHost(); + dispatcher_->window()->SetBounds(gfx::Rect(450, 60)); focus_client_.reset(new aura::test::TestFocusClient()); - aura::client::SetFocusClient(root_window_->window(), focus_client_.get()); + aura::client::SetFocusClient(dispatcher_->window(), focus_client_.get()); activation_client_.reset( - new aura::client::DefaultActivationClient(root_window_->window())); + new aura::client::DefaultActivationClient(dispatcher_->window())); capture_client_.reset( - new aura::client::DefaultCaptureClient(root_window_->window())); - ime_filter_.reset(new MinimalInputEventFilter(root_window_->window())); + new aura::client::DefaultCaptureClient(dispatcher_->window())); + ime_filter_.reset(new MinimalInputEventFilter(dispatcher_->window())); window_tree_client_.reset( - new LauncherWindowTreeClient(root_window_->window())); + new LauncherWindowTreeClient(dispatcher_->window())); - launcher_controller_.InitInWindow(root_window_->window()); + launcher_controller_.InitInWindow(dispatcher_->window()); if (pending_show_) { pending_show_ = false; @@ -275,7 +275,7 @@ class LauncherImpl : public Application, RemotePtr<LauncherClient> launcher_client_; scoped_ptr<WindowTreeHostMojo> window_tree_host_; - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; bool pending_show_; }; diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc index c366a59..ce1d6d1 100644 --- a/ui/aura/bench/bench_main.cc +++ b/ui/aura/bench/bench_main.cc @@ -300,20 +300,20 @@ int main(int argc, char** argv) { scoped_ptr<aura::TestScreen> test_screen( aura::TestScreen::CreateFullscreen()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get()); - scoped_ptr<aura::RootWindow> root_window( + scoped_ptr<aura::WindowEventDispatcher> dispatcher( test_screen->CreateRootWindowForPrimaryDisplay()); aura::client::SetCaptureClient( - root_window->window(), - new aura::client::DefaultCaptureClient(root_window->window())); + dispatcher->window(), + new aura::client::DefaultCaptureClient(dispatcher->window())); scoped_ptr<aura::client::FocusClient> focus_client( new aura::test::TestFocusClient); - aura::client::SetFocusClient(root_window->window(), focus_client.get()); + aura::client::SetFocusClient(dispatcher->window(), focus_client.get()); // add layers ColoredLayer background(SK_ColorRED); - background.SetBounds(root_window->window()->bounds()); - root_window->window()->layer()->Add(&background); + background.SetBounds(dispatcher->window()->bounds()); + dispatcher->window()->layer()->Add(&background); ColoredLayer window(SK_ColorBLUE); window.SetBounds(gfx::Rect(background.bounds().size())); @@ -338,22 +338,22 @@ int main(int argc, char** argv) { if (command_line->HasSwitch("bench-software-scroll")) { bench.reset(new SoftwareScrollBench(&page_background, - root_window->host()->compositor(), + dispatcher->host()->compositor(), frames)); } else { bench.reset(new WebGLBench(&page_background, - root_window->host()->compositor(), + dispatcher->host()->compositor(), frames)); } #ifndef NDEBUG - ui::PrintLayerHierarchy(root_window->window()->layer(), gfx::Point(100, 100)); + ui::PrintLayerHierarchy(dispatcher->window()->layer(), gfx::Point(100, 100)); #endif - root_window->host()->Show(); + dispatcher->host()->Show(); base::MessageLoopForUI::current()->Run(); focus_client.reset(); - root_window.reset(); + dispatcher.reset(); return 0; } diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index b14a70e..c958aa9 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -118,12 +118,12 @@ int DemoMain() { aura::Env::CreateInstance(); scoped_ptr<aura::TestScreen> test_screen(aura::TestScreen::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get()); - scoped_ptr<aura::RootWindow> root_window( + scoped_ptr<aura::WindowEventDispatcher> dispatcher( test_screen->CreateRootWindowForPrimaryDisplay()); scoped_ptr<DemoWindowTreeClient> window_tree_client(new DemoWindowTreeClient( - root_window->window())); + dispatcher->window())); aura::test::TestFocusClient focus_client; - aura::client::SetFocusClient(root_window->window(), &focus_client); + aura::client::SetFocusClient(dispatcher->window(), &focus_client); // Create a hierarchy of test windows. DemoWindowDelegate window_delegate1(SK_ColorBLUE); @@ -133,7 +133,7 @@ int DemoMain() { window1.SetBounds(gfx::Rect(100, 100, 400, 400)); window1.Show(); aura::client::ParentWindowWithContext( - &window1, root_window->window(), gfx::Rect()); + &window1, dispatcher->window(), gfx::Rect()); DemoWindowDelegate window_delegate2(SK_ColorRED); aura::Window window2(&window_delegate2); @@ -142,7 +142,7 @@ int DemoMain() { window2.SetBounds(gfx::Rect(200, 200, 350, 350)); window2.Show(); aura::client::ParentWindowWithContext( - &window2, root_window->window(), gfx::Rect()); + &window2, dispatcher->window(), gfx::Rect()); DemoWindowDelegate window_delegate3(SK_ColorGREEN); aura::Window window3(&window_delegate3); @@ -152,7 +152,7 @@ int DemoMain() { window3.Show(); window2.AddChild(&window3); - root_window->host()->Show(); + dispatcher->host()->Show(); base::MessageLoopForUI::current()->Run(); return 0; diff --git a/ui/aura/env.cc b/ui/aura/env.cc index c74a59f..65f77ec 100644 --- a/ui/aura/env.cc +++ b/ui/aura/env.cc @@ -76,9 +76,9 @@ bool Env::IsMouseButtonDown() const { mouse_button_flags_ != 0; } -void Env::RootWindowActivated(RootWindow* root_window) { +void Env::RootWindowActivated(WindowEventDispatcher* dispatcher) { FOR_EACH_OBSERVER(EnvObserver, observers_, - OnRootWindowActivated(root_window)); + OnRootWindowActivated(dispatcher)); } //////////////////////////////////////////////////////////////////////////////// @@ -98,10 +98,10 @@ void Env::NotifyWindowInitialized(Window* window) { FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); } -void Env::NotifyRootWindowInitialized(RootWindow* root_window) { +void Env::NotifyRootWindowInitialized(WindowEventDispatcher* dispatcher) { FOR_EACH_OBSERVER(EnvObserver, observers_, - OnRootWindowInitialized(root_window)); + OnRootWindowInitialized(dispatcher)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/aura/env.h b/ui/aura/env.h index 78fc2ef..a6695962 100644 --- a/ui/aura/env.h +++ b/ui/aura/env.h @@ -24,8 +24,8 @@ class EnvTestHelper; class EnvObserver; class InputStateLookup; -class RootWindow; class Window; +class WindowEventDispatcher; // A singleton object that tracks general state within Aura. // TODO(beng): manage RootWindows. @@ -60,7 +60,7 @@ class AURA_EXPORT Env : public ui::EventTarget { void set_touch_down(bool value) { is_touch_down_ = value; } // Invoked by RootWindow when its host is activated. - void RootWindowActivated(RootWindow* root_window); + void RootWindowActivated(WindowEventDispatcher* dispatcher); private: friend class test::EnvTestHelper; @@ -73,7 +73,7 @@ class AURA_EXPORT Env : public ui::EventTarget { void NotifyWindowInitialized(Window* window); // Called by the RootWindow when it is initialized. Notifies observers. - void NotifyRootWindowInitialized(RootWindow* root_window); + void NotifyRootWindowInitialized(WindowEventDispatcher* dispatcher); // Overridden from ui::EventTarget: virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE; diff --git a/ui/aura/env_observer.h b/ui/aura/env_observer.h index b624f91..b381929 100644 --- a/ui/aura/env_observer.h +++ b/ui/aura/env_observer.h @@ -9,8 +9,8 @@ namespace aura { -class RootWindow; class Window; +class WindowEventDispatcher; class AURA_EXPORT EnvObserver { public: @@ -18,10 +18,10 @@ class AURA_EXPORT EnvObserver { virtual void OnWindowInitialized(Window* window) = 0; // Called when |root_window| has been initialized. - virtual void OnRootWindowInitialized(RootWindow* root_window) {}; + virtual void OnRootWindowInitialized(WindowEventDispatcher* dispatcher) {}; // Called when a RootWindow's host is activated. - virtual void OnRootWindowActivated(RootWindow* root_window) {} + virtual void OnRootWindowActivated(WindowEventDispatcher* dispatcher) {} // Called right before Env is destroyed. virtual void OnWillDestroyEnv() {} diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc index 5d17de0..d65a951 100644 --- a/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -354,9 +354,9 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { class QueueTouchEventDelegate : public GestureEventConsumeDelegate { public: - explicit QueueTouchEventDelegate(RootWindow* root_window) + explicit QueueTouchEventDelegate(WindowEventDispatcher* dispatcher) : window_(NULL), - root_window_(root_window), + dispatcher_(dispatcher), queue_events_(true) { } virtual ~QueueTouchEventDelegate() { @@ -387,14 +387,14 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate { private: void ReceivedAckImpl(bool prevent_defaulted) { scoped_ptr<ui::TouchEvent> event(queue_.front()); - root_window_->ProcessedTouchEvent(event.get(), window_, + dispatcher_->ProcessedTouchEvent(event.get(), window_, prevent_defaulted ? ui::ER_HANDLED : ui::ER_UNHANDLED); queue_.pop(); } std::queue<ui::TouchEvent*> queue_; Window* window_; - RootWindow* root_window_; + WindowEventDispatcher* dispatcher_; bool queue_events_; DISALLOW_COPY_AND_ASSIGN(QueueTouchEventDelegate); @@ -577,7 +577,7 @@ class TimedEvents { return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); } - void SendScrollEvents(RootWindow* root_window, + void SendScrollEvents(WindowEventDispatcher* dispatcher, float x_start, float y_start, int dx, @@ -595,13 +595,13 @@ class TimedEvents { ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), touch_id, base::TimeDelta::FromMilliseconds(simulated_now_)); - ui::EventDispatchDetails details = root_window->OnEventFromSource(&move); + ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); simulated_now_ += time_step; } } - void SendScrollEvent(RootWindow* root_window, + void SendScrollEvent(WindowEventDispatcher* dispatcher, float x, float y, int touch_id, @@ -610,7 +610,7 @@ class TimedEvents { ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), touch_id, base::TimeDelta::FromMilliseconds(simulated_now_)); - ui::EventDispatchDetails details = root_window->OnEventFromSource(&move); + ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); simulated_now_++; } diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc index 8460d8a..d57fc30 100644 --- a/ui/aura/remote_window_tree_host_win.cc +++ b/ui/aura/remote_window_tree_host_win.cc @@ -368,11 +368,7 @@ bool RemoteWindowTreeHostWin::IsForegroundWindow() { } Window* RemoteWindowTreeHostWin::GetAshWindow() { - return GetRootWindow()->window(); -} - -RootWindow* RemoteWindowTreeHostWin::GetRootWindow() { - return delegate_->AsRootWindow(); + return GetDispatcher()->window(); } gfx::AcceleratedWidget RemoteWindowTreeHostWin::GetAcceleratedWidget() { @@ -424,7 +420,7 @@ void RemoteWindowTreeHostWin::ReleaseCapture() { bool RemoteWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) { aura::client::CursorClient* cursor_client = - aura::client::GetCursorClient(GetRootWindow()->window()); + aura::client::GetCursorClient(GetDispatcher()->window()); if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { *location_return = gfx::Point(0, 0); return false; diff --git a/ui/aura/remote_window_tree_host_win.h b/ui/aura/remote_window_tree_host_win.h index 87c7920..6ccd06c 100644 --- a/ui/aura/remote_window_tree_host_win.h +++ b/ui/aura/remote_window_tree_host_win.h @@ -216,7 +216,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin void OnImeInputSourceChanged(uint16 language_id, bool is_ime); // WindowTreeHost overrides: - virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 8733816..35349ee 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -70,11 +70,11 @@ void SetLastMouseLocation(const Window* root_window, } } -WindowTreeHost* CreateHost(RootWindow* root_window, - const RootWindow::CreateParams& params) { +WindowTreeHost* CreateHost(WindowEventDispatcher* dispatcher, + const WindowEventDispatcher::CreateParams& params) { WindowTreeHost* host = params.host ? params.host : WindowTreeHost::Create(params.initial_bounds); - host->set_delegate(root_window); + host->set_delegate(dispatcher); return host; } @@ -90,15 +90,16 @@ bool IsEventCandidateForHold(const ui::Event& event) { } // namespace -RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds) +WindowEventDispatcher::CreateParams::CreateParams( + const gfx::Rect& a_initial_bounds) : initial_bounds(a_initial_bounds), host(NULL) { } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, public: +// WindowEventDispatcher, public: -RootWindow::RootWindow(const CreateParams& params) +WindowEventDispatcher::WindowEventDispatcher(const CreateParams& params) : window_(new Window(NULL)), host_(CreateHost(this, params)), touch_ids_down_(0), @@ -122,12 +123,13 @@ RootWindow::RootWindow(const CreateParams& params) ui::GestureRecognizer::Get()->AddGestureEventHelper(this); } -RootWindow::~RootWindow() { - TRACE_EVENT0("shutdown", "RootWindow::Destructor"); +WindowEventDispatcher::~WindowEventDispatcher() { + TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this); - // An observer may have been added by an animation on the RootWindow. + // An observer may have been added by an animation on the + // WindowEventDispatcher. window()->layer()->GetAnimator()->RemoveObserver(this); // Destroy child windows while we're still valid. This is also done by @@ -144,19 +146,19 @@ RootWindow::~RootWindow() { } // static -RootWindow* RootWindow::GetForAcceleratedWidget( +WindowEventDispatcher* WindowEventDispatcher::GetForAcceleratedWidget( gfx::AcceleratedWidget widget) { - return reinterpret_cast<RootWindow*>( + return reinterpret_cast<WindowEventDispatcher*>( ui::ViewProp::GetValue(widget, kRootWindowForAcceleratedWidget)); } -void RootWindow::PrepareForShutdown() { +void WindowEventDispatcher::PrepareForShutdown() { host_->PrepareForShutdown(); // discard synthesize event request as well. synthesize_mouse_move_ = false; } -void RootWindow::RepostEvent(const ui::LocatedEvent& event) { +void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent& event) { DCHECK(event.type() == ui::ET_MOUSE_PRESSED || event.type() == ui::ET_GESTURE_TAP_DOWN); // We allow for only one outstanding repostable event. This is used @@ -168,9 +170,9 @@ void RootWindow::RepostEvent(const ui::LocatedEvent& event) { static_cast<aura::Window*>(event.target()), window())); base::MessageLoop::current()->PostNonNestableTask( - FROM_HERE, - base::Bind(base::IgnoreResult(&RootWindow::DispatchHeldEvents), - repost_event_factory_.GetWeakPtr())); + FROM_HERE, base::Bind( + base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents), + repost_event_factory_.GetWeakPtr())); } else { DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); held_repostable_event_.reset(); @@ -179,18 +181,18 @@ void RootWindow::RepostEvent(const ui::LocatedEvent& event) { } } -WindowTreeHostDelegate* RootWindow::AsWindowTreeHostDelegate() { +WindowTreeHostDelegate* WindowEventDispatcher::AsWindowTreeHostDelegate() { return this; } -void RootWindow::OnMouseEventsEnableStateChanged(bool enabled) { +void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) { // Send entered / exited so that visual state can be updated to match // mouse events state. PostMouseMoveEventAfterWindowChange(); // TODO(mazda): Add code to disable mouse events when |enabled| == false. } -Window* RootWindow::GetGestureTarget(ui::GestureEvent* event) { +Window* WindowEventDispatcher::GetGestureTarget(ui::GestureEvent* event) { Window* target = NULL; if (!event->IsEndingEvent()) { // The window that received the start event (e.g. scroll begin) needs to @@ -205,7 +207,7 @@ Window* RootWindow::GetGestureTarget(ui::GestureEvent* event) { return target; } -void RootWindow::DispatchGestureEvent(ui::GestureEvent* event) { +void WindowEventDispatcher::DispatchGestureEvent(ui::GestureEvent* event) { DispatchDetails details = DispatchHeldEvents(); if (details.dispatcher_destroyed) return; @@ -219,7 +221,7 @@ void RootWindow::DispatchGestureEvent(ui::GestureEvent* event) { } } -void RootWindow::OnWindowDestroying(Window* window) { +void WindowEventDispatcher::OnWindowDestroying(Window* window) { DispatchMouseExitToHidingWindow(window); if (window->IsVisible() && window->ContainsPointInRoot(GetLastMouseLocationInRoot())) { @@ -231,8 +233,8 @@ void RootWindow::OnWindowDestroying(Window* window) { OnWindowHidden(window, WINDOW_DESTROYED); } -void RootWindow::OnWindowBoundsChanged(Window* window, - bool contained_mouse_point) { +void WindowEventDispatcher::OnWindowBoundsChanged(Window* window, + bool contained_mouse_point) { if (contained_mouse_point || (window->IsVisible() && window->ContainsPointInRoot(GetLastMouseLocationInRoot()))) { @@ -240,7 +242,7 @@ void RootWindow::OnWindowBoundsChanged(Window* window, } } -void RootWindow::DispatchMouseExitToHidingWindow(Window* window) { +void WindowEventDispatcher::DispatchMouseExitToHidingWindow(Window* window) { // The mouse capture is intentionally ignored. Think that a mouse enters // to a window, the window sets the capture, the mouse exits the window, // and then it releases the capture. In that case OnMouseExited won't @@ -252,7 +254,7 @@ void RootWindow::DispatchMouseExitToHidingWindow(Window* window) { DispatchMouseExitAtPoint(last_mouse_location); } -void RootWindow::DispatchMouseExitAtPoint(const gfx::Point& point) { +void WindowEventDispatcher::DispatchMouseExitAtPoint(const gfx::Point& point) { ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, ui::EF_NONE); DispatchDetails details = @@ -261,7 +263,8 @@ void RootWindow::DispatchMouseExitAtPoint(const gfx::Point& point) { return; } -void RootWindow::OnWindowVisibilityChanged(Window* window, bool is_visible) { +void WindowEventDispatcher::OnWindowVisibilityChanged(Window* window, + bool is_visible) { if (window->ContainsPointInRoot(GetLastMouseLocationInRoot())) PostMouseMoveEventAfterWindowChange(); @@ -271,7 +274,8 @@ void RootWindow::OnWindowVisibilityChanged(Window* window, bool is_visible) { OnWindowHidden(window, WINDOW_HIDDEN); } -void RootWindow::OnWindowTransformed(Window* window, bool contained_mouse) { +void WindowEventDispatcher::OnWindowTransformed(Window* window, + bool contained_mouse) { if (contained_mouse || (window->IsVisible() && window->ContainsPointInRoot(GetLastMouseLocationInRoot()))) { @@ -279,27 +283,29 @@ void RootWindow::OnWindowTransformed(Window* window, bool contained_mouse) { } } -void RootWindow::OnKeyboardMappingChanged() { +void WindowEventDispatcher::OnKeyboardMappingChanged() { FOR_EACH_OBSERVER(RootWindowObserver, observers_, OnKeyboardMappingChanged(this)); } -void RootWindow::OnWindowTreeHostCloseRequested() { +void WindowEventDispatcher::OnWindowTreeHostCloseRequested() { FOR_EACH_OBSERVER(RootWindowObserver, observers_, OnWindowTreeHostCloseRequested(this)); } -void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) { +void WindowEventDispatcher::AddRootWindowObserver( + RootWindowObserver* observer) { observers_.AddObserver(observer); } -void RootWindow::RemoveRootWindowObserver(RootWindowObserver* observer) { +void WindowEventDispatcher::RemoveRootWindowObserver( + RootWindowObserver* observer) { observers_.RemoveObserver(observer); } -void RootWindow::ProcessedTouchEvent(ui::TouchEvent* event, - Window* window, - ui::EventResult result) { +void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, + Window* window, + ui::EventResult result) { scoped_ptr<ui::GestureRecognizer::Gestures> gestures; gestures.reset(ui::GestureRecognizer::Get()-> ProcessTouchEventForGesture(*event, result, window)); @@ -308,14 +314,15 @@ void RootWindow::ProcessedTouchEvent(ui::TouchEvent* event, return; } -void RootWindow::HoldPointerMoves() { +void WindowEventDispatcher::HoldPointerMoves() { if (!move_hold_count_) held_event_factory_.InvalidateWeakPtrs(); ++move_hold_count_; - TRACE_EVENT_ASYNC_BEGIN0("ui", "RootWindow::HoldPointerMoves", this); + TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", + this); } -void RootWindow::ReleasePointerMoves() { +void WindowEventDispatcher::ReleasePointerMoves() { --move_hold_count_; DCHECK_GE(move_hold_count_, 0); if (!move_hold_count_ && held_move_event_) { @@ -324,14 +331,14 @@ void RootWindow::ReleasePointerMoves() { // another one may not be safe/expected. Instead we post a task, that we // may cancel if HoldPointerMoves is called again before it executes. base::MessageLoop::current()->PostNonNestableTask( - FROM_HERE, - base::Bind(base::IgnoreResult(&RootWindow::DispatchHeldEvents), - held_event_factory_.GetWeakPtr())); + FROM_HERE, base::Bind( + base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents), + held_event_factory_.GetWeakPtr())); } - TRACE_EVENT_ASYNC_END0("ui", "RootWindow::HoldPointerMoves", this); + TRACE_EVENT_ASYNC_END0("ui", "WindowEventDispatcher::HoldPointerMoves", this); } -gfx::Point RootWindow::GetLastMouseLocationInRoot() const { +gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const { gfx::Point location = Env::GetInstance()->last_mouse_location(); client::ScreenPositionClient* client = client::GetScreenPositionClient(window()); @@ -341,13 +348,14 @@ gfx::Point RootWindow::GetLastMouseLocationInRoot() const { } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, private: +// WindowEventDispatcher, private: -void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) { +void WindowEventDispatcher::TransformEventForDeviceScaleFactor( + ui::LocatedEvent* event) { event->UpdateForRootTransform(host()->GetInverseRootTransform()); } -ui::EventDispatchDetails RootWindow::DispatchMouseEnterOrExit( +ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit( const ui::MouseEvent& event, ui::EventType type) { if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED && @@ -374,7 +382,7 @@ ui::EventDispatchDetails RootWindow::DispatchMouseEnterOrExit( return DispatchEvent(mouse_moved_handler_, &translated_event); } -ui::EventDispatchDetails RootWindow::ProcessGestures( +ui::EventDispatchDetails WindowEventDispatcher::ProcessGestures( ui::GestureRecognizer::Gestures* gestures) { DispatchDetails details; if (!gestures || gestures->empty()) @@ -391,15 +399,15 @@ ui::EventDispatchDetails RootWindow::ProcessGestures( return details; } -void RootWindow::OnWindowAddedToRootWindow(Window* attached) { +void WindowEventDispatcher::OnWindowAddedToRootWindow(Window* attached) { if (attached->IsVisible() && attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) { PostMouseMoveEventAfterWindowChange(); } } -void RootWindow::OnWindowRemovedFromRootWindow(Window* detached, - Window* new_root) { +void WindowEventDispatcher::OnWindowRemovedFromRootWindow(Window* detached, + Window* new_root) { DCHECK(aura::client::GetCaptureWindow(window()) != window()); DispatchMouseExitToHidingWindow(detached); @@ -413,7 +421,8 @@ void RootWindow::OnWindowRemovedFromRootWindow(Window* detached, OnWindowHidden(detached, new_root ? WINDOW_MOVING : WINDOW_HIDDEN); } -void RootWindow::OnWindowHidden(Window* invisible, WindowHiddenReason reason) { +void WindowEventDispatcher::OnWindowHidden(Window* invisible, + WindowHiddenReason reason) { // If the window the mouse was pressed in becomes invisible, it should no // longer receive mouse events. if (invisible->Contains(mouse_pressed_handler_)) @@ -445,7 +454,7 @@ void RootWindow::OnWindowHidden(Window* invisible, WindowHiddenReason reason) { } } -void RootWindow::CleanupGestureState(Window* window) { +void WindowEventDispatcher::CleanupGestureState(Window* window) { ui::GestureRecognizer::Get()->CancelActiveTouches(window); ui::GestureRecognizer::Get()->CleanupStateForConsumer(window); const Window::Windows& windows = window->children(); @@ -457,10 +466,10 @@ void RootWindow::CleanupGestureState(Window* window) { } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, aura::client::CaptureDelegate implementation: +// WindowEventDispatcher, aura::client::CaptureDelegate implementation: -void RootWindow::UpdateCapture(Window* old_capture, - Window* new_capture) { +void WindowEventDispatcher::UpdateCapture(Window* old_capture, + Window* new_capture) { // |mouse_moved_handler_| may have been set to a Window in a different root // (see below). Clear it here to ensure we don't end up referencing a stale // Window. @@ -494,26 +503,26 @@ void RootWindow::UpdateCapture(Window* old_capture, mouse_pressed_handler_ = NULL; } -void RootWindow::OnOtherRootGotCapture() { +void WindowEventDispatcher::OnOtherRootGotCapture() { mouse_moved_handler_ = NULL; mouse_pressed_handler_ = NULL; } -void RootWindow::SetNativeCapture() { +void WindowEventDispatcher::SetNativeCapture() { host_->SetCapture(); } -void RootWindow::ReleaseNativeCapture() { +void WindowEventDispatcher::ReleaseNativeCapture() { host_->ReleaseCapture(); } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, ui::EventProcessor implementation: -ui::EventTarget* RootWindow::GetRootTarget() { +// WindowEventDispatcher, ui::EventProcessor implementation: +ui::EventTarget* WindowEventDispatcher::GetRootTarget() { return window(); } -void RootWindow::PrepareEventForDispatch(ui::Event* event) { +void WindowEventDispatcher::PrepareEventForDispatch(ui::Event* event) { if (dispatching_held_event_) { // The held events are already in |window()|'s coordinate system. So it is // not necessary to apply the transform to convert from the host's @@ -529,14 +538,15 @@ void RootWindow::PrepareEventForDispatch(ui::Event* event) { } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, ui::EventDispatcherDelegate implementation: +// WindowEventDispatcher, ui::EventDispatcherDelegate implementation: -bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) { +bool WindowEventDispatcher::CanDispatchToTarget(ui::EventTarget* target) { return event_dispatch_target_ == target; } -ui::EventDispatchDetails RootWindow::PreDispatchEvent(ui::EventTarget* target, - ui::Event* event) { +ui::EventDispatchDetails WindowEventDispatcher::PreDispatchEvent( + ui::EventTarget* target, + ui::Event* event) { if (!dispatching_held_event_) { bool can_be_held = IsEventCandidateForHold(*event); if (!move_hold_count_ || !can_be_held) { @@ -562,8 +572,9 @@ ui::EventDispatchDetails RootWindow::PreDispatchEvent(ui::EventTarget* target, return DispatchDetails(); } -ui::EventDispatchDetails RootWindow::PostDispatchEvent(ui::EventTarget* target, - const ui::Event& event) { +ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent( + ui::EventTarget* target, + const ui::Event& event) { DispatchDetails details; if (target != event_dispatch_target_) details.target_destroyed = true; @@ -591,43 +602,45 @@ ui::EventDispatchDetails RootWindow::PostDispatchEvent(ui::EventTarget* target, } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, ui::GestureEventHelper implementation: +// WindowEventDispatcher, ui::GestureEventHelper implementation: -bool RootWindow::CanDispatchToConsumer(ui::GestureConsumer* consumer) { +bool WindowEventDispatcher::CanDispatchToConsumer( + ui::GestureConsumer* consumer) { Window* consumer_window = ConsumerToWindow(consumer);; return (consumer_window && consumer_window->GetRootWindow() == window()); } -void RootWindow::DispatchPostponedGestureEvent(ui::GestureEvent* event) { +void WindowEventDispatcher::DispatchPostponedGestureEvent( + ui::GestureEvent* event) { DispatchGestureEvent(event); } -void RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { +void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { DispatchDetails details = OnEventFromSource(event); if (details.dispatcher_destroyed) return; } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, ui::LayerAnimationObserver implementation: +// WindowEventDispatcher, ui::LayerAnimationObserver implementation: -void RootWindow::OnLayerAnimationEnded( +void WindowEventDispatcher::OnLayerAnimationEnded( ui::LayerAnimationSequence* animation) { host()->UpdateRootWindowSize(host_->GetBounds().size()); } -void RootWindow::OnLayerAnimationScheduled( +void WindowEventDispatcher::OnLayerAnimationScheduled( ui::LayerAnimationSequence* animation) { } -void RootWindow::OnLayerAnimationAborted( +void WindowEventDispatcher::OnLayerAnimationAborted( ui::LayerAnimationSequence* animation) { } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, WindowTreeHostDelegate implementation: +// WindowEventDispatcher, WindowTreeHostDelegate implementation: -void RootWindow::OnHostCancelMode() { +void WindowEventDispatcher::OnHostCancelMode() { ui::CancelModeEvent event; Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow(); DispatchDetails details = @@ -636,31 +649,31 @@ void RootWindow::OnHostCancelMode() { return; } -void RootWindow::OnHostActivated() { +void WindowEventDispatcher::OnHostActivated() { Env::GetInstance()->RootWindowActivated(this); } -void RootWindow::OnHostLostWindowCapture() { +void WindowEventDispatcher::OnHostLostWindowCapture() { Window* capture_window = client::GetCaptureWindow(window()); if (capture_window && capture_window->GetRootWindow() == window()) capture_window->ReleaseCapture(); } -void RootWindow::OnHostLostMouseGrab() { +void WindowEventDispatcher::OnHostLostMouseGrab() { mouse_pressed_handler_ = NULL; mouse_moved_handler_ = NULL; } -void RootWindow::OnHostMoved(const gfx::Point& origin) { - TRACE_EVENT1("ui", "RootWindow::OnHostMoved", +void WindowEventDispatcher::OnHostMoved(const gfx::Point& origin) { + TRACE_EVENT1("ui", "WindowEventDispatcher::OnHostMoved", "origin", origin.ToString()); FOR_EACH_OBSERVER(RootWindowObserver, observers_, OnWindowTreeHostMoved(this, origin)); } -void RootWindow::OnHostResized(const gfx::Size& size) { - TRACE_EVENT1("ui", "RootWindow::OnHostResized", +void WindowEventDispatcher::OnHostResized(const gfx::Size& size) { + TRACE_EVENT1("ui", "WindowEventDispatcher::OnHostResized", "size", size.ToString()); DispatchDetails details = DispatchHeldEvents(); @@ -678,27 +691,28 @@ void RootWindow::OnHostResized(const gfx::Size& size) { synthesize_mouse_move_ = false; } -void RootWindow::OnCursorMovedToRootLocation(const gfx::Point& root_location) { +void WindowEventDispatcher::OnCursorMovedToRootLocation( + const gfx::Point& root_location) { SetLastMouseLocation(window(), root_location); synthesize_mouse_move_ = false; } -RootWindow* RootWindow::AsRootWindow() { +WindowEventDispatcher* WindowEventDispatcher::AsDispatcher() { return this; } -const RootWindow* RootWindow::AsRootWindow() const { +const WindowEventDispatcher* WindowEventDispatcher::AsDispatcher() const { return this; } -ui::EventProcessor* RootWindow::GetEventProcessor() { +ui::EventProcessor* WindowEventDispatcher::GetEventProcessor() { return this; } //////////////////////////////////////////////////////////////////////////////// -// RootWindow, private: +// WindowEventDispatcher, private: -ui::EventDispatchDetails RootWindow::DispatchHeldEvents() { +ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() { if (!held_repostable_event_ && !held_move_event_) return DispatchDetails(); @@ -735,17 +749,18 @@ ui::EventDispatchDetails RootWindow::DispatchHeldEvents() { return dispatch_details; } -void RootWindow::PostMouseMoveEventAfterWindowChange() { +void WindowEventDispatcher::PostMouseMoveEventAfterWindowChange() { if (synthesize_mouse_move_) return; synthesize_mouse_move_ = true; base::MessageLoop::current()->PostNonNestableTask( FROM_HERE, - base::Bind(base::IgnoreResult(&RootWindow::SynthesizeMouseMoveEvent), - held_event_factory_.GetWeakPtr())); + base::Bind(base::IgnoreResult( + &WindowEventDispatcher::SynthesizeMouseMoveEvent), + held_event_factory_.GetWeakPtr())); } -ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() { +ui::EventDispatchDetails WindowEventDispatcher::SynthesizeMouseMoveEvent() { DispatchDetails details; if (!synthesize_mouse_move_) return details; @@ -763,8 +778,8 @@ ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() { return OnEventFromSource(&event); } -void RootWindow::PreDispatchLocatedEvent(Window* target, - ui::LocatedEvent* event) { +void WindowEventDispatcher::PreDispatchLocatedEvent(Window* target, + ui::LocatedEvent* event) { int flags = event->flags(); if (IsNonClientLocation(target, event->location())) flags |= ui::EF_IS_NON_CLIENT; @@ -779,8 +794,8 @@ void RootWindow::PreDispatchLocatedEvent(Window* target, } } -void RootWindow::PreDispatchMouseEvent(Window* target, - ui::MouseEvent* event) { +void WindowEventDispatcher::PreDispatchMouseEvent(Window* target, + ui::MouseEvent* event) { client::CursorClient* cursor_client = client::GetCursorClient(window()); if (cursor_client && !cursor_client->IsMouseEventsEnabled() && @@ -878,8 +893,8 @@ void RootWindow::PreDispatchMouseEvent(Window* target, PreDispatchLocatedEvent(target, event); } -void RootWindow::PreDispatchTouchEvent(Window* target, - ui::TouchEvent* event) { +void WindowEventDispatcher::PreDispatchTouchEvent(Window* target, + ui::TouchEvent* event) { switch (event->type()) { case ui::ET_TOUCH_PRESSED: touch_ids_down_ |= (1 << event->touch_id()); diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 0af6491..bbdabd3 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -45,18 +45,17 @@ class ViewProp; } namespace aura { -class RootWindow; class WindowTreeHost; class RootWindowObserver; class TestScreen; class WindowTargeter; // RootWindow is responsible for hosting a set of windows. -class AURA_EXPORT RootWindow : public ui::EventProcessor, - public ui::GestureEventHelper, - public ui::LayerAnimationObserver, - public client::CaptureDelegate, - public WindowTreeHostDelegate { +class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, + public ui::GestureEventHelper, + public ui::LayerAnimationObserver, + public client::CaptureDelegate, + public WindowTreeHostDelegate { public: struct AURA_EXPORT CreateParams { // CreateParams with initial_bounds and default host in pixel. @@ -70,20 +69,22 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, WindowTreeHost* host; }; - explicit RootWindow(const CreateParams& params); - virtual ~RootWindow(); + explicit WindowEventDispatcher(const CreateParams& params); + virtual ~WindowEventDispatcher(); // Returns the WindowTreeHost for the specified accelerated widget, or NULL // if there is none associated. - static RootWindow* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); + static WindowEventDispatcher* GetForAcceleratedWidget( + gfx::AcceleratedWidget widget); Window* window() { - return const_cast<Window*>(const_cast<const RootWindow*>(this)->window()); + return const_cast<Window*>( + const_cast<const WindowEventDispatcher*>(this)->window()); } const Window* window() const { return window_.get(); } WindowTreeHost* host() { return const_cast<WindowTreeHost*>( - const_cast<const RootWindow*>(this)->host()); + const_cast<const WindowEventDispatcher*>(this)->host()); } const WindowTreeHost* host() const { return host_.get(); } Window* mouse_pressed_handler() { return mouse_pressed_handler_; } @@ -150,8 +151,9 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, // When a touch event is dispatched to a Window, it may want to process the // touch event asynchronously. In such cases, the window should consume the // event during the event dispatch. Once the event is properly processed, the - // window should let the RootWindow know about the result of the event - // processing, so that gesture events can be properly created and dispatched. + // window should let the WindowEventDispatcher know about the result of the + // event processing, so that gesture events can be properly created and + // dispatched. void ProcessedTouchEvent(ui::TouchEvent* event, Window* window, ui::EventResult result); @@ -171,7 +173,8 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, gfx::Point GetLastMouseLocationInRoot() const; private: - FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot); + FRIEND_TEST_ALL_PREFIXES(WindowEventDispatcherTest, + KeepTranslatedEventInRoot); friend class Window; friend class TestScreen; @@ -186,9 +189,9 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, // Updates the event with the appropriate transform for the device scale // factor. The WindowTreeHostDelegate dispatches events in the physical pixel - // coordinate. But the event processing from RootWindow onwards happen in - // device-independent pixel coordinate. So it is necessary to update the event - // received from the host. + // coordinate. But the event processing from WindowEventDispatcher onwards + // happen in device-independent pixel coordinate. So it is necessary to update + // the event received from the host. void TransformEventForDeviceScaleFactor(ui::LocatedEvent* event); // Dispatches the specified event type (intended for enter/exit) to the @@ -199,7 +202,8 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, ui::EventDispatchDetails ProcessGestures( ui::GestureRecognizer::Gestures* gestures) WARN_UNUSED_RESULT; - // Called when a Window is attached or detached from the RootWindow. + // Called when a Window is attached or detached from the + // WindowEventDispatcher. void OnWindowAddedToRootWindow(Window* window); void OnWindowRemovedFromRootWindow(Window* window, Window* new_root); @@ -253,8 +257,8 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, virtual void OnHostResized(const gfx::Size& size) OVERRIDE; virtual void OnCursorMovedToRootLocation( const gfx::Point& root_location) OVERRIDE; - virtual RootWindow* AsRootWindow() OVERRIDE; - virtual const RootWindow* AsRootWindow() const OVERRIDE; + virtual WindowEventDispatcher* AsDispatcher() OVERRIDE; + virtual const WindowEventDispatcher* AsDispatcher() const OVERRIDE; virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; // We hold and aggregate mouse drags and touch moves as a way of throttling @@ -312,12 +316,12 @@ class AURA_EXPORT RootWindow : public ui::EventProcessor, scoped_ptr<ui::ViewProp> prop_; // Used to schedule reposting an event. - base::WeakPtrFactory<RootWindow> repost_event_factory_; + base::WeakPtrFactory<WindowEventDispatcher> repost_event_factory_; // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. - base::WeakPtrFactory<RootWindow> held_event_factory_; + base::WeakPtrFactory<WindowEventDispatcher> held_event_factory_; - DISALLOW_COPY_AND_ASSIGN(RootWindow); + DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcher); }; } // namespace aura diff --git a/ui/aura/root_window_observer.h b/ui/aura/root_window_observer.h index 0ef86e1..081b577 100644 --- a/ui/aura/root_window_observer.h +++ b/ui/aura/root_window_observer.h @@ -9,28 +9,31 @@ namespace gfx { class Point; -class Size; } namespace aura { -class RootWindow; class Window; +class WindowEventDispatcher; +// TODO(beng): Rename to WindowTreeHostObserver class AURA_EXPORT RootWindowObserver { public: // Invoked after the RootWindow's host has been resized. - virtual void OnWindowTreeHostResized(const RootWindow* root) {} + virtual void OnWindowTreeHostResized( + const WindowEventDispatcher* dispatcher) {} // Invoked after the RootWindow's host has been moved on screen. - virtual void OnWindowTreeHostMoved(const RootWindow* root, + virtual void OnWindowTreeHostMoved(const WindowEventDispatcher* dispatcher, const gfx::Point& new_origin) {} // Invoked when the native windowing system sends us a request to close our // window. - virtual void OnWindowTreeHostCloseRequested(const RootWindow* root) {} + virtual void OnWindowTreeHostCloseRequested( + const WindowEventDispatcher* dispatcher) {} // Invoked when the keyboard mapping has changed. - virtual void OnKeyboardMappingChanged(const RootWindow* root) {} + virtual void OnKeyboardMappingChanged( + const WindowEventDispatcher* dispatcher) {} protected: virtual ~RootWindowObserver() {} diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index 2b28144..f711135 100644 --- a/ui/aura/root_window_unittest.cc +++ b/ui/aura/root_window_unittest.cc @@ -96,9 +96,9 @@ bool IsFocusedWindow(aura::Window* window) { } // namespace -typedef test::AuraTestBase RootWindowTest; +typedef test::AuraTestBase WindowEventDispatcherTest; -TEST_F(RootWindowTest, OnHostMouseEvent) { +TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) { // Create two non-overlapping windows so we don't have to worry about which // is on top. scoped_ptr<NonClientDelegate> delegate1(new NonClientDelegate()); @@ -133,7 +133,7 @@ TEST_F(RootWindowTest, OnHostMouseEvent) { EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); } -TEST_F(RootWindowTest, RepostEvent) { +TEST_F(WindowEventDispatcherTest, RepostEvent) { // Test RepostEvent in RootWindow. It only works for Mouse Press. EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); gfx::Point point(10, 10); @@ -147,7 +147,7 @@ TEST_F(RootWindowTest, RepostEvent) { // Check that we correctly track the state of the mouse buttons in response to // button press and release events. -TEST_F(RootWindowTest, MouseButtonState) { +TEST_F(WindowEventDispatcherTest, MouseButtonState) { EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); gfx::Point location; @@ -204,7 +204,7 @@ TEST_F(RootWindowTest, MouseButtonState) { EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); } -TEST_F(RootWindowTest, TranslatedEvent) { +TEST_F(WindowEventDispatcherTest, TranslatedEvent) { scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1, gfx::Rect(50, 50, 100, 100), root_window())); @@ -284,7 +284,7 @@ class TestEventClient : public client::EventClient { } // namespace -TEST_F(RootWindowTest, CanProcessEventsWithinSubtree) { +TEST_F(WindowEventDispatcherTest, CanProcessEventsWithinSubtree) { TestEventClient client(root_window()); test::TestWindowDelegate d; @@ -340,7 +340,7 @@ TEST_F(RootWindowTest, CanProcessEventsWithinSubtree) { w3->parent()->RemoveChild(w3.get()); } -TEST_F(RootWindowTest, IgnoreUnknownKeys) { +TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { test::TestEventHandler* filter = new ConsumeKeyHandler; root_window()->SetEventFilter(filter); // passes ownership @@ -355,7 +355,7 @@ TEST_F(RootWindowTest, IgnoreUnknownKeys) { EXPECT_EQ(1, filter->num_key_events()); } -TEST_F(RootWindowTest, NoDelegateWindowReceivesKeyEvents) { +TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); w1->Show(); w1->Focus(); @@ -372,7 +372,7 @@ TEST_F(RootWindowTest, NoDelegateWindowReceivesKeyEvents) { // Tests that touch-events that are beyond the bounds of the root-window do get // propagated to the event filters correctly with the root as the target. -TEST_F(RootWindowTest, TouchEventsOutsideBounds) { +TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) { test::TestEventHandler* filter = new test::TestEventHandler; root_window()->SetEventFilter(filter); // passes ownership @@ -391,7 +391,7 @@ TEST_F(RootWindowTest, TouchEventsOutsideBounds) { } // Tests that scroll events are dispatched correctly. -TEST_F(RootWindowTest, ScrollEventDispatch) { +TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) { base::TimeDelta now = ui::EventTimeForNow(); test::TestEventHandler* filter = new test::TestEventHandler; root_window()->SetEventFilter(filter); @@ -579,7 +579,7 @@ std::string EventTypesToString(const EventFilterRecorder::Events& events) { // Verifies a repost mouse event targets the window with capture (if there is // one). -TEST_F(RootWindowTest, RepostTargetsCaptureWindow) { +TEST_F(WindowEventDispatcherTest, RepostTargetsCaptureWindow) { // Set capture on |window| generate a mouse event (that is reposted) and not // over |window| and verify |window| gets it (|window| gets it because it has // capture). @@ -599,7 +599,7 @@ TEST_F(RootWindowTest, RepostTargetsCaptureWindow) { std::string::npos) << EventTypesToString(recorder->events()); } -TEST_F(RootWindowTest, MouseMovesHeld) { +TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -691,7 +691,7 @@ TEST_F(RootWindowTest, MouseMovesHeld) { filter->Reset(); } -TEST_F(RootWindowTest, TouchMovesHeld) { +TEST_F(WindowEventDispatcherTest, TouchMovesHeld) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -775,7 +775,7 @@ class HoldPointerOnScrollHandler : public test::TestEventHandler { // Tests that touch-move events don't contribute to an in-progress scroll // gesture if touch-move events are being held by the dispatcher. -TEST_F(RootWindowTest, TouchMovesHeldOnScroll) { +TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); test::TestWindowDelegate delegate; @@ -806,7 +806,7 @@ TEST_F(RootWindowTest, TouchMovesHeldOnScroll) { // Tests that synthetic mouse events are ignored when mouse // events are disabled. -TEST_F(RootWindowTest, DispatchSyntheticMouseEvents) { +TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -840,7 +840,7 @@ TEST_F(RootWindowTest, DispatchSyntheticMouseEvents) { // Tests that a mouse exit is dispatched to the last known cursor location // when the cursor becomes invisible. -TEST_F(RootWindowTest, DispatchMouseExitWhenCursorHidden) { +TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -936,7 +936,7 @@ class DeletingWindowDelegate : public test::TestWindowDelegate { DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); }; -TEST_F(RootWindowTest, DeleteWindowDuringDispatch) { +TEST_F(WindowEventDispatcherTest, DeleteWindowDuringDispatch) { // Verifies that we can delete a window during each phase of event handling. // Deleting the window should not cause a crash, only prevent further // processing from occurring. @@ -1006,7 +1006,8 @@ class DetachesParentOnTapDelegate : public test::TestWindowDelegate { // Tests that the gesture recognizer is reset for all child windows when a // window hides. No expectations, just checks that the test does not crash. -TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { +TEST_F(WindowEventDispatcherTest, + GestureRecognizerResetsTargetWhenParentHides) { scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); DetachesParentOnTapDelegate delegate; scoped_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); @@ -1057,7 +1058,7 @@ class NestedGestureDelegate : public test::TestWindowDelegate { } // namespace // Tests that gesture end is delivered after nested gesture processing. -TEST_F(RootWindowTest, GestureEndDeliveredAfterNestedGestures) { +TEST_F(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { NestedGestureDelegate d1(NULL, gfx::Point()); scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); w1->SetBounds(gfx::Rect(0, 0, 100, 100)); @@ -1077,7 +1078,7 @@ TEST_F(RootWindowTest, GestureEndDeliveredAfterNestedGestures) { } // Tests whether we can repost the Tap down gesture event. -TEST_F(RootWindowTest, RepostTapdownGestureTest) { +TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -1159,7 +1160,7 @@ class RepostGestureEventRecorder : public EventFilterRecorder { // Tests whether events which are generated after the reposted gesture event // are received after that. In this case the scroll sequence events should // be received after the reposted gesture event. -TEST_F(RootWindowTest, GestureRepostEventOrder) { +TEST_F(WindowEventDispatcherTest, GestureRepostEventOrder) { // Expected events at the end for the repost_target window defined below. const char kExpectedTargetEvents[] = // TODO)(rbyers): Gesture event reposting is disabled - crbug.com/279039. @@ -1241,7 +1242,7 @@ class OnMouseExitDeletingEventFilter : public EventFilterRecorder { // Tests that RootWindow drops mouse-moved event that is supposed to be sent to // a child, but the child is destroyed because of the synthesized mouse-exit // event generated on the previous mouse_moved_handler_. -TEST_F(RootWindowTest, DeleteWindowDuringMouseMovedDispatch) { +TEST_F(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { // Create window 1 and set its event filter. Window 1 will take ownership of // the event filter. scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); @@ -1314,17 +1315,18 @@ class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver { #endif // Verifies GetRootWindow() from ~Window returns a valid root. -TEST_F(RootWindowTest, MAYBE_ValidRootDuringDestruction) { +TEST_F(WindowEventDispatcherTest, MAYBE_ValidRootDuringDestruction) { bool got_destroying = false; bool has_valid_root = false; ValidRootDuringDestructionWindowObserver observer(&got_destroying, &has_valid_root); { - scoped_ptr<RootWindow> root_window( - new RootWindow(RootWindow::CreateParams(gfx::Rect(0, 0, 100, 100)))); - root_window->host()->InitHost(); - // Owned by RootWindow. - Window* w1 = CreateNormalWindow(1, root_window->window(), NULL); + scoped_ptr<WindowEventDispatcher> dispatcher( + new WindowEventDispatcher( + WindowEventDispatcher::CreateParams(gfx::Rect(0, 0, 100, 100)))); + dispatcher->host()->InitHost(); + // Owned by WindowEventDispatcher. + Window* w1 = CreateNormalWindow(1, dispatcher->window(), NULL); w1->AddObserver(&observer); } EXPECT_TRUE(got_destroying); @@ -1368,7 +1370,7 @@ class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate { // tracks the number of events with ui::EF_SHIFT_DOWN set (all reposted events // have EF_SHIFT_DOWN). When the first event is seen RepostEvent() is used to // schedule another reposted event. -TEST_F(RootWindowTest, DontResetHeldEvent) { +TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) { DontResetHeldEventWindowDelegate delegate(root_window()); scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); w1->SetBounds(gfx::Rect(0, 0, 40, 40)); @@ -1390,15 +1392,17 @@ TEST_F(RootWindowTest, DontResetHeldEvent) { namespace { -// See description above DeleteRootFromHeldMouseEvent for details. -class DeleteRootFromHeldMouseEventDelegate : public test::TestWindowDelegate { +// See description above DeleteDispatcherFromHeldMouseEvent for details. +class DeleteDispatcherFromHeldMouseEventDelegate + : public test::TestWindowDelegate { public: - explicit DeleteRootFromHeldMouseEventDelegate(aura::RootWindow* root) - : root_(root), + explicit DeleteDispatcherFromHeldMouseEventDelegate( + WindowEventDispatcher* dispatcher) + : dispatcher_(dispatcher), got_mouse_event_(false), got_destroy_(false) { } - virtual ~DeleteRootFromHeldMouseEventDelegate() {} + virtual ~DeleteDispatcherFromHeldMouseEventDelegate() {} bool got_mouse_event() const { return got_mouse_event_; } bool got_destroy() const { return got_destroy_; } @@ -1407,7 +1411,7 @@ class DeleteRootFromHeldMouseEventDelegate : public test::TestWindowDelegate { virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { if ((event->flags() & ui::EF_SHIFT_DOWN) != 0) { got_mouse_event_ = true; - delete root_; + delete dispatcher_; } } virtual void OnWindowDestroyed() OVERRIDE { @@ -1415,44 +1419,44 @@ class DeleteRootFromHeldMouseEventDelegate : public test::TestWindowDelegate { } private: - RootWindow* root_; + WindowEventDispatcher* dispatcher_; bool got_mouse_event_; bool got_destroy_; - DISALLOW_COPY_AND_ASSIGN(DeleteRootFromHeldMouseEventDelegate); + DISALLOW_COPY_AND_ASSIGN(DeleteDispatcherFromHeldMouseEventDelegate); }; } // namespace #if defined(USE_OZONE) // Creating multiple WindowTreeHostOzone instances is broken. -#define MAYBE_DeleteRootFromHeldMouseEvent DISABLED_DeleteRootFromHeldMouseEvent +#define MAYBE_DeleteDispatcherFromHeldMouseEvent DISABLED_DeleteDispatcherFromHeldMouseEvent #else -#define MAYBE_DeleteRootFromHeldMouseEvent DeleteRootFromHeldMouseEvent +#define MAYBE_DeleteDispatcherFromHeldMouseEvent DeleteDispatcherFromHeldMouseEvent #endif // Verifies if a RootWindow is deleted from dispatching a held mouse event we // don't crash. -TEST_F(RootWindowTest, MAYBE_DeleteRootFromHeldMouseEvent) { +TEST_F(WindowEventDispatcherTest, MAYBE_DeleteDispatcherFromHeldMouseEvent) { // Should be deleted by |delegate|. - RootWindow* r2 = - new RootWindow(RootWindow::CreateParams(gfx::Rect(0, 0, 100, 100))); - r2->host()->InitHost(); - DeleteRootFromHeldMouseEventDelegate delegate(r2); - // Owned by |r2|. - Window* w1 = CreateNormalWindow(1, r2->window(), &delegate); + WindowEventDispatcher* d2 = new WindowEventDispatcher( + WindowEventDispatcher::CreateParams(gfx::Rect(0, 0, 100, 100))); + d2->host()->InitHost(); + DeleteDispatcherFromHeldMouseEventDelegate delegate(d2); + // Owned by |d2|. + Window* w1 = CreateNormalWindow(1, d2->window(), &delegate); w1->SetBounds(gfx::Rect(0, 0, 40, 40)); ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), ui::EF_SHIFT_DOWN, 0); - r2->RepostEvent(pressed); + d2->RepostEvent(pressed); // RunAllPendingInMessageLoop() to make sure the |pressed| is run. RunAllPendingInMessageLoop(); EXPECT_TRUE(delegate.got_mouse_event()); EXPECT_TRUE(delegate.got_destroy()); } -TEST_F(RootWindowTest, WindowHideCancelsActiveTouches) { +TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -1473,7 +1477,7 @@ TEST_F(RootWindowTest, WindowHideCancelsActiveTouches) { EventTypesToString(filter->events())); } -TEST_F(RootWindowTest, WindowHideCancelsActiveGestures) { +TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); // passes ownership @@ -1507,7 +1511,7 @@ TEST_F(RootWindowTest, WindowHideCancelsActiveGestures) { // Places two windows side by side. Presses down on one window, and starts a // scroll. Sets capture on the other window and ensures that the "ending" events // aren't sent to the window which gained capture. -TEST_F(RootWindowTest, EndingEventDoesntRetarget) { +TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) { scoped_ptr<Window> window1(CreateNormalWindow(1, root_window(), NULL)); window1->SetBounds(gfx::Rect(0, 0, 40, 40)); @@ -1576,7 +1580,7 @@ class CaptureWindowTracker : public test::TestWindowDelegate { } // Verifies handling loss of capture by the capture window being hidden. -TEST_F(RootWindowTest, CaptureWindowHidden) { +TEST_F(WindowEventDispatcherTest, CaptureWindowHidden) { CaptureWindowTracker capture_window_tracker; capture_window_tracker.CreateCaptureWindow(root_window()); capture_window_tracker.capture_window()->Hide(); @@ -1584,7 +1588,7 @@ TEST_F(RootWindowTest, CaptureWindowHidden) { } // Verifies handling loss of capture by the capture window being destroyed. -TEST_F(RootWindowTest, CaptureWindowDestroyed) { +TEST_F(WindowEventDispatcherTest, CaptureWindowDestroyed) { CaptureWindowTracker capture_window_tracker; capture_window_tracker.CreateCaptureWindow(root_window()); capture_window_tracker.reset(); @@ -1607,10 +1611,11 @@ class ExitMessageLoopOnMousePress : public test::TestEventHandler { DISALLOW_COPY_AND_ASSIGN(ExitMessageLoopOnMousePress); }; -class RootWindowTestWithMessageLoop : public RootWindowTest { +class WindowEventDispatcherTestWithMessageLoop + : public WindowEventDispatcherTest { public: - RootWindowTestWithMessageLoop() {} - virtual ~RootWindowTestWithMessageLoop() {} + WindowEventDispatcherTestWithMessageLoop() {} + virtual ~WindowEventDispatcherTestWithMessageLoop() {} void RunTest() { // Reset any event the window may have received when bringing up the window @@ -1623,7 +1628,7 @@ class RootWindowTestWithMessageLoop : public RootWindowTest { ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), ui::EF_NONE, ui::EF_NONE); message_loop()->PostTask(FROM_HERE, - base::Bind(&RootWindow::RepostEvent, + base::Bind(&WindowEventDispatcher::RepostEvent, base::Unretained(dispatcher()), mouse)); message_loop()->PostTask(FROM_HERE, @@ -1644,46 +1649,47 @@ class RootWindowTestWithMessageLoop : public RootWindowTest { protected: virtual void SetUp() OVERRIDE { - RootWindowTest::SetUp(); + WindowEventDispatcherTest::SetUp(); window_.reset(CreateNormalWindow(1, root_window(), NULL)); window_->AddPreTargetHandler(&handler_); } virtual void TearDown() OVERRIDE { window_.reset(); - RootWindowTest::TearDown(); + WindowEventDispatcherTest::TearDown(); } private: scoped_ptr<Window> window_; ExitMessageLoopOnMousePress handler_; - DISALLOW_COPY_AND_ASSIGN(RootWindowTestWithMessageLoop); + DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcherTestWithMessageLoop); }; -TEST_F(RootWindowTestWithMessageLoop, EventRepostedInNonNestedLoop) { +TEST_F(WindowEventDispatcherTestWithMessageLoop, EventRepostedInNonNestedLoop) { CHECK(!message_loop()->is_running()); // Perform the test in a callback, so that it runs after the message-loop // starts. - message_loop()->PostTask(FROM_HERE, - base::Bind(&RootWindowTestWithMessageLoop::RunTest, - base::Unretained(this))); + message_loop()->PostTask( + FROM_HERE, base::Bind( + &WindowEventDispatcherTestWithMessageLoop::RunTest, + base::Unretained(this))); message_loop()->Run(); } -class RootWindowTestInHighDPI : public RootWindowTest { +class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { public: - RootWindowTestInHighDPI() {} - virtual ~RootWindowTestInHighDPI() {} + WindowEventDispatcherTestInHighDPI() {} + virtual ~WindowEventDispatcherTestInHighDPI() {} protected: virtual void SetUp() OVERRIDE { - RootWindowTest::SetUp(); + WindowEventDispatcherTest::SetUp(); test_screen()->SetDeviceScaleFactor(2.f); } }; -TEST_F(RootWindowTestInHighDPI, EventLocationTransform) { +TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { test::TestWindowDelegate delegate; scoped_ptr<aura::Window> child(test::CreateTestWindowWithDelegate(&delegate, 1234, gfx::Rect(20, 20, 100, 100), root_window())); @@ -1719,7 +1725,7 @@ TEST_F(RootWindowTestInHighDPI, EventLocationTransform) { root_window()->RemovePreTargetHandler(&handler_root); } -TEST_F(RootWindowTestInHighDPI, TouchMovesHeldOnScroll) { +TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { EventFilterRecorder* filter = new EventFilterRecorder; root_window()->SetEventFilter(filter); test::TestWindowDelegate delegate; @@ -1767,7 +1773,7 @@ class SelfDestructDelegate : public test::TestWindowDelegate { DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate); }; -TEST_F(RootWindowTest, SynthesizedLocatedEvent) { +TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { test::EventGenerator generator(root_window()); generator.MoveMouseTo(10, 10); EXPECT_EQ("10,10", diff --git a/ui/aura/test/aura_test_base.h b/ui/aura/test/aura_test_base.h index 5b07bf7..5fb94e7 100644 --- a/ui/aura/test/aura_test_base.h +++ b/ui/aura/test/aura_test_base.h @@ -12,9 +12,9 @@ #include "ui/aura/test/aura_test_helper.h" namespace aura { -class RootWindow; class Window; class WindowDelegate; +class WindowEventDispatcher; namespace test { // A base class for aura unit tests. @@ -42,7 +42,7 @@ class AuraTestBase : public testing::Test { bool DispatchEventUsingWindowDispatcher(ui::Event* event); Window* root_window() { return helper_->root_window(); } - RootWindow* dispatcher() { return helper_->dispatcher(); } + WindowEventDispatcher* dispatcher() { return helper_->dispatcher(); } TestScreen* test_screen() { return helper_->test_screen(); } private: diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc index 9dc1181..b05f21f 100644 --- a/ui/aura/test/aura_test_helper.cc +++ b/ui/aura/test/aura_test_helper.cc @@ -35,7 +35,7 @@ namespace test { AuraTestHelper::AuraTestHelper(base::MessageLoopForUI* message_loop) : setup_called_(false), teardown_called_(false), - owns_root_window_(false) { + owns_dispatcher_(false) { DCHECK(message_loop); message_loop_ = message_loop; // Disable animations during tests. @@ -66,7 +66,7 @@ void AuraTestHelper::SetUp() { test_screen_.reset(TestScreen::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); - root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); + dispatcher_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); focus_client_.reset(new TestFocusClient); client::SetFocusClient(root_window(), focus_client_.get()); @@ -92,7 +92,7 @@ void AuraTestHelper::TearDown() { capture_client_.reset(); focus_client_.reset(); client::SetFocusClient(root_window(), NULL); - root_window_.reset(); + dispatcher_.reset(); ui::GestureRecognizer::Reset(); test_screen_.reset(); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); diff --git a/ui/aura/test/aura_test_helper.h b/ui/aura/test/aura_test_helper.h index 1bd937d..cbf937f 100644 --- a/ui/aura/test/aura_test_helper.h +++ b/ui/aura/test/aura_test_helper.h @@ -46,8 +46,8 @@ class AuraTestHelper { // Flushes message loop. void RunAllPendingInMessageLoop(); - Window* root_window() { return root_window_->window(); } - RootWindow* dispatcher() { return root_window_.get(); } + Window* root_window() { return dispatcher_->window(); } + WindowEventDispatcher* dispatcher() { return dispatcher_.get(); } TestScreen* test_screen() { return test_screen_.get(); } @@ -55,8 +55,8 @@ class AuraTestHelper { base::MessageLoopForUI* message_loop_; bool setup_called_; bool teardown_called_; - bool owns_root_window_; - scoped_ptr<RootWindow> root_window_; + bool owns_dispatcher_; + scoped_ptr<WindowEventDispatcher> dispatcher_; scoped_ptr<TestWindowTreeClient> stacking_client_; scoped_ptr<client::DefaultActivationClient> activation_client_; scoped_ptr<client::DefaultCaptureClient> capture_client_; diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc index 422407d..97b8509 100644 --- a/ui/aura/test/event_generator.cc +++ b/ui/aura/test/event_generator.cc @@ -39,7 +39,8 @@ class DefaultEventGeneratorDelegate : public EventGeneratorDelegate { virtual ~DefaultEventGeneratorDelegate() {} // EventGeneratorDelegate overrides: - virtual RootWindow* GetRootWindowAt(const gfx::Point& point) const OVERRIDE { + virtual WindowEventDispatcher* GetDispatcherAt( + const gfx::Point& point) const OVERRIDE { return root_window_->GetDispatcher(); } @@ -82,7 +83,7 @@ const int kAllButtonMask = ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON; EventGenerator::EventGenerator(Window* root_window) : delegate_(new DefaultEventGeneratorDelegate(root_window)), - current_root_window_(delegate_->GetRootWindowAt(current_location_)), + current_dispatcher_(delegate_->GetDispatcherAt(current_location_)), flags_(0), grab_(false), async_(false) { @@ -91,7 +92,7 @@ EventGenerator::EventGenerator(Window* root_window) EventGenerator::EventGenerator(Window* root_window, const gfx::Point& point) : delegate_(new DefaultEventGeneratorDelegate(root_window)), current_location_(point), - current_root_window_(delegate_->GetRootWindowAt(current_location_)), + current_dispatcher_(delegate_->GetDispatcherAt(current_location_)), flags_(0), grab_(false), async_(false) { @@ -100,7 +101,7 @@ EventGenerator::EventGenerator(Window* root_window, const gfx::Point& point) EventGenerator::EventGenerator(Window* root_window, Window* window) : delegate_(new DefaultEventGeneratorDelegate(root_window)), current_location_(CenterOfWindow(window)), - current_root_window_(delegate_->GetRootWindowAt(current_location_)), + current_dispatcher_(delegate_->GetDispatcherAt(current_location_)), flags_(0), grab_(false), async_(false) { @@ -108,7 +109,7 @@ EventGenerator::EventGenerator(Window* root_window, Window* window) EventGenerator::EventGenerator(EventGeneratorDelegate* delegate) : delegate_(delegate), - current_root_window_(delegate_->GetRootWindowAt(current_location_)), + current_dispatcher_(delegate_->GetDispatcherAt(current_location_)), flags_(0), grab_(false), async_(false) { @@ -151,7 +152,7 @@ void EventGenerator::ReleaseRightButton() { void EventGenerator::SendMouseExit() { gfx::Point exit_location(current_location_); - ConvertPointToTarget(current_root_window_->window(), &exit_location); + ConvertPointToTarget(current_dispatcher_->window(), &exit_location); ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, flags_, 0); Dispatch(&mouseev); @@ -164,7 +165,7 @@ void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) { Dispatch(&mouseev); current_location_ = point_in_host; - current_root_window_->host()->ConvertPointFromHost(¤t_location_); + current_dispatcher_->host()->ConvertPointFromHost(¤t_location_); } void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen, @@ -179,8 +180,8 @@ void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen, step.Scale(i / count); gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step); if (!grab_) - UpdateCurrentRootWindow(move_point); - ConvertPointToTarget(current_root_window_->window(), &move_point); + UpdateCurrentDispatcher(move_point); + ConvertPointToTarget(current_dispatcher_->window(), &move_point); ui::MouseEvent mouseev(event_type, move_point, move_point, flags_, 0); Dispatch(&mouseev); } @@ -225,7 +226,7 @@ void EventGenerator::MoveTouchId(const gfx::Point& point, int touch_id) { Dispatch(&touchev); if (!grab_) - UpdateCurrentRootWindow(point); + UpdateCurrentDispatcher(point); } void EventGenerator::ReleaseTouch() { @@ -523,8 +524,8 @@ void EventGenerator::DispatchKeyEvent(bool is_press, Dispatch(&keyev); } -void EventGenerator::UpdateCurrentRootWindow(const gfx::Point& point) { - current_root_window_ = delegate_->GetRootWindowAt(point); +void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) { + current_dispatcher_ = delegate_->GetDispatcherAt(point); } void EventGenerator::PressButton(int flag) { @@ -573,7 +574,7 @@ void EventGenerator::ConvertPointToTarget(const aura::Window* target, gfx::Point EventGenerator::GetLocationInCurrentRoot() const { gfx::Point p(current_location_); - ConvertPointToTarget(current_root_window_->window(), &p); + ConvertPointToTarget(current_dispatcher_->window(), &p); return p; } @@ -607,7 +608,7 @@ void EventGenerator::DoDispatchEvent(ui::Event* event, bool async) { } pending_events_.push_back(pending_event); } else { - ui::EventDispatchDetails details = current_root_window_->OnEventFromSource( + ui::EventDispatchDetails details = current_dispatcher_->OnEventFromSource( event); CHECK(!details.dispatcher_destroyed); } diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h index ee9bf51..97358c4 100644 --- a/ui/aura/test/event_generator.h +++ b/ui/aura/test/event_generator.h @@ -28,8 +28,8 @@ class TouchEvent; } namespace aura { -class RootWindow; class Window; +class WindowEventDispatcher; namespace client { class ScreenPositionClient; @@ -47,32 +47,28 @@ class EventGeneratorDelegate { virtual ~EventGeneratorDelegate() {} // Returns a root window for given point. - virtual RootWindow* GetRootWindowAt(const gfx::Point& point) const = 0; + virtual WindowEventDispatcher* GetDispatcherAt( + const gfx::Point& point) const = 0; // Returns the screen position client that determines the // coordinates used in EventGenerator. EventGenerator uses - // RootWindow's coordinate if this retruns NULL. + // root Window's coordinate if this returns NULL. virtual client::ScreenPositionClient* GetScreenPositionClient( const aura::Window* window) const = 0; }; // EventGenerator is a tool that generates and dispatch events. -// Unlike |ui_controls| package in ui/base/test, this does not -// generate platform native events. Insetad, it directly posts event -// to |aura::RootWindow| synchronously. - -// Advantage of using this class, compared to |ui_controls| is that -// you can write the tests that involves events in synchronus -// way. There is no need to wait for native +// Unlike |ui_controls| package in ui/base/test, this does not generate platform +// native events. Instead, it sends events to |aura::WindowEventDispatcher| +// synchronously. // -// On the other hand, this class is not suited for the following -// cases: +// This class is not suited for the following cases: // // 1) If your test depends on native events (ui::Event::native_event()). // This return is empty/NULL event with EventGenerator. // 2) If your test involves nested message loop, such as // menu or drag & drop. Because this class directly -// post an event to RootWindow, this event will not be +// post an event to WindowEventDispatcher, this event will not be // handled in the nested message loop. // 3) Similarly, |base::MessagePumpObserver| will not be invoked. // 4) Any other code that requires native events, such as @@ -311,18 +307,18 @@ class EventGenerator { // TODO(yusukes): Support native_event() on all platforms. void ReleaseKey(ui::KeyboardCode key_code, int flags); - // Dispatch the event to the RootWindow. + // Dispatch the event to the WindowEventDispatcher. void Dispatch(ui::Event* event); - void set_current_root_window(RootWindow* root_window) { - current_root_window_ = root_window; + void set_current_dispatcher(WindowEventDispatcher* dispatcher) { + current_dispatcher_ = dispatcher; } private: - // Dispatch a key event to the RootWindow. + // Dispatch a key event to the WindowEventDispatcher. void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); - void UpdateCurrentRootWindow(const gfx::Point& point); + void UpdateCurrentDispatcher(const gfx::Point& point); void PressButton(int flag); void ReleaseButton(int flag); @@ -341,7 +337,7 @@ class EventGenerator { scoped_ptr<EventGeneratorDelegate> delegate_; gfx::Point current_location_; - RootWindow* current_root_window_; + WindowEventDispatcher* current_dispatcher_; int flags_; bool grab_; std::list<ui::Event*> pending_events_; diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index 6c7db3f..7e79608 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc @@ -31,25 +31,26 @@ TestScreen* TestScreen::CreateFullscreen() { TestScreen::~TestScreen() { } -RootWindow* TestScreen::CreateRootWindowForPrimaryDisplay() { - DCHECK(!root_window_); - root_window_ = new RootWindow( - RootWindow::CreateParams(gfx::Rect(display_.GetSizeInPixel()))); - root_window_->window()->AddObserver(this); - root_window_->host()->InitHost(); - return root_window_; +WindowEventDispatcher* TestScreen::CreateRootWindowForPrimaryDisplay() { + DCHECK(!dispatcher_); + dispatcher_ = new WindowEventDispatcher( + WindowEventDispatcher::CreateParams( + gfx::Rect(display_.GetSizeInPixel()))); + dispatcher_->window()->AddObserver(this); + dispatcher_->host()->InitHost(); + return dispatcher_; } void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel); - root_window_->host()->NotifyHostResized(bounds_in_pixel.size()); + dispatcher_->host()->NotifyHostResized(bounds_in_pixel.size()); } void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) { display_.set_rotation(rotation); // TODO(oshima|mukai): Update the display_ as well. - root_window_->host()->SetTransform( + dispatcher_->host()->SetTransform( GetRotationTransform() * GetUIScaleTransform()); } @@ -59,7 +60,7 @@ void TestScreen::SetUIScale(float ui_scale) { gfx::Rect new_bounds = gfx::ToNearestRect( gfx::ScaleRect(bounds_in_pixel, 1.0f / ui_scale)); display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds); - root_window_->host()->SetTransform( + dispatcher_->host()->SetTransform( GetRotationTransform() * GetUIScaleTransform()); } @@ -99,14 +100,14 @@ bool TestScreen::IsDIPEnabled() { void TestScreen::OnWindowBoundsChanged( Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { - DCHECK_EQ(root_window_->window(), window); + DCHECK_EQ(dispatcher_->window(), window); display_.SetSize(gfx::ToFlooredSize( gfx::ScaleSize(new_bounds.size(), display_.device_scale_factor()))); } void TestScreen::OnWindowDestroying(Window* window) { - if (root_window_->window() == window) - root_window_ = NULL; + if (dispatcher_->window() == window) + dispatcher_ = NULL; } gfx::Point TestScreen::GetCursorScreenPoint() { @@ -118,7 +119,7 @@ gfx::NativeWindow TestScreen::GetWindowUnderCursor() { } gfx::NativeWindow TestScreen::GetWindowAtScreenPoint(const gfx::Point& point) { - return root_window_->window()->GetTopWindowContainingPoint(point); + return dispatcher_->window()->GetTopWindowContainingPoint(point); } int TestScreen::GetNumDisplays() const { @@ -153,7 +154,7 @@ void TestScreen::RemoveObserver(gfx::DisplayObserver* observer) { } TestScreen::TestScreen(const gfx::Rect& screen_bounds) - : root_window_(NULL), + : dispatcher_(NULL), ui_scale_(1.0f) { static int64 synthesized_display_id = 2000; display_.set_id(synthesized_display_id++); diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h index c958279..c344d3c 100644 --- a/ui/aura/test/test_screen.h +++ b/ui/aura/test/test_screen.h @@ -16,8 +16,8 @@ class Transform; } namespace aura { -class RootWindow; class Window; +class WindowEventDispatcher; // A minimal, testing Aura implementation of gfx::Screen. class TestScreen : public gfx::Screen, @@ -28,7 +28,9 @@ class TestScreen : public gfx::Screen, static TestScreen* CreateFullscreen(); virtual ~TestScreen(); - RootWindow* CreateRootWindowForPrimaryDisplay(); + // TODO(beng): Rename to CreateHostForPrimaryDisplay() and make it return + // a WTH. + WindowEventDispatcher* CreateRootWindowForPrimaryDisplay(); void SetDeviceScaleFactor(float device_scale_fator); void SetDisplayRotation(gfx::Display::Rotation rotation); @@ -65,7 +67,7 @@ class TestScreen : public gfx::Screen, private: explicit TestScreen(const gfx::Rect& screen_bounds); - aura::RootWindow* root_window_; + aura::WindowEventDispatcher* dispatcher_; gfx::Display display_; diff --git a/ui/aura/test/ui_controls_factory_aura.h b/ui/aura/test/ui_controls_factory_aura.h index 800e927..777f0d3 100644 --- a/ui/aura/test/ui_controls_factory_aura.h +++ b/ui/aura/test/ui_controls_factory_aura.h @@ -8,11 +8,13 @@ #include "ui/base/test/ui_controls_aura.h" namespace aura { -class RootWindow; +class WindowEventDispatcher; namespace test { -ui_controls::UIControlsAura* CreateUIControlsAura(RootWindow* root_window); +// TODO(beng): Should be changed to take a WindowTreeHost. +ui_controls::UIControlsAura* CreateUIControlsAura( + WindowEventDispatcher* dispatcher); } // namespace test } // namespace aura diff --git a/ui/aura/test/ui_controls_factory_aurawin.cc b/ui/aura/test/ui_controls_factory_aurawin.cc index 2b2d6f6..3c8dc4c 100644 --- a/ui/aura/test/ui_controls_factory_aurawin.cc +++ b/ui/aura/test/ui_controls_factory_aurawin.cc @@ -84,7 +84,7 @@ class UIControlsWin : public UIControlsAura { } // namespace -UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { +UIControlsAura* CreateUIControlsAura(WindowEventDispatcher* dispatcher) { return new UIControlsWin(); } diff --git a/ui/aura/test/ui_controls_factory_aurax11.cc b/ui/aura/test/ui_controls_factory_aurax11.cc index d505e36..9a78594 100644 --- a/ui/aura/test/ui_controls_factory_aurax11.cc +++ b/ui/aura/test/ui_controls_factory_aurax11.cc @@ -5,11 +5,6 @@ #include <X11/keysym.h> #include <X11/Xlib.h> -// X macro fail. -#if defined(RootWindow) -#undef RootWindow -#endif - #include "base/logging.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/env.h" @@ -85,7 +80,7 @@ bool Matcher(const base::NativeEvent& event) { class UIControlsX11 : public UIControlsAura { public: - UIControlsX11(aura::RootWindow* root_window) : root_window_(root_window) { + UIControlsX11(WindowEventDispatcher* dispatcher) : dispatcher_(dispatcher) { } virtual bool SendKeyPress(gfx::NativeWindow window, @@ -118,11 +113,11 @@ class UIControlsX11 : public UIControlsAura { xevent.xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), ui::XKeysymForWindowsKeyCode(key, shift)); - root_window_->host()->PostNativeEvent(&xevent); + dispatcher_->host()->PostNativeEvent(&xevent); // Send key release events. xevent.xkey.type = KeyRelease; - root_window_->host()->PostNativeEvent(&xevent); + dispatcher_->host()->PostNativeEvent(&xevent); if (alt) UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); if (shift) @@ -143,19 +138,19 @@ class UIControlsX11 : public UIControlsAura { const base::Closure& closure) OVERRIDE { gfx::Point root_location(screen_x, screen_y); aura::client::ScreenPositionClient* screen_position_client = - aura::client::GetScreenPositionClient(root_window_->window()); + aura::client::GetScreenPositionClient(dispatcher_->window()); if (screen_position_client) { - screen_position_client->ConvertPointFromScreen(root_window_->window(), + screen_position_client->ConvertPointFromScreen(dispatcher_->window(), &root_location); } gfx::Point root_current_location; - root_window_->host()->QueryMouseLocation(&root_current_location); - root_window_->host()->ConvertPointFromHost(&root_current_location); + dispatcher_->host()->QueryMouseLocation(&root_current_location); + dispatcher_->host()->ConvertPointFromHost(&root_current_location); if (root_location != root_current_location && button_down_mask == 0) { // Move the cursor because EnterNotify/LeaveNotify are generated with the // current mouse position as a result of XGrabPointer() - root_window_->window()->MoveCursorTo(root_location); + dispatcher_->window()->MoveCursorTo(root_location); } else { XEvent xevent = {0}; XMotionEvent* xmotion = &xevent.xmotion; @@ -164,8 +159,8 @@ class UIControlsX11 : public UIControlsAura { xmotion->y = root_location.y(); xmotion->state = button_down_mask; xmotion->same_screen = True; - // RootWindow will take care of other necessary fields. - root_window_->host()->PostNativeEvent(&xevent); + // WindowEventDispatcher will take care of other necessary fields. + dispatcher_->host()->PostNativeEvent(&xevent); } RunClosureAfterAllPendingUIEvents(closure); return true; @@ -181,9 +176,9 @@ class UIControlsX11 : public UIControlsAura { XButtonEvent* xbutton = &xevent.xbutton; gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location(); aura::client::ScreenPositionClient* screen_position_client = - aura::client::GetScreenPositionClient(root_window_->window()); + aura::client::GetScreenPositionClient(dispatcher_->window()); if (screen_position_client) { - screen_position_client->ConvertPointFromScreen(root_window_->window(), + screen_position_client->ConvertPointFromScreen(dispatcher_->window(), &mouse_loc); } xbutton->x = mouse_loc.x(); @@ -203,15 +198,15 @@ class UIControlsX11 : public UIControlsAura { xbutton->state = Button3Mask; break; } - // RootWindow will take care of other necessary fields. + // WindowEventDispatcher will take care of other necessary fields. if (state & DOWN) { xevent.xbutton.type = ButtonPress; - root_window_->host()->PostNativeEvent(&xevent); + dispatcher_->host()->PostNativeEvent(&xevent); button_down_mask |= xbutton->state; } if (state & UP) { xevent.xbutton.type = ButtonRelease; - root_window_->host()->PostNativeEvent(&xevent); + dispatcher_->host()->PostNativeEvent(&xevent); button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state; } RunClosureAfterAllPendingUIEvents(closure); @@ -233,7 +228,7 @@ class UIControlsX11 : public UIControlsAura { marker_event->xclient.format = 8; } marker_event->xclient.message_type = MarkerEventAtom(); - root_window_->host()->PostNativeEvent(marker_event); + dispatcher_->host()->PostNativeEvent(marker_event); new EventWaiter(closure, &Matcher); } private: @@ -242,7 +237,7 @@ class UIControlsX11 : public UIControlsAura { unsigned int mask) { xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), keysym); - root_window_->host()->PostNativeEvent(xevent); + dispatcher_->host()->PostNativeEvent(xevent); xevent->xkey.state |= mask; } @@ -252,18 +247,18 @@ class UIControlsX11 : public UIControlsAura { xevent->xkey.state ^= mask; xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), keysym); - root_window_->host()->PostNativeEvent(xevent); + dispatcher_->host()->PostNativeEvent(xevent); } - aura::RootWindow* root_window_; + WindowEventDispatcher* dispatcher_; DISALLOW_COPY_AND_ASSIGN(UIControlsX11); }; } // namespace -UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { - return new UIControlsX11(root_window); +UIControlsAura* CreateUIControlsAura(WindowEventDispatcher* dispatcher) { + return new UIControlsX11(dispatcher); } } // namespace test diff --git a/ui/aura/window.h b/ui/aura/window.h index 6b239a0..d0f3b6e 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -44,13 +44,10 @@ class Texture; namespace aura { class LayoutManager; -class RootWindow; class WindowDelegate; +class WindowEventDispatcher; class WindowObserver; -// TODO(beng): remove once RootWindow is renamed. -typedef RootWindow WindowEventDispatcher; - // Defined in window_property.h (which we do not include) template<typename T> struct WindowProperty; @@ -347,7 +344,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, private: friend class test::WindowTestApi; friend class LayoutManager; - friend class RootWindow; + friend class WindowEventDispatcher; friend class WindowTargeter; // Called by the public {Set,Get,Clear}Property functions. diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc index 7e8749d..9143b85 100644 --- a/ui/aura/window_tree_host.cc +++ b/ui/aura/window_tree_host.cc @@ -81,7 +81,7 @@ void WindowTreeHost::InitHost() { window()->Init(aura::WINDOW_LAYER_NOT_DRAWN); InitCompositor(); UpdateRootWindowSize(GetBounds().size()); - Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsRootWindow()); + Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsDispatcher()); window()->Show(); } @@ -98,7 +98,7 @@ aura::Window* WindowTreeHost::window() { } const aura::Window* WindowTreeHost::window() const { - return delegate_->AsRootWindow()->window(); + return delegate_->AsDispatcher()->window(); } void WindowTreeHost::SetRootWindowTransformer( @@ -174,8 +174,8 @@ void WindowTreeHost::OnCursorVisibilityChanged(bool show) { // visible because that can only happen in response to a mouse event, which // will trigger its own mouse enter. if (!show) { - delegate_->AsRootWindow()->DispatchMouseExitAtPoint( - delegate_->AsRootWindow()->GetLastMouseLocationInRoot()); + delegate_->AsDispatcher()->DispatchMouseExitAtPoint( + delegate_->AsDispatcher()->GetLastMouseLocationInRoot()); } OnCursorVisibilityChangedNative(show); @@ -193,6 +193,10 @@ void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) { MoveCursorToInternal(root_location, host_location); } +WindowEventDispatcher* WindowTreeHost::GetDispatcher() { + return delegate_->AsDispatcher(); +} + //////////////////////////////////////////////////////////////////////////////// // WindowTreeHost, protected: diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h index f8eb6cc..6567672f 100644 --- a/ui/aura/window_tree_host.h +++ b/ui/aura/window_tree_host.h @@ -26,10 +26,9 @@ class Compositor; } namespace aura { - -class RootWindow; -class WindowTreeHostDelegate; class RootWindowTransformer; +class WindowEventDispatcher; +class WindowTreeHostDelegate; // WindowTreeHost bridges between a native window and the embedded RootWindow. // It provides the accelerated widget and maps events from the native os to @@ -103,7 +102,7 @@ class AURA_EXPORT WindowTreeHost { gfx::NativeCursor last_cursor() const { return last_cursor_; } - virtual RootWindow* GetRootWindow() = 0; + WindowEventDispatcher* GetDispatcher(); // Returns the accelerated widget. virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; diff --git a/ui/aura/window_tree_host_delegate.h b/ui/aura/window_tree_host_delegate.h index 67044ab..203f016 100644 --- a/ui/aura/window_tree_host_delegate.h +++ b/ui/aura/window_tree_host_delegate.h @@ -47,8 +47,8 @@ class AURA_EXPORT WindowTreeHostDelegate { virtual void OnCursorMovedToRootLocation(const gfx::Point& root_location) = 0; - virtual RootWindow* AsRootWindow() = 0; - virtual const RootWindow* AsRootWindow() const = 0; + virtual WindowEventDispatcher* AsDispatcher() = 0; + virtual const WindowEventDispatcher* AsDispatcher() const = 0; virtual ui::EventProcessor* GetEventProcessor() = 0; diff --git a/ui/aura/window_tree_host_mac.h b/ui/aura/window_tree_host_mac.h index a45add8..cdce4db 100644 --- a/ui/aura/window_tree_host_mac.h +++ b/ui/aura/window_tree_host_mac.h @@ -30,7 +30,6 @@ class AURA_EXPORT WindowTreeHostMac : public WindowTreeHost { private: // WindowTreeHost Overrides. - virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; diff --git a/ui/aura/window_tree_host_mac.mm b/ui/aura/window_tree_host_mac.mm index fa34373..82ea978 100644 --- a/ui/aura/window_tree_host_mac.mm +++ b/ui/aura/window_tree_host_mac.mm @@ -23,10 +23,6 @@ WindowTreeHostMac::WindowTreeHostMac(const gfx::Rect& bounds) { WindowTreeHostMac::~WindowTreeHostMac() { } -RootWindow* WindowTreeHostMac::GetRootWindow() { - return delegate_->AsRootWindow(); -} - gfx::AcceleratedWidget WindowTreeHostMac::GetAcceleratedWidget() { return [window_ contentView]; } diff --git a/ui/aura/window_tree_host_ozone.cc b/ui/aura/window_tree_host_ozone.cc index d2dfafb..0a8057b 100644 --- a/ui/aura/window_tree_host_ozone.cc +++ b/ui/aura/window_tree_host_ozone.cc @@ -42,10 +42,6 @@ uint32_t WindowTreeHostOzone::Dispatch(const base::NativeEvent& ne) { return POST_DISPATCH_NONE; } -RootWindow* WindowTreeHostOzone::GetRootWindow() { - return delegate_->AsRootWindow(); -} - gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { return widget_; } diff --git a/ui/aura/window_tree_host_ozone.h b/ui/aura/window_tree_host_ozone.h index 2690d0c..4f4c709 100644 --- a/ui/aura/window_tree_host_ozone.h +++ b/ui/aura/window_tree_host_ozone.h @@ -28,7 +28,6 @@ class WindowTreeHostOzone : public WindowTreeHost, virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; // WindowTreeHost Overrides. - virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; diff --git a/ui/aura/window_tree_host_win.cc b/ui/aura/window_tree_host_win.cc index e1f9ea2..53851df 100644 --- a/ui/aura/window_tree_host_win.cc +++ b/ui/aura/window_tree_host_win.cc @@ -56,10 +56,6 @@ WindowTreeHostWin::~WindowTreeHostWin() { DestroyWindow(hwnd()); } -RootWindow* WindowTreeHostWin::GetRootWindow() { - return delegate_->AsRootWindow(); -} - gfx::AcceleratedWidget WindowTreeHostWin::GetAcceleratedWidget() { return hwnd(); } @@ -138,8 +134,8 @@ void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { // the window size may not have changed. float current_scale = compositor()->device_scale_factor(); float new_scale = gfx::Screen::GetScreenFor( - delegate_->AsRootWindow()->window())->GetDisplayNearestWindow( - delegate_->AsRootWindow()->window()).device_scale_factor(); + delegate_->AsDispatcher()->window())->GetDisplayNearestWindow( + delegate_->AsDispatcher()->window()).device_scale_factor(); if (current_scale != new_scale) NotifyHostResized(bounds.size()); } @@ -174,7 +170,7 @@ void WindowTreeHostWin::ReleaseCapture() { bool WindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) { client::CursorClient* cursor_client = - client::GetCursorClient(GetRootWindow()->window()); + client::GetCursorClient(GetDispatcher()->window()); if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { *location_return = gfx::Point(0, 0); return false; diff --git a/ui/aura/window_tree_host_win.h b/ui/aura/window_tree_host_win.h index 7576d8e..4c8d4ce 100644 --- a/ui/aura/window_tree_host_win.h +++ b/ui/aura/window_tree_host_win.h @@ -20,7 +20,6 @@ class WindowTreeHostWin : public WindowTreeHost, WindowTreeHostWin(const gfx::Rect& bounds); virtual ~WindowTreeHostWin(); // WindowTreeHost: - virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc index adc9415..9ec1e6f 100644 --- a/ui/aura/window_tree_host_x11.cc +++ b/ui/aura/window_tree_host_x11.cc @@ -362,7 +362,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { switch (xev->type) { case EnterNotify: { - aura::Window* root_window = GetRootWindow()->window(); + aura::Window* root_window = GetDispatcher()->window(); client::CursorClient* cursor_client = client::GetCursorClient(root_window); if (cursor_client) { @@ -402,7 +402,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { client::UserActionClient* gesture_client = - client::GetUserActionClient(delegate_->AsRootWindow()->window()); + client::GetUserActionClient(delegate_->AsDispatcher()->window()); if (gesture_client) { gesture_client->OnUserAction( static_cast<int>(xev->xbutton.button) == kBackMouseButton ? @@ -468,7 +468,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { // We have received a close message from the window manager. - delegate_->AsRootWindow()->OnWindowTreeHostCloseRequested(); + delegate_->AsDispatcher()->OnWindowTreeHostCloseRequested(); } else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) { XEvent reply_event = *xev; reply_event.xclient.window = x_root_window_; @@ -486,7 +486,7 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { case MappingModifier: case MappingKeyboard: XRefreshKeyboardMapping(&xev->xmapping); - delegate_->AsRootWindow()->OnKeyboardMappingChanged(); + delegate_->AsDispatcher()->OnKeyboardMappingChanged(); break; case MappingPointer: ui::DeviceDataManager::GetInstance()->UpdateButtonMap(); @@ -523,10 +523,6 @@ uint32_t WindowTreeHostX11::Dispatch(const base::NativeEvent& event) { return POST_DISPATCH_NONE; } -RootWindow* WindowTreeHostX11::GetRootWindow() { - return delegate_->AsRootWindow(); -} - gfx::AcceleratedWidget WindowTreeHostX11::GetAcceleratedWidget() { return xwindow_; } @@ -574,8 +570,8 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { // size, which is in DIP, changes when the scale changes. float current_scale = compositor()->device_scale_factor(); float new_scale = gfx::Screen::GetScreenFor( - delegate_->AsRootWindow()->window())->GetDisplayNearestWindow( - delegate_->AsRootWindow()->window()).device_scale_factor(); + delegate_->AsDispatcher()->window())->GetDisplayNearestWindow( + delegate_->AsDispatcher()->window()).device_scale_factor(); bool origin_changed = bounds_.origin() != bounds.origin(); bool size_changed = bounds_.size() != bounds.size(); XWindowChanges changes = {0}; @@ -607,8 +603,8 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { if (size_changed || current_scale != new_scale) { NotifyHostResized(bounds.size()); } else { - delegate_->AsRootWindow()->window()->SchedulePaintInRect( - delegate_->AsRootWindow()->window()->bounds()); + delegate_->AsDispatcher()->window()->SchedulePaintInRect( + delegate_->AsDispatcher()->window()->bounds()); } } @@ -638,7 +634,7 @@ void WindowTreeHostX11::ReleaseCapture() { bool WindowTreeHostX11::QueryMouseLocation(gfx::Point* location_return) { client::CursorClient* cursor_client = - client::GetCursorClient(GetRootWindow()->window()); + client::GetCursorClient(GetDispatcher()->window()); if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { *location_return = gfx::Point(0, 0); return false; @@ -731,7 +727,7 @@ void WindowTreeHostX11::PostNativeEvent( xevent.xmotion.time = CurrentTime; gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); - delegate_->AsRootWindow()->host()->ConvertPointToNativeScreen(&point); + delegate_->AsDispatcher()->host()->ConvertPointToNativeScreen(&point); xevent.xmotion.x_root = point.x(); xevent.xmotion.y_root = point.y(); } @@ -769,14 +765,16 @@ void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { void WindowTreeHostX11::OnWindowInitialized(Window* window) { } -void WindowTreeHostX11::OnRootWindowInitialized(RootWindow* root_window) { +void WindowTreeHostX11::OnRootWindowInitialized( + WindowEventDispatcher* dispatcher) { // UpdateIsInternalDisplay relies on: - // 1. delegate_ pointing to RootWindow - available after SetDelegate. - // 2. RootWindow's kDisplayIdKey property set - available by the time - // RootWindow::Init is called. + // 1. delegate_ pointing to WindowEventDispatcher - available after + // SetDelegate. + // 2. WED's kDisplayIdKey property set - available by the time + // WED::Init is called. // (set in DisplayManager::CreateRootWindowForDisplay) - // Ready when NotifyRootWindowInitialized is called from RootWindow::Init. - if (!delegate_ || root_window != GetRootWindow()) + // Ready when NotifyRootWindowInitialized is called from WED::Init. + if (!delegate_ || dispatcher != GetDispatcher()) return; UpdateIsInternalDisplay(); @@ -876,7 +874,7 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { if (type == ui::ET_MOUSE_RELEASED) break; client::UserActionClient* gesture_client = - client::GetUserActionClient(delegate_->AsRootWindow()->window()); + client::GetUserActionClient(delegate_->AsDispatcher()->window()); if (gesture_client) { bool reverse_direction = ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); @@ -931,7 +929,7 @@ void WindowTreeHostX11::SetCursorInternal(gfx::NativeCursor cursor) { void WindowTreeHostX11::TranslateAndDispatchMouseEvent( ui::MouseEvent* event) { - Window* root_window = GetRootWindow()->window(); + Window* root_window = GetDispatcher()->window(); client::ScreenPositionClient* screen_position_client = client::GetScreenPositionClient(root_window); gfx::Rect local(bounds_.size()); @@ -952,7 +950,7 @@ void WindowTreeHostX11::TranslateAndDispatchMouseEvent( } void WindowTreeHostX11::UpdateIsInternalDisplay() { - Window* root_window = GetRootWindow()->window(); + Window* root_window = GetDispatcher()->window(); gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); gfx::Display display = screen->GetDisplayNearestWindow(root_window); is_internal_display_ = display.IsInternal(); diff --git a/ui/aura/window_tree_host_x11.h b/ui/aura/window_tree_host_x11.h index c5e06b0a..99dbcd3 100644 --- a/ui/aura/window_tree_host_x11.h +++ b/ui/aura/window_tree_host_x11.h @@ -45,7 +45,6 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; // WindowTreeHost Overrides. - virtual RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; @@ -69,7 +68,8 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, // EnvObserver overrides. virtual void OnWindowInitialized(Window* window) OVERRIDE; - virtual void OnRootWindowInitialized(RootWindow* root_window) OVERRIDE; + virtual void OnRootWindowInitialized( + WindowEventDispatcher* dispatcher) OVERRIDE; // ui::EventSource overrides. virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; diff --git a/ui/aura/window_tree_host_x11_unittest.cc b/ui/aura/window_tree_host_x11_unittest.cc index ffbd299..d6c9ccf 100644 --- a/ui/aura/window_tree_host_x11_unittest.cc +++ b/ui/aura/window_tree_host_x11_unittest.cc @@ -34,8 +34,10 @@ class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate, virtual void OnHostResized(const gfx::Size& size) OVERRIDE {} virtual void OnCursorMovedToRootLocation( const gfx::Point& root_location) OVERRIDE {} - virtual aura::RootWindow* AsRootWindow() OVERRIDE { return NULL; } - virtual const aura::RootWindow* AsRootWindow() const OVERRIDE { return NULL; } + virtual aura::WindowEventDispatcher* AsDispatcher() OVERRIDE { return NULL; } + virtual const aura::WindowEventDispatcher* AsDispatcher() const OVERRIDE { + return NULL; + } virtual ui::EventProcessor* GetEventProcessor() OVERRIDE { return this; } diff --git a/ui/views/corewm/capture_controller_unittest.cc b/ui/views/corewm/capture_controller_unittest.cc index 2cbb61c..a089e6c 100644 --- a/ui/views/corewm/capture_controller_unittest.cc +++ b/ui/views/corewm/capture_controller_unittest.cc @@ -34,8 +34,8 @@ class CaptureControllerTest : public aura::test::AuraTestBase { AuraTestBase::SetUp(); capture_controller_.reset(new corewm::ScopedCaptureClient(root_window())); - second_root_.reset(new aura::RootWindow( - aura::RootWindow::CreateParams(gfx::Rect(0, 0, 800, 600)))); + second_root_.reset(new aura::WindowEventDispatcher( + aura::WindowEventDispatcher::CreateParams(gfx::Rect(0, 0, 800, 600)))); second_root_->host()->InitHost(); second_root_->window()->Show(); second_root_->host()->SetBounds(gfx::Rect(800, 600)); @@ -82,7 +82,7 @@ class CaptureControllerTest : public aura::test::AuraTestBase { } scoped_ptr<corewm::ScopedCaptureClient> capture_controller_; - scoped_ptr<aura::RootWindow> second_root_; + scoped_ptr<aura::WindowEventDispatcher> second_root_; scoped_ptr<corewm::ScopedCaptureClient> second_capture_controller_; #if !defined(OS_CHROMEOS) scoped_ptr<aura::client::ScreenPositionClient> desktop_position_client_; @@ -96,22 +96,22 @@ class CaptureControllerTest : public aura::test::AuraTestBase { // Makes sure that internal details that are set on mouse down (such as // mouse_pressed_handler()) are cleared when another root window takes capture. TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { - // Create a window inside the RootWindow. + // Create a window inside the WindowEventDispatcher. scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); - // Make a synthesized mouse down event. Ensure that the RootWindow will - // dispatch further mouse events to |w1|. + // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher + // will dispatch further mouse events to |w1|. ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_pressed_event); EXPECT_EQ(w1.get(), dispatcher()->mouse_pressed_handler()); - // Build a window in the second RootWindow. + // Build a window in the second WindowEventDispatcher. scoped_ptr<aura::Window> w2( CreateNormalWindow(2, second_root_->window(), NULL)); // The act of having the second window take capture should clear out mouse - // pressed handler in the first RootWindow. + // pressed handler in the first WindowEventDispatcher. w2->SetCapture(); EXPECT_EQ(NULL, dispatcher()->mouse_pressed_handler()); } @@ -120,15 +120,15 @@ TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { // other. This is needed has to be handled explicitly on Linux, and is a sanity // check on Windows. TEST_F(CaptureControllerTest, ResetOtherWindowCaptureOnCapture) { - // Create a window inside the RootWindow. + // Create a window inside the WindowEventDispatcher. scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); w1->SetCapture(); // Both capture clients should return the same capture window. EXPECT_EQ(w1.get(), GetCaptureWindow()); EXPECT_EQ(w1.get(), GetSecondCaptureWindow()); - // Build a window in the second RootWindow and give it capture. Both capture - // clients should return the same capture window. + // Build a window in the second WindowEventDispatcher and give it capture. + // Both capture clients should return the same capture window. scoped_ptr<aura::Window> w2( CreateNormalWindow(2, second_root_->window(), NULL)); w2->SetCapture(); @@ -136,9 +136,10 @@ TEST_F(CaptureControllerTest, ResetOtherWindowCaptureOnCapture) { EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); } -// Verifies the touch target for the RootWindow gets reset on releasing capture. +// Verifies the touch target for the WindowEventDispatcher gets reset on +// releasing capture. TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) { - // Create a window inside the RootWindow. + // Create a window inside the WindowEventDispatcher. scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); aura::test::EventGenerator event_generator1(root_window()); event_generator1.PressTouch(); @@ -147,8 +148,8 @@ TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) { EXPECT_EQ(w1.get(), GetCaptureWindow()); EXPECT_EQ(w1.get(), GetSecondCaptureWindow()); - // Build a window in the second RootWindow and give it capture. Both capture - // clients should return the same capture window. + // Build a window in the second WindowEventDispatcher and give it capture. + // Both capture clients should return the same capture window. scoped_ptr<aura::Window> w2( CreateNormalWindow(2, second_root_->window(), NULL)); w2->SetCapture(); @@ -156,8 +157,8 @@ TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) { EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); // Release capture on the window. Releasing capture should reset the touch - // target of the first RootWindow (as it no longer contains the capture - // target). + // target of the first WindowEventDispatcher (as it no longer contains the + // capture target). w2->ReleaseCapture(); EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); diff --git a/ui/views/corewm/desktop_capture_controller_unittest.cc b/ui/views/corewm/desktop_capture_controller_unittest.cc index f08c4db..166a40b 100644 --- a/ui/views/corewm/desktop_capture_controller_unittest.cc +++ b/ui/views/corewm/desktop_capture_controller_unittest.cc @@ -72,13 +72,14 @@ TEST_F(DesktopCaptureControllerTest, ResetMouseHandlers) { generator1.MoveMouseToCenterOf(w1->GetNativeView()); generator1.PressLeftButton(); EXPECT_FALSE(w1->HasCapture()); - aura::RootWindow* w1_root = w1->GetNativeView()->GetDispatcher(); - EXPECT_TRUE(w1_root->mouse_pressed_handler() != NULL); - EXPECT_TRUE(w1_root->mouse_moved_handler() != NULL); + aura::WindowEventDispatcher* w1_dispatcher = + w1->GetNativeView()->GetDispatcher(); + EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() != NULL); + EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() != NULL); w2->SetCapture(w2->GetRootView()); EXPECT_TRUE(w2->HasCapture()); - EXPECT_TRUE(w1_root->mouse_pressed_handler() == NULL); - EXPECT_TRUE(w1_root->mouse_moved_handler() == NULL); + EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() == NULL); + EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() == NULL); w2->ReleaseCapture(); } diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc index 7edc668..30ebe3a 100644 --- a/ui/views/examples/content_client/examples_browser_main_parts.cc +++ b/ui/views/examples/content_client/examples_browser_main_parts.cc @@ -60,9 +60,9 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() { // Set up basic pieces of views::corewm. wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); // Ensure the X window gets mapped. - wm_test_helper_->root_window()->host()->Show(); + wm_test_helper_->dispatcher()->host()->Show(); // Ensure Aura knows where to open new windows. - window_context = wm_test_helper_->root_window()->window(); + window_context = wm_test_helper_->dispatcher()->window(); #elif defined(USE_AURA) aura::Env::CreateInstance(); gfx::Screen::SetScreenInstance( diff --git a/ui/views/test/ui_controls_factory_desktop_aurax11.cc b/ui/views/test/ui_controls_factory_desktop_aurax11.cc index 23a7922..d04ab57 100644 --- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc +++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc @@ -285,22 +285,22 @@ class UIControlsDesktopX11 : public UIControlsAura { return NULL; } - void SetKeycodeAndSendThenMask(aura::RootWindow* root_window, + void SetKeycodeAndSendThenMask(aura::WindowEventDispatcher* dispatcher, XEvent* xevent, KeySym keysym, unsigned int mask) { xevent->xkey.keycode = XKeysymToKeycode(x_display_, keysym); - root_window->host()->PostNativeEvent(xevent); + dispatcher->host()->PostNativeEvent(xevent); xevent->xkey.state |= mask; } - void UnmaskAndSetKeycodeThenSend(aura::RootWindow* root_window, + void UnmaskAndSetKeycodeThenSend(aura::WindowEventDispatcher* dispatcher, XEvent* xevent, unsigned int mask, KeySym keysym) { xevent->xkey.state ^= mask; xevent->xkey.keycode = XKeysymToKeycode(x_display_, keysym); - root_window->host()->PostNativeEvent(xevent); + dispatcher->host()->PostNativeEvent(xevent); } // Our X11 state. diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc index 24b1938..cb86fe5 100644 --- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc +++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc @@ -27,13 +27,14 @@ gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) { return cursor; } -void DesktopNativeCursorManager::AddRootWindow(aura::RootWindow* root_window) { - root_windows_.insert(root_window); +void DesktopNativeCursorManager::AddRootWindow( + aura::WindowEventDispatcher* dispatcher) { + dispatchers_.insert(dispatcher); } void DesktopNativeCursorManager::RemoveRootWindow( - aura::RootWindow* root_window) { - root_windows_.erase(root_window); + aura::WindowEventDispatcher* dispatcher) { + dispatchers_.erase(dispatcher); } void DesktopNativeCursorManager::SetDisplay( @@ -56,8 +57,8 @@ void DesktopNativeCursorManager::SetCursor( delegate->CommitCursor(new_cursor); if (delegate->IsCursorVisible()) { - for (RootWindows::const_iterator i = root_windows_.begin(); - i != root_windows_.end(); + for (Dispatchers::const_iterator i = dispatchers_.begin(); + i != dispatchers_.end(); ++i) { (*i)->host()->SetCursor(new_cursor); } @@ -74,15 +75,15 @@ void DesktopNativeCursorManager::SetVisibility( } else { gfx::NativeCursor invisible_cursor(ui::kCursorNone); cursor_loader_->SetPlatformCursor(&invisible_cursor); - for (RootWindows::const_iterator i = root_windows_.begin(); - i != root_windows_.end(); + for (Dispatchers::const_iterator i = dispatchers_.begin(); + i != dispatchers_.end(); ++i) { (*i)->host()->SetCursor(invisible_cursor); } } - for (RootWindows::const_iterator i = root_windows_.begin(); - i != root_windows_.end(); + for (Dispatchers::const_iterator i = dispatchers_.begin(); + i != dispatchers_.end(); ++i) { (*i)->host()->OnCursorVisibilityChanged(visible); } @@ -110,8 +111,8 @@ void DesktopNativeCursorManager::SetMouseEventsEnabled( SetVisibility(delegate->IsCursorVisible(), delegate); - for (RootWindows::const_iterator i = root_windows_.begin(); - i != root_windows_.end(); + for (Dispatchers::const_iterator i = dispatchers_.begin(); + i != dispatchers_.end(); ++i) { (*i)->OnMouseEventsEnableStateChanged(enabled); } diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h index 18732b0..67dfaeb 100644 --- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h +++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h @@ -13,7 +13,7 @@ #include "ui/views/views_export.h" namespace aura { -class RootWindow; +class WindowEventDispatcher; } namespace ui { @@ -41,10 +41,10 @@ class VIEWS_EXPORT DesktopNativeCursorManager gfx::NativeCursor GetInitializedCursor(int type); // Adds |root_window| to the set |root_windows_|. - void AddRootWindow(aura::RootWindow* root_window); + void AddRootWindow(aura::WindowEventDispatcher* dispatcher); // Removes |root_window| from the set |root_windows_|. - void RemoveRootWindow(aura::RootWindow* root_window); + void RemoveRootWindow(aura::WindowEventDispatcher* dispatcher); private: // Overridden from views::corewm::NativeCursorManager: @@ -67,9 +67,9 @@ class VIEWS_EXPORT DesktopNativeCursorManager bool enabled, views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE; - // The set of root windows to notify of changes in cursor state. - typedef std::set<aura::RootWindow*> RootWindows; - RootWindows root_windows_; + // The set of dispatchers to notify of changes in cursor state. + typedef std::set<aura::WindowEventDispatcher*> Dispatchers; + Dispatchers dispatchers_; scoped_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater_; scoped_ptr<ui::CursorLoader> cursor_loader_; 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 bab7a76..45faed7 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -265,11 +265,11 @@ void DesktopNativeWidgetAura::OnHostClosed() { if (window_modality_controller_) window_modality_controller_.reset(); - // Make sure we don't have capture. Otherwise CaptureController and RootWindow - // are left referencing a deleted Window. + // Make sure we don't have capture. Otherwise CaptureController and + // WindowEventDispatcher are left referencing a deleted Window. { aura::Window* capture_window = capture_client_->GetCaptureWindow(); - if (capture_window && root_window_->window()->Contains(capture_window)) + if (capture_window && dispatcher_->window()->Contains(capture_window)) capture_window->ReleaseCapture(); } @@ -277,28 +277,28 @@ void DesktopNativeWidgetAura::OnHostClosed() { // references. Make sure we destroy ShadowController early on. shadow_controller_.reset(); tooltip_manager_.reset(); - root_window_->window()->RemovePreTargetHandler(tooltip_controller_.get()); - aura::client::SetTooltipClient(root_window_->window(), NULL); + dispatcher_->window()->RemovePreTargetHandler(tooltip_controller_.get()); + aura::client::SetTooltipClient(dispatcher_->window(), NULL); tooltip_controller_.reset(); root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); - window_tree_client_.reset(); // Uses root_window_ at destruction. + window_tree_client_.reset(); // Uses dispatcher_ at destruction. - capture_client_.reset(); // Uses root_window_ at destruction. + capture_client_.reset(); // Uses dispatcher_ at destruction. // FocusController uses |content_window_|. Destroy it now so that we don't // have to worry about the possibility of FocusController attempting to use // |content_window_| after it's been destroyed but before all child windows // have been destroyed. - root_window_->window()->RemovePreTargetHandler(focus_client_.get()); - aura::client::SetFocusClient(root_window_->window(), NULL); - aura::client::SetActivationClient(root_window_->window(), NULL); + dispatcher_->window()->RemovePreTargetHandler(focus_client_.get()); + aura::client::SetFocusClient(dispatcher_->window(), NULL); + aura::client::SetActivationClient(dispatcher_->window(), NULL); focus_client_.reset(); - root_window_->RemoveRootWindowObserver(this); - root_window_.reset(); // Uses input_method_event_filter_ at destruction. - // RootWindow owns |desktop_window_tree_host_|. + dispatcher_->RemoveRootWindowObserver(this); + dispatcher_.reset(); // Uses input_method_event_filter_ at destruction. + // WindowEventDispatcher owns |desktop_window_tree_host_|. desktop_window_tree_host_ = NULL; content_window_ = NULL; @@ -308,14 +308,14 @@ void DesktopNativeWidgetAura::OnHostClosed() { } void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( - aura::RootWindow* root) { - // |root_window_| is still valid, but DesktopWindowTreeHost is nearly + aura::WindowEventDispatcher* dispatcher) { + // |dispatcher_| is still valid, but DesktopWindowTreeHost is nearly // destroyed. Do cleanup here of members DesktopWindowTreeHost may also use. - aura::client::SetDispatcherClient(root->window(), NULL); + aura::client::SetDispatcherClient(dispatcher->window(), NULL); dispatcher_client_.reset(); - aura::client::SetCursorClient(root->window(), NULL); - native_cursor_manager_->RemoveRootWindow(root); + aura::client::SetCursorClient(dispatcher->window(), NULL); + native_cursor_manager_->RemoveRootWindow(dispatcher); cursor_reference_count_--; if (cursor_reference_count_ == 0) { @@ -326,20 +326,20 @@ void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( cursor_manager_ = NULL; } - aura::client::SetScreenPositionClient(root->window(), NULL); + aura::client::SetScreenPositionClient(dispatcher->window(), NULL); position_client_.reset(); - aura::client::SetDragDropClient(root->window(), NULL); + aura::client::SetDragDropClient(dispatcher->window(), NULL); drag_drop_client_.reset(); - aura::client::SetEventClient(root->window(), NULL); + aura::client::SetEventClient(dispatcher->window(), NULL); event_client_.reset(); } void DesktopNativeWidgetAura::HandleActivationChanged(bool active) { native_widget_delegate_->OnNativeWidgetActivationChanged(active); aura::client::ActivationClient* activation_client = - aura::client::GetActivationClient(root_window_->window()); + aura::client::GetActivationClient(dispatcher_->window()); if (!activation_client) return; if (active) { @@ -395,20 +395,20 @@ void DesktopNativeWidgetAura::InitNativeWidget( desktop_window_tree_host_ = params.desktop_window_tree_host ? params.desktop_window_tree_host : DesktopWindowTreeHost::Create(native_widget_delegate_, this); - aura::RootWindow::CreateParams rw_params(params.bounds); + aura::WindowEventDispatcher::CreateParams rw_params(params.bounds); desktop_window_tree_host_->Init(content_window_, params, &rw_params); - root_window_.reset(new aura::RootWindow(rw_params)); - root_window_->host()->InitHost(); - root_window_->window()->AddChild(content_window_container_); - root_window_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); + dispatcher_.reset(new aura::WindowEventDispatcher(rw_params)); + dispatcher_->host()->InitHost(); + dispatcher_->window()->AddChild(content_window_container_); + dispatcher_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); // The WindowsModalityController event filter should be at the head of the // pre target handlers list. This ensures that it handles input events first // when modal windows are at the top of the Zorder. if (widget_type_ == Widget::InitParams::TYPE_WINDOW) window_modality_controller_.reset( - new views::corewm::WindowModalityController(root_window_->window())); + new views::corewm::WindowModalityController(dispatcher_->window())); // |root_window_event_filter_| must be created before // OnWindowTreeHostCreated() is invoked. @@ -416,12 +416,13 @@ void DesktopNativeWidgetAura::InitNativeWidget( // CEF sets focus to the window the user clicks down on. // TODO(beng): see if we can't do this some other way. CEF seems a heavy- // handed way of accomplishing focus. - // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. + // No event filter for aura::Env. Create CompoundEvnetFilter per + // WindowEventDispatcher. root_window_event_filter_ = new corewm::CompoundEventFilter; // Pass ownership of the filter to the root_window. - root_window_->window()->SetEventFilter(root_window_event_filter_); + dispatcher_->window()->SetEventFilter(root_window_event_filter_); - // |root_window_| must be added to |native_cursor_manager_| before + // |dispatcher_| must be added to |native_cursor_manager_| before // OnRootWindowCreated() is called. cursor_reference_count_++; if (!native_cursor_manager_) { @@ -432,46 +433,46 @@ void DesktopNativeWidgetAura::InitNativeWidget( cursor_manager_ = new views::corewm::CursorManager( scoped_ptr<corewm::NativeCursorManager>(native_cursor_manager_)); } - native_cursor_manager_->AddRootWindow(root_window_.get()); - aura::client::SetCursorClient(root_window_->window(), cursor_manager_); + native_cursor_manager_->AddRootWindow(dispatcher_.get()); + aura::client::SetCursorClient(dispatcher_->window(), cursor_manager_); - desktop_window_tree_host_->OnRootWindowCreated(root_window_.get(), params); + desktop_window_tree_host_->OnRootWindowCreated(dispatcher_.get(), params); UpdateWindowTransparency(); - capture_client_.reset(new DesktopCaptureClient(root_window_->window())); + capture_client_.reset(new DesktopCaptureClient(dispatcher_->window())); corewm::FocusController* focus_controller = new corewm::FocusController(new DesktopFocusRules(content_window_)); focus_client_.reset(focus_controller); - aura::client::SetFocusClient(root_window_->window(), focus_controller); - aura::client::SetActivationClient(root_window_->window(), focus_controller); - root_window_->window()->AddPreTargetHandler(focus_controller); + aura::client::SetFocusClient(dispatcher_->window(), focus_controller); + aura::client::SetActivationClient(dispatcher_->window(), focus_controller); + dispatcher_->window()->AddPreTargetHandler(focus_controller); dispatcher_client_.reset(new DesktopDispatcherClient); - aura::client::SetDispatcherClient(root_window_->window(), + aura::client::SetDispatcherClient(dispatcher_->window(), dispatcher_client_.get()); position_client_.reset(new DesktopScreenPositionClient()); - aura::client::SetScreenPositionClient(root_window_->window(), + aura::client::SetScreenPositionClient(dispatcher_->window(), position_client_.get()); InstallInputMethodEventFilter(); drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( native_cursor_manager_); - aura::client::SetDragDropClient(root_window_->window(), + aura::client::SetDragDropClient(dispatcher_->window(), drag_drop_client_.get()); static_cast<aura::client::FocusClient*>(focus_client_.get())-> FocusWindow(content_window_); - OnWindowTreeHostResized(root_window_.get()); + OnWindowTreeHostResized(dispatcher_.get()); - root_window_->AddRootWindowObserver(this); + dispatcher_->AddRootWindowObserver(this); window_tree_client_.reset( - new DesktopNativeWidgetAuraWindowTreeClient(root_window_->window())); + new DesktopNativeWidgetAuraWindowTreeClient(dispatcher_->window())); drop_helper_.reset(new DropHelper( static_cast<internal::RootView*>(GetWidget()->GetRootView()))); aura::client::SetDragDropDelegate(content_window_, this); @@ -481,28 +482,28 @@ void DesktopNativeWidgetAura::InitNativeWidget( tooltip_controller_.reset( new corewm::TooltipController( desktop_window_tree_host_->CreateTooltip())); - aura::client::SetTooltipClient(root_window_->window(), + aura::client::SetTooltipClient(dispatcher_->window(), tooltip_controller_.get()); - root_window_->window()->AddPreTargetHandler(tooltip_controller_.get()); + dispatcher_->window()->AddPreTargetHandler(tooltip_controller_.get()); if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { visibility_controller_.reset(new views::corewm::VisibilityController); - aura::client::SetVisibilityClient(root_window_->window(), + aura::client::SetVisibilityClient(dispatcher_->window(), visibility_controller_.get()); views::corewm::SetChildWindowVisibilityChangesAnimated( - root_window_->window()); + dispatcher_->window()); views::corewm::SetChildWindowVisibilityChangesAnimated( content_window_container_); } if (params.type == Widget::InitParams::TYPE_WINDOW) { focus_manager_event_handler_.reset(new FocusManagerEventHandler(this)); - root_window_->window()->AddPreTargetHandler( + dispatcher_->window()->AddPreTargetHandler( focus_manager_event_handler_.get()); } event_client_.reset(new DesktopEventClient); - aura::client::SetEventClient(root_window_->window(), event_client_.get()); + aura::client::SetEventClient(dispatcher_->window(), event_client_.get()); aura::client::GetFocusClient(content_window_)->FocusWindow(content_window_); @@ -510,7 +511,7 @@ void DesktopNativeWidgetAura::InitNativeWidget( shadow_controller_.reset( new corewm::ShadowController( - aura::client::GetActivationClient(root_window_->window()))); + aura::client::GetActivationClient(dispatcher_->window()))); content_window_->SetProperty(aura::client::kCanMaximizeKey, GetWidget()->widget_delegate()->CanMaximize()); @@ -676,7 +677,7 @@ void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { // We could probably get rid of this and similar logic from // the DesktopNativeWidgetAura::OnWindowTreeHostResized function. float scale = 1; - aura::Window* root = root_window_->window(); + aura::Window* root = dispatcher_->window(); if (root) { scale = gfx::Screen::GetScreenFor(root)-> GetDisplayNearestWindow(root).device_scale_factor(); @@ -846,7 +847,7 @@ void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { cursor_ = cursor; aura::client::CursorClient* cursor_client = - aura::client::GetCursorClient(root_window_->window()); + aura::client::GetCursorClient(dispatcher_->window()); if (cursor_client) cursor_client->SetCursor(cursor); } @@ -855,7 +856,7 @@ bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const { if (!content_window_) return false; aura::client::CursorClient* cursor_client = - aura::client::GetCursorClient(root_window_->window()); + aura::client::GetCursorClient(dispatcher_->window()); return cursor_client ? cursor_client->IsMouseEventsEnabled() : true; } @@ -953,7 +954,7 @@ void DesktopNativeWidgetAura::OnWindowDestroying() { void DesktopNativeWidgetAura::OnWindowDestroyed() { // Cleanup happens in OnHostClosed(). We own |content_window_| (indirectly by - // way of |root_window_|) so there should be no need to do any processing + // way of |dispatcher_|) so there should be no need to do any processing // here. } @@ -1120,19 +1121,19 @@ int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { // DesktopNativeWidgetAura, aura::RootWindowObserver implementation: void DesktopNativeWidgetAura::OnWindowTreeHostCloseRequested( - const aura::RootWindow* root) { + const aura::WindowEventDispatcher* dispatcher) { Close(); } void DesktopNativeWidgetAura::OnWindowTreeHostResized( - const aura::RootWindow* root) { + const aura::WindowEventDispatcher* dispatcher) { // Don't update the bounds of the child layers when animating closed. If we // did it would force a paint, which we don't want. We don't want the paint // as we can't assume any of the children are valid. if (desktop_window_tree_host_->IsAnimatingClosed()) return; - gfx::Rect new_bounds = gfx::Rect(root->window()->bounds().size()); + gfx::Rect new_bounds = gfx::Rect(dispatcher->window()->bounds().size()); content_window_->SetBounds(new_bounds); // Can be NULL at start. if (content_window_container_) @@ -1141,7 +1142,7 @@ void DesktopNativeWidgetAura::OnWindowTreeHostResized( } void DesktopNativeWidgetAura::OnWindowTreeHostMoved( - const aura::RootWindow* root, + const aura::WindowEventDispatcher* dispatcher, const gfx::Point& new_origin) { TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnWindowTreeHostMoved", "new_origin", new_origin.ToString()); @@ -1160,9 +1161,9 @@ void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { DCHECK(!input_method_event_filter_.get()); input_method_event_filter_.reset(new corewm::InputMethodEventFilter( - root_window_->host()->GetAcceleratedWidget())); + dispatcher_->host()->GetAcceleratedWidget())); input_method_event_filter_->SetInputMethodPropertyInRootWindow( - root_window_->window()); + dispatcher_->window()); root_window_event_filter_->AddHandler(input_method_event_filter_.get()); } diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index 3fc21a5..510f746 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -70,9 +70,10 @@ class VIEWS_EXPORT DesktopNativeWidgetAura // this is the signal that we should start our shutdown. virtual void OnHostClosed(); - // Called from ~DesktopWindowTreeHost. This takes the RootWindow as by the - // time we get here |root_window_| is NULL. - virtual void OnDesktopWindowTreeHostDestroyed(aura::RootWindow* root); + // Called from ~DesktopWindowTreeHost. This takes the WindowEventDispatcher + // as by the time we get here |dispatcher_| is NULL. + virtual void OnDesktopWindowTreeHostDestroyed( + aura::WindowEventDispatcher* dispatcher); corewm::InputMethodEventFilter* input_method_event_filter() { return input_method_event_filter_.get(); @@ -80,8 +81,8 @@ class VIEWS_EXPORT DesktopNativeWidgetAura corewm::CompoundEventFilter* root_window_event_filter() { return root_window_event_filter_; } - aura::RootWindow* root_window() { - return root_window_.get(); + aura::WindowEventDispatcher* dispatcher() { + return dispatcher_.get(); } // Overridden from NativeWidget: @@ -227,10 +228,12 @@ class VIEWS_EXPORT DesktopNativeWidgetAura // Overridden from aura::RootWindowObserver: virtual void OnWindowTreeHostCloseRequested( - const aura::RootWindow* root) OVERRIDE; - virtual void OnWindowTreeHostResized(const aura::RootWindow* root) OVERRIDE; - virtual void OnWindowTreeHostMoved(const aura::RootWindow* root, - const gfx::Point& new_origin) OVERRIDE; + const aura::WindowEventDispatcher* dispatcher) OVERRIDE; + virtual void OnWindowTreeHostResized( + const aura::WindowEventDispatcher* dispatcher) OVERRIDE; + virtual void OnWindowTreeHostMoved( + const aura::WindowEventDispatcher* dispatcher, + const gfx::Point& new_origin) OVERRIDE; private: friend class FocusManagerEventHandler; @@ -247,9 +250,10 @@ class VIEWS_EXPORT DesktopNativeWidgetAura scoped_ptr<DesktopCaptureClient> capture_client_; - // The NativeWidget owns the RootWindow. Required because the RootWindow owns - // its WindowTreeHost, so DesktopWindowTreeHost can't own it. - scoped_ptr<aura::RootWindow> root_window_; + // The NativeWidget owns the WindowEventDispatcher. Required because the + // WindowEventDispatcher owns its WindowTreeHost, so DesktopWindowTreeHost + // can't own it. + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; // The following factory is used for calls to close the NativeWidgetAura // instance. diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc index 61dde12..a7c108d 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc @@ -91,9 +91,9 @@ TEST_F(DesktopNativeWidgetAuraTest, GlobalCursorState) { widget_b.Init(init_params_b); aura::client::CursorClient* cursor_client_a = aura::client::GetCursorClient( - desktop_native_widget_aura_a->root_window()->window()); + desktop_native_widget_aura_a->dispatcher()->window()); aura::client::CursorClient* cursor_client_b = aura::client::GetCursorClient( - desktop_native_widget_aura_b->root_window()->window()); + desktop_native_widget_aura_b->dispatcher()->window()); // Verify the cursor can be locked using one client and unlocked using // another. diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 271e4ec..252e6cb 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -207,12 +207,12 @@ gfx::Display DesktopScreenX11::GetDisplayNearestWindow( // Getting screen bounds here safely is hard. // // You'd think we'd be able to just call window->GetBoundsInScreen(), but we - // can't because |window| (and the associated RootWindow*) can be partially - // initialized at this point; RootWindow initializations call through into - // GetDisplayNearestWindow(). But the X11 resources are created before we - // create the aura::RootWindow. So we ask what the DRWHX11 believes the - // window bounds are instead of going through the aura::Window's screen - // bounds. + // can't because |window| (and the associated WindowEventDispatcher*) can be + // partially initialized at this point; WindowEventDispatcher initializations + // call through into GetDisplayNearestWindow(). But the X11 resources are + // created before we create the aura::WindowEventDispatcher. So we ask what + // the DRWHX11 believes the window bounds are instead of going through the + // aura::Window's screen bounds. aura::WindowEventDispatcher* dispatcher = window->GetDispatcher(); if (dispatcher) { DesktopWindowTreeHostX11* rwh = DesktopWindowTreeHostX11::GetHostForXID( diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host.h b/ui/views/widget/desktop_aura/desktop_window_tree_host.h index 09591a6..a698db2 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host.h @@ -53,13 +53,15 @@ class VIEWS_EXPORT DesktopWindowTreeHost { // Return the NativeTheme to use for |window|. WARNING: |window| may be NULL. static ui::NativeTheme* GetNativeTheme(aura::Window* window); - // Sets up resources needed before the RootWindow has been created. - virtual void Init(aura::Window* content_window, - const Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) = 0; - - // Invoked once the RootWindow has been created. Caller owns the RootWindow. - virtual void OnRootWindowCreated(aura::RootWindow* root, + // Sets up resources needed before the WindowEventDispatcher has been created. + virtual void Init( + aura::Window* content_window, + const Widget::InitParams& params, + aura::WindowEventDispatcher::CreateParams* rw_create_params) = 0; + + // Invoked once the WindowEventDispatcher has been created. Caller owns the + // WindowEventDispatcher. + virtual void OnRootWindowCreated(aura::WindowEventDispatcher* dispatcher, const Widget::InitParams& params) = 0; // Creates and returns the Tooltip implementation to use. Return value is diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc index c587338..fee9b05 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -64,7 +64,8 @@ void InsetBottomRight(gfx::Rect* rect, gfx::Vector2d vector) { DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL); -// Identifies the DesktopWindowTreeHostWin associated with the RootWindow. +// Identifies the DesktopWindowTreeHostWin associated with the +// WindowEventDispatcher. DEFINE_WINDOW_PROPERTY_KEY(DesktopWindowTreeHostWin*, kDesktopWindowTreeHostKey, NULL); @@ -76,7 +77,7 @@ bool DesktopWindowTreeHostWin::is_cursor_visible_ = true; DesktopWindowTreeHostWin::DesktopWindowTreeHostWin( internal::NativeWidgetDelegate* native_widget_delegate, DesktopNativeWidgetAura* desktop_native_widget_aura) - : root_window_(NULL), + : dispatcher_(NULL), message_handler_(new HWNDMessageHandler(this)), native_widget_delegate_(native_widget_delegate), desktop_native_widget_aura_(desktop_native_widget_aura), @@ -91,13 +92,15 @@ DesktopWindowTreeHostWin::DesktopWindowTreeHostWin( DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { // WARNING: |content_window_| has been destroyed by the time we get here. desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed( - root_window_); + dispatcher_); } // static aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { - aura::RootWindow* root = aura::RootWindow::GetForAcceleratedWidget(hwnd); - return root ? root->window()->GetProperty(kContentWindowForRootWindow) : NULL; + aura::WindowEventDispatcher* dispatcher = + aura::WindowEventDispatcher::GetForAcceleratedWidget(hwnd); + return dispatcher ? + dispatcher->window()->GetProperty(kContentWindowForRootWindow) : NULL; } // static @@ -122,7 +125,7 @@ ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { void DesktopWindowTreeHostWin::Init( aura::Window* content_window, const Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) { + aura::WindowEventDispatcher::CreateParams* rw_create_params) { // TODO(beng): SetInitParams(). content_window_ = content_window; @@ -155,19 +158,19 @@ void DesktopWindowTreeHostWin::Init( } void DesktopWindowTreeHostWin::OnRootWindowCreated( - aura::RootWindow* root, + aura::WindowEventDispatcher* dispatcher, const Widget::InitParams& params) { - root_window_ = root; + dispatcher_ = dispatcher; // The cursor is not necessarily visible when the root window is created. aura::client::CursorClient* cursor_client = - aura::client::GetCursorClient(root_window_->window()); + aura::client::GetCursorClient(dispatcher_->window()); if (cursor_client) is_cursor_visible_ = cursor_client->IsCursorVisible(); - root_window_->window()->SetProperty(kContentWindowForRootWindow, - content_window_); - root_window_->window()->SetProperty(kDesktopWindowTreeHostKey, this); + dispatcher_->window()->SetProperty(kContentWindowForRootWindow, + content_window_); + dispatcher_->window()->SetProperty(kDesktopWindowTreeHostKey, this); should_animate_window_close_ = content_window_->type() != ui::wm::WINDOW_TYPE_NORMAL && @@ -186,7 +189,7 @@ scoped_ptr<corewm::Tooltip> DesktopWindowTreeHostWin::CreateTooltip() { scoped_ptr<aura::client::DragDropClient> DesktopWindowTreeHostWin::CreateDragDropClient( DesktopNativeCursorManager* cursor_manager) { - drag_drop_client_ = new DesktopDragDropClientWin(root_window_->window(), + drag_drop_client_ = new DesktopDragDropClientWin(dispatcher_->window(), GetHWND()); return scoped_ptr<aura::client::DragDropClient>(drag_drop_client_).Pass(); } @@ -448,10 +451,6 @@ bool DesktopWindowTreeHostWin::IsAnimatingClosed() const { //////////////////////////////////////////////////////////////////////////////// // DesktopWindowTreeHostWin, WindowTreeHost implementation: -aura::RootWindow* DesktopWindowTreeHostWin::GetRootWindow() { - return root_window_; -} - gfx::AcceleratedWidget DesktopWindowTreeHostWin::GetAcceleratedWidget() { return message_handler_->hwnd(); } @@ -537,7 +536,7 @@ void DesktopWindowTreeHostWin::ReleaseCapture() { bool DesktopWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) { aura::client::CursorClient* cursor_client = - aura::client::GetCursorClient(root_window_->window()); + aura::client::GetCursorClient(dispatcher_->window()); if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { *location_return = gfx::Point(0, 0); return false; @@ -550,7 +549,7 @@ bool DesktopWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) { } bool DesktopWindowTreeHostWin::ConfineCursorToRootWindow() { - RECT window_rect = root_window_->window()->GetBoundsInScreen().ToRECT(); + RECT window_rect = dispatcher_->window()->GetBoundsInScreen().ToRECT(); ::ClipCursor(&window_rect); return true; } @@ -878,17 +877,17 @@ bool DesktopWindowTreeHostWin::HandleUntranslatedKeyEvent( void DesktopWindowTreeHostWin::HandleTouchEvent( const ui::TouchEvent& event) { // HWNDMessageHandler asynchronously processes touch events. Because of this - // it's possible for the aura::RootWindow to have been destroyed by the time - // we attempt to process them. + // it's possible for the aura::WindowEventDispatcher to have been destroyed + // by the time we attempt to process them. if (!GetWidget()->GetNativeView()) return; // Currently we assume the window that has capture gets touch events too. - aura::RootWindow* root = - aura::RootWindow::GetForAcceleratedWidget(GetCapture()); - if (root) { + aura::WindowEventDispatcher* dispatcher = + aura::WindowEventDispatcher::GetForAcceleratedWidget(GetCapture()); + if (dispatcher) { DesktopWindowTreeHostWin* target = - root->window()->GetProperty(kDesktopWindowTreeHostKey); + dispatcher->window()->GetProperty(kDesktopWindowTreeHostKey); if (target && target->HasCapture() && target != this) { POINT target_location(event.location().ToPOINT()); ClientToScreen(GetHWND(), &target_location); @@ -949,7 +948,7 @@ void DesktopWindowTreeHostWin::HandleTooltipMouseMove(UINT message, void DesktopWindowTreeHostWin::HandleMenuLoop(bool in_menu_loop) { if (in_menu_loop) { tooltip_disabler_.reset( - new aura::client::ScopedTooltipDisabler(root_window_->window())); + new aura::client::ScopedTooltipDisabler(dispatcher_->window())); } else { tooltip_disabler_.reset(); } @@ -990,21 +989,21 @@ HWND DesktopWindowTreeHostWin::GetHWND() const { void DesktopWindowTreeHostWin::SetWindowTransparency() { bool transparent = ShouldUseNativeFrame() && !IsFullscreen(); - root_window_->host()->compositor()->SetHostHasTransparentBackground( + dispatcher_->host()->compositor()->SetHostHasTransparentBackground( transparent); - root_window_->window()->SetTransparent(transparent); + dispatcher_->window()->SetTransparent(transparent); content_window_->SetTransparent(transparent); } bool DesktopWindowTreeHostWin::IsModalWindowActive() const { // This function can get called during window creation which occurs before - // root_window_ has been created. - if (!root_window_) + // dispatcher_ has been created. + if (!dispatcher_) return false; aura::Window::Windows::const_iterator index; - for (index = root_window_->window()->children().begin(); - index != root_window_->window()->children().end(); + for (index = dispatcher_->window()->children().begin(); + index != dispatcher_->window()->children().end(); ++index) { if ((*index)->GetProperty(aura::client::kModalKey) != ui:: MODAL_TYPE_NONE && (*index)->TargetVisibility()) diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h index 6c7a3e0..4bde34d 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h @@ -45,10 +45,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin protected: // Overridden from DesktopWindowTreeHost: - virtual void Init(aura::Window* content_window, - const Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) OVERRIDE; - virtual void OnRootWindowCreated(aura::RootWindow* root, + virtual void Init( + aura::Window* content_window, + const Widget::InitParams& params, + aura::WindowEventDispatcher::CreateParams* rw_create_params) OVERRIDE; + virtual void OnRootWindowCreated(aura::WindowEventDispatcher* dispatcher, const Widget::InitParams& params) OVERRIDE; virtual scoped_ptr<corewm::Tooltip> CreateTooltip() OVERRIDE; virtual scoped_ptr<aura::client::DragDropClient> @@ -108,7 +109,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin virtual bool IsAnimatingClosed() const OVERRIDE; // Overridden from aura::WindowTreeHost: - virtual aura::RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; @@ -228,8 +228,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin // Returns true if a modal window is active in the current root window chain. bool IsModalWindowActive() const; - // We are owned by the RootWindow, but we have to have a back pointer to it. - aura::RootWindow* root_window_; + // We are owned by the WindowEventDispatcher, but we have to have a back + // pointer to it. + aura::WindowEventDispatcher* dispatcher_; scoped_ptr<HWNDMessageHandler> message_handler_; scoped_ptr<aura::client::FocusClient> focus_client_; diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index 26fb4f5..53001d4 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -133,7 +133,7 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( is_fullscreen_(false), is_always_on_top_(false), use_native_frame_(false), - root_window_(NULL), + dispatcher_(NULL), drag_drop_client_(NULL), current_cursor_(ui::kCursorNull), native_widget_delegate_(native_widget_delegate), @@ -144,23 +144,27 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( } DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { - root_window_->window()->ClearProperty(kHostForRootWindow); - aura::client::SetWindowMoveClient(root_window_->window(), NULL); - desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(root_window_); + dispatcher_->window()->ClearProperty(kHostForRootWindow); + aura::client::SetWindowMoveClient(dispatcher_->window(), NULL); + desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(dispatcher_); if (custom_window_shape_) XDestroyRegion(custom_window_shape_); } // static aura::Window* DesktopWindowTreeHostX11::GetContentWindowForXID(XID xid) { - aura::RootWindow* root = aura::RootWindow::GetForAcceleratedWidget(xid); - return root ? root->window()->GetProperty(kViewsWindowForRootWindow) : NULL; + aura::WindowEventDispatcher* dispatcher = + aura::WindowEventDispatcher::GetForAcceleratedWidget(xid); + return dispatcher ? + dispatcher->window()->GetProperty(kViewsWindowForRootWindow) : NULL; } // static DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::GetHostForXID(XID xid) { - aura::RootWindow* root = aura::RootWindow::GetForAcceleratedWidget(xid); - return root ? root->window()->GetProperty(kHostForRootWindow) : NULL; + aura::WindowEventDispatcher* dispatcher = + aura::WindowEventDispatcher::GetForAcceleratedWidget(xid); + return dispatcher ? + dispatcher->window()->GetProperty(kHostForRootWindow) : NULL; } // static @@ -211,7 +215,7 @@ void DesktopWindowTreeHostX11::CleanUpWindowList() { void DesktopWindowTreeHostX11::Init( aura::Window* content_window, const Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) { + aura::WindowEventDispatcher::CreateParams* rw_create_params) { content_window_ = content_window; // TODO(erg): Check whether we *should* be building a WindowTreeHost here, or @@ -232,14 +236,14 @@ void DesktopWindowTreeHostX11::Init( } void DesktopWindowTreeHostX11::OnRootWindowCreated( - aura::RootWindow* root, + aura::WindowEventDispatcher* dispatcher, const Widget::InitParams& params) { - root_window_ = root; + dispatcher_ = dispatcher; - root_window_->window()->SetProperty(kViewsWindowForRootWindow, - content_window_); - root_window_->window()->SetProperty(kHostForRootWindow, this); - delegate_ = root_window_; + dispatcher_->window()->SetProperty(kViewsWindowForRootWindow, + content_window_); + dispatcher_->window()->SetProperty(kHostForRootWindow, this); + delegate_ = dispatcher_; // If we're given a parent, we need to mark ourselves as transient to another // window. Otherwise activation gets screwy. @@ -253,14 +257,14 @@ void DesktopWindowTreeHostX11::OnRootWindowCreated( X11DesktopHandler::get(); // TODO(erg): Unify this code once the other consumer goes away. - x11_window_event_filter_.reset(new X11WindowEventFilter(root_window_, this)); + x11_window_event_filter_.reset(new X11WindowEventFilter(dispatcher_, this)); SetUseNativeFrame(params.type == Widget::InitParams::TYPE_WINDOW && !params.remove_standard_frame); desktop_native_widget_aura_->root_window_event_filter()->AddHandler( x11_window_event_filter_.get()); x11_window_move_client_.reset(new X11DesktopWindowMoveClient); - aura::client::SetWindowMoveClient(root_window_->window(), + aura::client::SetWindowMoveClient(dispatcher_->window(), x11_window_move_client_.get()); native_widget_delegate_->OnNativeWidgetCreated(true); @@ -275,7 +279,7 @@ scoped_ptr<aura::client::DragDropClient> DesktopWindowTreeHostX11::CreateDragDropClient( DesktopNativeCursorManager* cursor_manager) { drag_drop_client_ = new DesktopDragDropClientAuraX11( - root_window_->window(), cursor_manager, xdisplay_, xwindow_); + dispatcher_->window(), cursor_manager, xdisplay_, xwindow_); return scoped_ptr<aura::client::DragDropClient>(drag_drop_client_).Pass(); } @@ -318,7 +322,7 @@ void DesktopWindowTreeHostX11::CloseNow() { } // Remove the event listeners we've installed. We need to remove these - // because otherwise we get assert during ~RootWindow(). + // because otherwise we get assert during ~WindowEventDispatcher(). desktop_native_widget_aura_->root_window_event_filter()->RemoveHandler( x11_window_event_filter_.get()); @@ -742,10 +746,6 @@ bool DesktopWindowTreeHostX11::IsAnimatingClosed() const { //////////////////////////////////////////////////////////////////////////////// // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: -aura::RootWindow* DesktopWindowTreeHostX11::GetRootWindow() { - return root_window_; -} - gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { return xwindow_; } @@ -843,7 +843,7 @@ void DesktopWindowTreeHostX11::ReleaseCapture() { bool DesktopWindowTreeHostX11::QueryMouseLocation( gfx::Point* location_return) { aura::client::CursorClient* cursor_client = - aura::client::GetCursorClient(GetRootWindow()->window()); + aura::client::GetCursorClient(GetDispatcher()->window()); if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { *location_return = gfx::Point(0, 0); return false; @@ -1141,8 +1141,8 @@ void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { } else { // Another DesktopWindowTreeHostX11 has installed itself as // capture. Translate the event's location and dispatch to the other. - event->ConvertLocationToTarget(root_window_->window(), - g_current_capture->root_window_->window()); + event->ConvertLocationToTarget(dispatcher_->window(), + g_current_capture->dispatcher_->window()); g_current_capture->SendEventToProcessor(event); } } @@ -1150,8 +1150,8 @@ void DesktopWindowTreeHostX11::DispatchMouseEvent(ui::MouseEvent* event) { void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { if (g_current_capture && g_current_capture != this && event->type() == ui::ET_TOUCH_PRESSED) { - event->ConvertLocationToTarget(root_window_->window(), - g_current_capture->root_window_->window()); + event->ConvertLocationToTarget(dispatcher_->window(), + g_current_capture->dispatcher_->window()); g_current_capture->SendEventToProcessor(event); } else { SendEventToProcessor(event); @@ -1309,7 +1309,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { aura::client::UserActionClient* gesture_client = - aura::client::GetUserActionClient(root_window_->window()); + aura::client::GetUserActionClient(dispatcher_->window()); if (gesture_client) { gesture_client->OnUserAction( static_cast<int>(xev->xbutton.button) == kBackMouseButton ? @@ -1418,7 +1418,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { if (button == kBackMouseButton || button == kForwardMouseButton) { aura::client::UserActionClient* gesture_client = aura::client::GetUserActionClient( - delegate_->AsRootWindow()->window()); + delegate_->AsDispatcher()->window()); if (gesture_client) { bool reverse_direction = ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); @@ -1485,7 +1485,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { Atom protocol = static_cast<Atom>(xev->xclient.data.l[0]); if (protocol == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { // We have received a close message from the window manager. - root_window_->OnWindowTreeHostCloseRequested(); + dispatcher_->OnWindowTreeHostCloseRequested(); } else if (protocol == atom_cache_.GetAtom("_NET_WM_PING")) { XEvent reply_event = *xev; reply_event.xclient.window = x_root_window_; @@ -1516,7 +1516,7 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) { case MappingModifier: case MappingKeyboard: XRefreshKeyboardMapping(&xev->xmapping); - root_window_->OnKeyboardMappingChanged(); + dispatcher_->OnKeyboardMappingChanged(); break; case MappingPointer: ui::DeviceDataManager::GetInstance()->UpdateButtonMap(); diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h index 56411ae..f10e646 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h @@ -8,9 +8,6 @@ #include <X11/extensions/shape.h> #include <X11/Xlib.h> -// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. -#undef RootWindow - #include "base/basictypes.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" @@ -71,10 +68,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : protected: // Overridden from DesktopWindowTreeHost: - virtual void Init(aura::Window* content_window, - const Widget::InitParams& params, - aura::RootWindow::CreateParams* rw_create_params) OVERRIDE; - virtual void OnRootWindowCreated(aura::RootWindow* root, + virtual void Init( + aura::Window* content_window, + const Widget::InitParams& params, + aura::WindowEventDispatcher::CreateParams* rw_create_params) OVERRIDE; + virtual void OnRootWindowCreated(aura::WindowEventDispatcher* dispatcher, const Widget::InitParams& params) OVERRIDE; virtual scoped_ptr<corewm::Tooltip> CreateTooltip() OVERRIDE; virtual scoped_ptr<aura::client::DragDropClient> @@ -134,7 +132,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : virtual bool IsAnimatingClosed() const OVERRIDE; // Overridden from aura::WindowTreeHost: - virtual aura::RootWindow* GetRootWindow() OVERRIDE; virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; @@ -164,9 +161,9 @@ private: // initialization related to talking to the X11 server. void InitX11Window(const Widget::InitParams& params); - // Creates an aura::RootWindow to contain the |content_window|, along with - // all aura client objects that direct behavior. - aura::RootWindow* InitRootWindow(const Widget::InitParams& params); + // Creates an aura::WindowEventDispatcher to contain the |content_window|, + // along with all aura client objects that direct behavior. + aura::WindowEventDispatcher* InitDispatcher(const Widget::InitParams& params); // Returns true if there's an X window manager present... in most cases. Some // window managers (notably, ion3) don't implement enough of ICCCM for us to @@ -255,8 +252,9 @@ private: // True if the window has title-bar / borders provided by the window manager. bool use_native_frame_; - // We are owned by the RootWindow, but we have to have a back pointer to it. - aura::RootWindow* root_window_; + // We are owned by the WindowEventDispatcher, but we have to have a back + // pointer to it. + aura::WindowEventDispatcher* dispatcher_; scoped_ptr<DesktopDispatcherClient> dispatcher_client_; diff --git a/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc b/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc index 58f3ff5..77a4b21 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc +++ b/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc @@ -5,8 +5,6 @@ #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h" #include <X11/Xlib.h> -// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. -#undef RootWindow #include "base/debug/stack_trace.h" #include "base/message_loop/message_loop.h" @@ -43,7 +41,7 @@ namespace views { X11DesktopWindowMoveClient::X11DesktopWindowMoveClient() : move_loop_(this), - root_window_(NULL) { + dispatcher_(NULL) { } X11DesktopWindowMoveClient::~X11DesktopWindowMoveClient() {} @@ -52,7 +50,7 @@ void X11DesktopWindowMoveClient::OnMouseMovement(XMotionEvent* event) { gfx::Point cursor_point(event->x_root, event->y_root); gfx::Point system_loc = cursor_point - window_offset_; - gfx::Rect target_rect(system_loc, root_window_->host()->GetBounds().size()); + gfx::Rect target_rect(system_loc, dispatcher_->host()->GetBounds().size()); window_move_timer_.Start( FROM_HERE, @@ -67,7 +65,7 @@ void X11DesktopWindowMoveClient::OnMouseReleased() { } void X11DesktopWindowMoveClient::OnMoveLoopEnded() { - root_window_ = NULL; + dispatcher_ = NULL; } //////////////////////////////////////////////////////////////////////////////// @@ -78,10 +76,10 @@ aura::client::WindowMoveResult X11DesktopWindowMoveClient::RunMoveLoop( const gfx::Vector2d& drag_offset, aura::client::WindowMoveSource move_source) { window_offset_ = drag_offset; - root_window_ = source->GetDispatcher(); + dispatcher_ = source->GetDispatcher(); bool success = move_loop_.RunMoveLoop(source, - root_window_->host()->last_cursor()); + dispatcher_->host()->last_cursor()); return success ? aura::client::MOVE_SUCCESSFUL : aura::client::MOVE_CANCELED; } @@ -94,7 +92,7 @@ void X11DesktopWindowMoveClient::EndMoveLoop() { // DesktopWindowTreeHostLinux, private: void X11DesktopWindowMoveClient::SetHostBounds(const gfx::Rect& rect) { - root_window_->host()->SetBounds(rect); + dispatcher_->host()->SetBounds(rect); } } // namespace views diff --git a/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h b/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h index 3be6a63c..935ffcd 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h +++ b/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h @@ -7,9 +7,6 @@ #include <X11/Xlib.h> -// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. -#undef RootWindow - #include "base/callback.h" #include "base/compiler_specific.h" #include "base/message_loop/message_loop.h" @@ -21,7 +18,7 @@ #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" namespace aura { -class RootWindow; +class WindowEventDispatcher; } namespace gfx { @@ -58,7 +55,7 @@ class VIEWS_EXPORT X11DesktopWindowMoveClient : // We need to keep track of this so we can actually move it when reacting to // mouse events. - aura::RootWindow* root_window_; + aura::WindowEventDispatcher* dispatcher_; // Our cursor offset from the top left window origin when the drag // started. Used to calculate the window's new bounds relative to the current diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.cc b/ui/views/widget/desktop_aura/x11_window_event_filter.cc index 1336c46..c43e192 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc @@ -61,10 +61,10 @@ const char* kAtomsToCache[] = { namespace views { X11WindowEventFilter::X11WindowEventFilter( - aura::RootWindow* root_window, + aura::WindowEventDispatcher* dispatcher, DesktopWindowTreeHost* window_tree_host) : xdisplay_(gfx::GetXDisplay()), - xwindow_(root_window->host()->GetAcceleratedWidget()), + xwindow_(dispatcher->host()->GetAcceleratedWidget()), x_root_window_(DefaultRootWindow(xdisplay_)), atom_cache_(xdisplay_, kAtomsToCache), window_tree_host_(window_tree_host), diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.h b/ui/views/widget/desktop_aura/x11_window_event_filter.h index 41f2454..ad93774 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.h +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.h @@ -6,8 +6,6 @@ #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WINDOW_EVENT_FILTER_H_ #include <X11/Xlib.h> -// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. -#undef RootWindow #include "base/compiler_specific.h" #include "base/message_loop/message_loop.h" @@ -17,8 +15,8 @@ #include "ui/views/views_export.h" namespace aura { -class RootWindow; class Window; +class WindowEventDispatcher; } namespace gfx { @@ -32,7 +30,7 @@ class NativeWidgetAura; // An EventFilter that sets properties on X11 windows. class VIEWS_EXPORT X11WindowEventFilter : public ui::EventHandler { public: - X11WindowEventFilter(aura::RootWindow* root_window, + X11WindowEventFilter(aura::WindowEventDispatcher* dispatcher, DesktopWindowTreeHost* window_tree_host); virtual ~X11WindowEventFilter(); diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc index 623352c..a600f44 100644 --- a/ui/views/widget/native_widget_aura_unittest.cc +++ b/ui/views/widget/native_widget_aura_unittest.cc @@ -45,14 +45,17 @@ class NativeWidgetAuraTest : public ViewsTestBase { protected: aura::Window* root_window() { return GetContext(); } - aura::RootWindow* dispatcher() { return root_window()->GetDispatcher(); } + aura::WindowEventDispatcher* dispatcher() { + return root_window()->GetDispatcher(); + } private: DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); }; TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { - // Make a parent window larger than the host represented by rootwindow. + // Make a parent window larger than the host represented by + // WindowEventDispatcher. scoped_ptr<aura::Window> parent(new aura::Window(NULL)); parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); @@ -68,7 +71,8 @@ TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { } TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { - // Make a parent window smaller than the host represented by rootwindow. + // Make a parent window smaller than the host represented by + // WindowEventDispatcher. scoped_ptr<aura::Window> parent(new aura::Window(NULL)); parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); parent->SetBounds(gfx::Rect(0, 0, 480, 320)); @@ -85,8 +89,8 @@ TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { // Verifies CenterWindow() constrains to parent size. TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) { - // Make a parent window smaller than the host represented by rootwindow and - // offset it slightly from the origin. + // Make a parent window smaller than the host represented by + // WindowEventDispatcher and offset it slightly from the origin. scoped_ptr<aura::Window> parent(new aura::Window(NULL)); parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); parent->SetBounds(gfx::Rect(20, 40, 480, 320)); diff --git a/ui/wm/test/wm_test_helper.cc b/ui/wm/test/wm_test_helper.cc index d32cf65..bb1753d 100644 --- a/ui/wm/test/wm_test_helper.cc +++ b/ui/wm/test/wm_test_helper.cc @@ -16,30 +16,30 @@ namespace wm { WMTestHelper::WMTestHelper(const gfx::Size& default_window_size) { aura::Env::CreateInstance(); - root_window_.reset(new aura::RootWindow( - aura::RootWindow::CreateParams( + dispatcher_.reset(new aura::WindowEventDispatcher( + aura::WindowEventDispatcher::CreateParams( gfx::Rect(default_window_size)))); - root_window_->host()->InitHost(); - aura::client::SetWindowTreeClient(root_window_->window(), this); + dispatcher_->host()->InitHost(); + aura::client::SetWindowTreeClient(dispatcher_->window(), this); focus_client_.reset(new aura::test::TestFocusClient); - aura::client::SetFocusClient(root_window_->window(), focus_client_.get()); + aura::client::SetFocusClient(dispatcher_->window(), focus_client_.get()); root_window_event_filter_ = new views::corewm::CompoundEventFilter; // Pass ownership of the filter to the root_window. - root_window_->window()->SetEventFilter(root_window_event_filter_); + dispatcher_->window()->SetEventFilter(root_window_event_filter_); input_method_filter_.reset(new views::corewm::InputMethodEventFilter( - root_window_->host()->GetAcceleratedWidget())); + dispatcher_->host()->GetAcceleratedWidget())); input_method_filter_->SetInputMethodPropertyInRootWindow( - root_window_->window()); + dispatcher_->window()); root_window_event_filter_->AddHandler(input_method_filter_.get()); activation_client_.reset( - new aura::client::DefaultActivationClient(root_window_->window())); + new aura::client::DefaultActivationClient(dispatcher_->window())); capture_client_.reset( - new aura::client::DefaultCaptureClient(root_window_->window())); + new aura::client::DefaultCaptureClient(dispatcher_->window())); } WMTestHelper::~WMTestHelper() { @@ -49,7 +49,7 @@ WMTestHelper::~WMTestHelper() { aura::Window* WMTestHelper::GetDefaultParent(aura::Window* context, aura::Window* window, const gfx::Rect& bounds) { - return root_window_->window(); + return dispatcher_->window(); } } // namespace wm diff --git a/ui/wm/test/wm_test_helper.h b/ui/wm/test/wm_test_helper.h index ba23ee7..da2d153 100644 --- a/ui/wm/test/wm_test_helper.h +++ b/ui/wm/test/wm_test_helper.h @@ -10,8 +10,8 @@ #include "ui/aura/client/window_tree_client.h" namespace aura { -class RootWindow; class Window; +class WindowEventDispatcher; namespace client { class DefaultActivationClient; class DefaultCaptureClient; @@ -41,7 +41,7 @@ class WMTestHelper : public aura::client::WindowTreeClient { explicit WMTestHelper(const gfx::Size& default_window_size); virtual ~WMTestHelper(); - aura::RootWindow* root_window() { return root_window_.get(); } + aura::WindowEventDispatcher* dispatcher() { return dispatcher_.get(); } // Overridden from client::WindowTreeClient: virtual aura::Window* GetDefaultParent(aura::Window* context, @@ -49,9 +49,9 @@ class WMTestHelper : public aura::client::WindowTreeClient { const gfx::Rect& bounds) OVERRIDE; private: - scoped_ptr<aura::RootWindow> root_window_; + scoped_ptr<aura::WindowEventDispatcher> dispatcher_; - // Owned by RootWindow + // Owned by the root Window. views::corewm::CompoundEventFilter* root_window_event_filter_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |