Commit e092727e authored by oshima@chromium.org's avatar oshima@chromium.org

Use accelerator to switch overview mode

BUG=None
R=sadrul@chromium.org

Review URL: https://codereview.chromium.org/394683002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283452 0039d316-1c4b-4281-b951-d872f2087c98
parent 55d0849a
include_rules = [ include_rules = [
"+athena/input/public",
"+athena/screen/public", "+athena/screen/public",
"+ui/aura", "+ui/aura",
"+ui/compositor", "+ui/compositor",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "athena/wm/public/window_manager.h" #include "athena/wm/public/window_manager.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/screen/public/screen_manager.h" #include "athena/screen/public/screen_manager.h"
#include "athena/wm/window_overview_mode.h" #include "athena/wm/window_overview_mode.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -16,11 +17,14 @@ namespace { ...@@ -16,11 +17,14 @@ namespace {
class WindowManagerImpl : public WindowManager, class WindowManagerImpl : public WindowManager,
public WindowOverviewModeDelegate, public WindowOverviewModeDelegate,
public aura::WindowObserver { public aura::WindowObserver,
public AcceleratorHandler {
public: public:
WindowManagerImpl(); WindowManagerImpl();
virtual ~WindowManagerImpl(); virtual ~WindowManagerImpl();
void Init() { InstallAccelerators(); }
void Layout(); void Layout();
// WindowManager: // WindowManager:
...@@ -32,6 +36,19 @@ class WindowManagerImpl : public WindowManager, ...@@ -32,6 +36,19 @@ class WindowManagerImpl : public WindowManager,
} }
private: private:
enum Command {
COMMAND_TOGGLE_OVERVIEW,
};
void InstallAccelerators() {
const AcceleratorData accelerator_data[] = {
{TRIGGER_ON_PRESS, ui::VKEY_6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
AF_NONE},
};
AcceleratorManager::Get()->RegisterAccelerators(
accelerator_data, arraysize(accelerator_data), this);
}
// WindowOverviewModeDelegate: // WindowOverviewModeDelegate:
virtual void OnSelectWindow(aura::Window* window) OVERRIDE { virtual void OnSelectWindow(aura::Window* window) OVERRIDE {
CHECK_EQ(container_.get(), window->parent()); CHECK_EQ(container_.get(), window->parent());
...@@ -45,8 +62,19 @@ class WindowManagerImpl : public WindowManager, ...@@ -45,8 +62,19 @@ class WindowManagerImpl : public WindowManager,
container_.reset(); container_.reset();
} }
// AcceleratorHandler:
virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; }
virtual bool OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) OVERRIDE {
switch (command_id) {
case COMMAND_TOGGLE_OVERVIEW:
ToggleOverview();
break;
}
return true;
}
scoped_ptr<aura::Window> container_; scoped_ptr<aura::Window> container_;
scoped_ptr<ui::EventHandler> temp_handler_;
scoped_ptr<WindowOverviewMode> overview_; scoped_ptr<WindowOverviewMode> overview_;
DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
...@@ -82,37 +110,17 @@ class AthenaContainerLayoutManager : public aura::LayoutManager { ...@@ -82,37 +110,17 @@ class AthenaContainerLayoutManager : public aura::LayoutManager {
DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager); DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager);
}; };
class TempEventHandler : public ui::EventHandler {
public:
TempEventHandler() {}
virtual ~TempEventHandler() {}
private:
// ui::EventHandler:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
if (event->type() == ui::ET_KEY_PRESSED &&
event->key_code() == ui::VKEY_F6) {
instance->ToggleOverview();
}
}
DISALLOW_COPY_AND_ASSIGN(TempEventHandler);
};
WindowManagerImpl::WindowManagerImpl() WindowManagerImpl::WindowManagerImpl()
: container_(ScreenManager::Get()->CreateDefaultContainer("MainContainer")), : container_(
temp_handler_(new TempEventHandler()) { ScreenManager::Get()->CreateDefaultContainer("MainContainer")) {
container_->SetLayoutManager(new AthenaContainerLayoutManager); container_->SetLayoutManager(new AthenaContainerLayoutManager);
container_->AddObserver(this); container_->AddObserver(this);
container_->AddPreTargetHandler(temp_handler_.get());
instance = this; instance = this;
} }
WindowManagerImpl::~WindowManagerImpl() { WindowManagerImpl::~WindowManagerImpl() {
if (container_) { if (container_)
container_->RemovePreTargetHandler(temp_handler_.get());
container_->RemoveObserver(this); container_->RemoveObserver(this);
}
container_.reset(); container_.reset();
instance = NULL; instance = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment