Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "athena/wm/public/window_manager.h" | 5 #include "athena/wm/public/window_manager.h" |
| 6 | 6 |
| 7 #include "athena/input/public/accelerator_manager.h" | |
| 7 #include "athena/screen/public/screen_manager.h" | 8 #include "athena/screen/public/screen_manager.h" |
| 8 #include "athena/wm/window_overview_mode.h" | 9 #include "athena/wm/window_overview_mode.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "ui/aura/layout_manager.h" | 11 #include "ui/aura/layout_manager.h" |
| 11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 12 #include "ui/wm/public/window_types.h" | 13 #include "ui/wm/public/window_types.h" |
| 13 | 14 |
| 14 namespace athena { | 15 namespace athena { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 class WindowManagerImpl : public WindowManager, | 18 class WindowManagerImpl : public WindowManager, |
| 18 public WindowOverviewModeDelegate, | 19 public WindowOverviewModeDelegate, |
| 19 public aura::WindowObserver { | 20 public aura::WindowObserver, |
| 21 public AcceleratorHandler { | |
| 20 public: | 22 public: |
| 21 WindowManagerImpl(); | 23 WindowManagerImpl(); |
| 22 virtual ~WindowManagerImpl(); | 24 virtual ~WindowManagerImpl(); |
| 23 | 25 |
| 26 void Init() { | |
| 27 InstallAccelerators(); | |
| 28 } | |
| 29 | |
| 24 void Layout(); | 30 void Layout(); |
| 25 | 31 |
| 32 | |
|
sadrul
2014/07/15 04:41:38
remove this extra blank line.
oshima
2014/07/15 19:36:18
Done.
| |
| 26 // WindowManager: | 33 // WindowManager: |
| 27 virtual void ToggleOverview() OVERRIDE { | 34 virtual void ToggleOverview() OVERRIDE { |
| 28 if (overview_) | 35 if (overview_) |
| 29 overview_.reset(); | 36 overview_.reset(); |
| 30 else | 37 else |
| 31 overview_ = WindowOverviewMode::Create(container_.get(), this); | 38 overview_ = WindowOverviewMode::Create(container_.get(), this); |
| 32 } | 39 } |
| 33 | 40 |
| 34 private: | 41 private: |
| 42 enum Command { | |
| 43 COMMAND_TOGGLE_OVERVIEW, | |
| 44 }; | |
| 45 | |
| 46 void InstallAccelerators() { | |
| 47 const AcceleratorData accelerator_data[] = { | |
| 48 {TRIGGER_ON_PRESS, ui::VKEY_6, ui::EF_NONE, | |
| 49 COMMAND_TOGGLE_OVERVIEW, AF_NONE}, | |
| 50 }; | |
| 51 AcceleratorManager::Get()->RegisterAccelerators( | |
| 52 accelerator_data, arraysize(accelerator_data), this); | |
| 53 } | |
| 54 | |
| 35 // WindowOverviewModeDelegate: | 55 // WindowOverviewModeDelegate: |
| 36 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { | 56 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { |
| 37 CHECK_EQ(container_.get(), window->parent()); | 57 CHECK_EQ(container_.get(), window->parent()); |
| 38 container_->StackChildAtTop(window); | 58 container_->StackChildAtTop(window); |
| 39 overview_.reset(); | 59 overview_.reset(); |
| 40 } | 60 } |
| 41 | 61 |
| 42 // aura::WindowObserver | 62 // aura::WindowObserver |
| 43 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 63 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { |
| 44 if (window == container_) | 64 if (window == container_) |
| 45 container_.reset(); | 65 container_.reset(); |
| 46 } | 66 } |
| 47 | 67 |
| 68 // AcceleratorHandler: | |
| 69 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; } | |
| 70 virtual bool OnAcceleratorFired(int command_id, | |
| 71 const ui::Accelerator& accelerator) OVERRIDE { | |
| 72 switch (command_id) { | |
| 73 case COMMAND_TOGGLE_OVERVIEW: | |
| 74 ToggleOverview(); | |
| 75 break; | |
| 76 } | |
| 77 return true; | |
| 78 } | |
| 79 | |
| 48 scoped_ptr<aura::Window> container_; | 80 scoped_ptr<aura::Window> container_; |
| 49 scoped_ptr<ui::EventHandler> temp_handler_; | 81 scoped_ptr<ui::EventHandler> temp_handler_; |
| 50 scoped_ptr<WindowOverviewMode> overview_; | 82 scoped_ptr<WindowOverviewMode> overview_; |
| 51 | 83 |
| 52 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); | 84 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); |
| 53 }; | 85 }; |
| 54 | 86 |
| 55 class WindowManagerImpl* instance = NULL; | 87 class WindowManagerImpl* instance = NULL; |
| 56 | 88 |
| 57 class AthenaContainerLayoutManager : public aura::LayoutManager { | 89 class AthenaContainerLayoutManager : public aura::LayoutManager { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 75 } | 107 } |
| 76 virtual void SetChildBounds(aura::Window* child, | 108 virtual void SetChildBounds(aura::Window* child, |
| 77 const gfx::Rect& requested_bounds) OVERRIDE { | 109 const gfx::Rect& requested_bounds) OVERRIDE { |
| 78 if (!requested_bounds.IsEmpty()) | 110 if (!requested_bounds.IsEmpty()) |
| 79 SetChildBoundsDirect(child, requested_bounds); | 111 SetChildBoundsDirect(child, requested_bounds); |
| 80 } | 112 } |
| 81 | 113 |
| 82 DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager); | 114 DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager); |
| 83 }; | 115 }; |
| 84 | 116 |
| 85 class TempEventHandler : public ui::EventHandler { | 117 class TempEventHandler : public ui::EventHandler { |
|
sadrul
2014/07/15 04:41:38
This should no longer be necessary, right?
oshima
2014/07/15 19:36:18
Thanks, removed.
| |
| 86 public: | 118 public: |
| 87 TempEventHandler() {} | 119 TempEventHandler() {} |
| 88 virtual ~TempEventHandler() {} | 120 virtual ~TempEventHandler() {} |
| 89 | 121 |
| 90 private: | 122 private: |
| 91 // ui::EventHandler: | 123 // ui::EventHandler: |
| 92 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 124 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { |
| 93 if (event->type() == ui::ET_KEY_PRESSED && | 125 if (event->type() == ui::ET_KEY_PRESSED && |
| 94 event->key_code() == ui::VKEY_F6) { | 126 event->key_code() == ui::VKEY_F6) { |
| 95 instance->ToggleOverview(); | 127 instance->ToggleOverview(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 174 } |
| 143 | 175 |
| 144 // static | 176 // static |
| 145 void WindowManager::Shutdown() { | 177 void WindowManager::Shutdown() { |
| 146 DCHECK(instance); | 178 DCHECK(instance); |
| 147 delete instance; | 179 delete instance; |
| 148 DCHECK(!instance); | 180 DCHECK(!instance); |
| 149 } | 181 } |
| 150 | 182 |
| 151 } // namespace athena | 183 } // namespace athena |
| OLD | NEW |