diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-06-20 14:52:04 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-06-20 14:52:04 +0100 |
commit | f8ee788a64d60abd8f2d742a5fdedde054ecd910 (patch) | |
tree | 7dc14380200b953c64e0ccd16435cdbd1dbf1205 /athena/screen | |
parent | fcbbbe23a38088a52492922075e71a419c4b01ec (diff) | |
download | chromium_org-f8ee788a64d60abd8f2d742a5fdedde054ecd910.tar.gz |
Merge from Chromium at DEPS revision 278205
This commit was generated by merge_to_master.py.
Change-Id: I23f1e7ea8c154ba72e7fb594436216f861f868ab
Diffstat (limited to 'athena/screen')
-rw-r--r-- | athena/screen/DEPS | 2 | ||||
-rw-r--r-- | athena/screen/background_controller.cc | 2 | ||||
-rw-r--r-- | athena/screen/screen_accelerator_handler.cc | 96 | ||||
-rw-r--r-- | athena/screen/screen_accelerator_handler.h | 33 | ||||
-rw-r--r-- | athena/screen/screen_manager_impl.cc | 8 |
5 files changed, 141 insertions, 0 deletions
diff --git a/athena/screen/DEPS b/athena/screen/DEPS index 08856b1c42..0dbb68d29b 100644 --- a/athena/screen/DEPS +++ b/athena/screen/DEPS @@ -1,6 +1,8 @@ include_rules = [ + "+athena/input/public", "+ui/aura", "+ui/compositor", "+ui/gfx", "+ui/views", + "+ui/wm", ] diff --git a/athena/screen/background_controller.cc b/athena/screen/background_controller.cc index 53cf3e2491..66686d0ca8 100644 --- a/athena/screen/background_controller.cc +++ b/athena/screen/background_controller.cc @@ -51,11 +51,13 @@ BackgroundController::BackgroundController(aura::Window* container) { views::Widget* background_widget = new views::Widget; views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); + params.accept_events = false; params.parent = container; background_widget->Init(params); background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true); background_view_ = new BackgroundView; background_widget->SetContentsView(background_view_); + background_widget->GetNativeView()->SetName("BackgroundWidget"); background_widget->Show(); } diff --git a/athena/screen/screen_accelerator_handler.cc b/athena/screen/screen_accelerator_handler.cc new file mode 100644 index 0000000000..031a039dc6 --- /dev/null +++ b/athena/screen/screen_accelerator_handler.cc @@ -0,0 +1,96 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "athena/screen/screen_accelerator_handler.h" + +#include "athena/input/public/accelerator_manager.h" +#include "ui/aura/window.h" +#include "ui/aura/window_event_dispatcher.h" +#include "ui/aura/window_tree_host.h" +#include "ui/compositor/debug_utils.h" +#include "ui/wm/public/activation_client.h" + +namespace athena { +namespace { + +enum Command { + CMD_PRINT_LAYER_HIERARCHY, + CMD_PRINT_WINDOW_HIERARCHY, +}; + +const int EF_ALL_DOWN = + ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN; + +const AcceleratorData accelerator_data[] = { + {TRIGGER_ON_PRESS, ui::VKEY_L, EF_ALL_DOWN, CMD_PRINT_LAYER_HIERARCHY, + AF_DEBUG}, + {TRIGGER_ON_PRESS, ui::VKEY_W, EF_ALL_DOWN, CMD_PRINT_WINDOW_HIERARCHY, + AF_DEBUG}, +}; + +void PrintLayerHierarchy(aura::Window* root_window) { + ui::PrintLayerHierarchy( + root_window->layer(), + root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot()); +} + +void PrintWindowHierarchy(aura::Window* window, + aura::Window* active, + int indent, + std::ostringstream* out) { + std::string indent_str(indent, ' '); + std::string name(window->name()); + if (name.empty()) + name = "\"\""; + *out << indent_str << name << " (" << window << ")" + << " type=" << window->type() + << ((window == active) ? " [active] " : " ") + << (window->IsVisible() ? " visible " : " ") + << window->bounds().ToString() << '\n'; + + for (size_t i = 0; i < window->children().size(); ++i) + PrintWindowHierarchy(window->children()[i], active, indent + 3, out); +} + +void HandlePrintWindowHierarchy(aura::Window* root_window) { + aura::Window* active = + aura::client::GetActivationClient(root_window)->GetActiveWindow(); + std::ostringstream out; + out << "RootWindow :\n"; + PrintWindowHierarchy(root_window, active, 0, &out); + // Error so logs can be collected from end-users. + LOG(ERROR) << out.str(); +} + +} // namespace + +// static +ScreenAcceleratorHandler::ScreenAcceleratorHandler(aura::Window* root_window) + : root_window_(root_window) { + AcceleratorManager::Get()->RegisterAccelerators( + accelerator_data, arraysize(accelerator_data), this); +} + +ScreenAcceleratorHandler::~ScreenAcceleratorHandler() { +} + +bool ScreenAcceleratorHandler::IsCommandEnabled(int command_id) const { + return true; +} + +bool ScreenAcceleratorHandler::OnAcceleratorFired( + int command_id, + const ui::Accelerator& accelerator) { + switch (command_id) { + case CMD_PRINT_LAYER_HIERARCHY: + PrintLayerHierarchy(root_window_); + return true; + case CMD_PRINT_WINDOW_HIERARCHY: + HandlePrintWindowHierarchy(root_window_); + return true; + } + return false; +} + +} // namesapce athena diff --git a/athena/screen/screen_accelerator_handler.h b/athena/screen/screen_accelerator_handler.h new file mode 100644 index 0000000000..7e7a9eaf20 --- /dev/null +++ b/athena/screen/screen_accelerator_handler.h @@ -0,0 +1,33 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "athena/input/public/accelerator_manager.h" + +#include "base/macros.h" + +namespace aura { +class Window; +} + +namespace athena { + +// Handles screen related accelerators. +class ScreenAcceleratorHandler : public AcceleratorHandler { + public: + explicit ScreenAcceleratorHandler(aura::Window* root_window); + + private: + virtual ~ScreenAcceleratorHandler(); + + // AcceleratorHandler: + virtual bool IsCommandEnabled(int command_id) const OVERRIDE; + virtual bool OnAcceleratorFired(int command_id, + const ui::Accelerator& accelerator) OVERRIDE; + + aura::Window* root_window_; + + DISALLOW_COPY_AND_ASSIGN(ScreenAcceleratorHandler); +}; + +} // namespace athena diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc index ca3101a769..e426a80f87 100644 --- a/athena/screen/screen_manager_impl.cc +++ b/athena/screen/screen_manager_impl.cc @@ -4,12 +4,15 @@ #include "athena/screen/public/screen_manager.h" +#include "athena/input/public/accelerator_manager.h" #include "athena/screen/background_controller.h" +#include "athena/screen/screen_accelerator_handler.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "ui/aura/client/window_tree_client.h" #include "ui/aura/layout_manager.h" #include "ui/aura/window.h" +#include "ui/wm/core/capture_controller.h" namespace athena { namespace { @@ -103,6 +106,8 @@ class ScreenManagerImpl : public ScreenManager { scoped_ptr<BackgroundController> background_controller_; scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; + scoped_ptr<AcceleratorHandler> accelerator_handler_; + scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); }; @@ -114,6 +119,9 @@ void ScreenManagerImpl::Init() { background_window_->SetLayoutManager( new FillLayoutManager(background_window_)); background_controller_.reset(new BackgroundController(background_window_)); + + capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); + accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); } aura::Window* ScreenManagerImpl::CreateDefaultContainer( |