Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: athena/wm/window_manager_impl.cc

Issue 406393003: Cleanup athena's WindowManagerImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/input/public/accelerator_manager.h"
8 #include "athena/screen/public/screen_manager.h" 8 #include "athena/screen/public/screen_manager.h"
9 #include "athena/wm/public/window_manager_observer.h" 9 #include "athena/wm/public/window_manager_observer.h"
10 #include "athena/wm/window_overview_mode.h" 10 #include "athena/wm/window_overview_mode.h"
(...skipping 10 matching lines...) Expand all
21 public WindowOverviewModeDelegate, 21 public WindowOverviewModeDelegate,
22 public aura::WindowObserver, 22 public aura::WindowObserver,
23 public AcceleratorHandler { 23 public AcceleratorHandler {
24 public: 24 public:
25 WindowManagerImpl(); 25 WindowManagerImpl();
26 virtual ~WindowManagerImpl(); 26 virtual ~WindowManagerImpl();
27 27
28 void Layout(); 28 void Layout();
29 29
30 // WindowManager: 30 // WindowManager:
31 virtual void ToggleOverview() OVERRIDE { 31 virtual void ToggleOverview() OVERRIDE;
32 if (overview_) {
33 overview_.reset();
34 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
35 OnOverviewModeExit());
36 } else {
37 overview_ = WindowOverviewMode::Create(container_.get(), this);
38 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
39 OnOverviewModeEnter());
40 }
41 }
42 32
43 private: 33 private:
44 enum Command { 34 enum Command {
45 COMMAND_TOGGLE_OVERVIEW, 35 COMMAND_TOGGLE_OVERVIEW,
46 }; 36 };
47 37
48 void InstallAccelerators() { 38 void InstallAccelerators();
49 const AcceleratorData accelerator_data[] = {
50 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
51 AF_NONE},
52 };
53 AcceleratorManager::Get()->RegisterAccelerators(
54 accelerator_data, arraysize(accelerator_data), this);
55 }
56 39
57 // WindowManager: 40 // WindowManager:
58 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE { 41 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE;
59 observers_.AddObserver(observer); 42 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE;
60 }
61
62 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE {
63 observers_.RemoveObserver(observer);
64 }
65 43
66 // WindowOverviewModeDelegate: 44 // WindowOverviewModeDelegate:
67 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { 45 virtual void OnSelectWindow(aura::Window* window) OVERRIDE;
68 CHECK_EQ(container_.get(), window->parent());
69 container_->StackChildAtTop(window);
70 overview_.reset();
71 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
72 OnOverviewModeExit());
73 }
74 46
75 // aura::WindowObserver 47 // aura::WindowObserver
76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { 48 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
77 if (window == container_)
78 container_.reset();
79 }
80 49
81 // AcceleratorHandler: 50 // AcceleratorHandler:
82 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; } 51 virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
83 virtual bool OnAcceleratorFired(int command_id, 52 virtual bool OnAcceleratorFired(int command_id,
84 const ui::Accelerator& accelerator) OVERRIDE { 53 const ui::Accelerator& accelerator) OVERRIDE;
85 switch (command_id) {
86 case COMMAND_TOGGLE_OVERVIEW:
87 ToggleOverview();
88 break;
89 }
90 return true;
91 }
92 54
93 scoped_ptr<aura::Window> container_; 55 scoped_ptr<aura::Window> container_;
94 scoped_ptr<WindowOverviewMode> overview_; 56 scoped_ptr<WindowOverviewMode> overview_;
95 ObserverList<WindowManagerObserver> observers_; 57 ObserverList<WindowManagerObserver> observers_;
96 58
97 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 59 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
98 }; 60 };
99 61
100 class WindowManagerImpl* instance = NULL; 62 class WindowManagerImpl* instance = NULL;
101 63
102 class AthenaContainerLayoutManager : public aura::LayoutManager { 64 class AthenaContainerLayoutManager : public aura::LayoutManager {
flackr 2014/07/23 02:34:19 Can you move this class so the implementation imme
pkotwicz 2014/07/23 04:25:36 WindowManagerImpl uses AthenaContainerLayoutManage
103 public: 65 public:
104 AthenaContainerLayoutManager() {} 66 AthenaContainerLayoutManager() {}
105 virtual ~AthenaContainerLayoutManager() {} 67 virtual ~AthenaContainerLayoutManager() {}
106 68
107 private: 69 private:
108 // aura::LayoutManager: 70 // aura::LayoutManager:
109 virtual void OnWindowResized() OVERRIDE { instance->Layout(); } 71 virtual void OnWindowResized() OVERRIDE { instance->Layout(); }
110 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { 72 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
111 instance->Layout(); 73 instance->Layout();
112 } 74 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const aura::Window::Windows& children = container_->children(); 113 const aura::Window::Windows& children = container_->children();
152 for (aura::Window::Windows::const_iterator iter = children.begin(); 114 for (aura::Window::Windows::const_iterator iter = children.begin();
153 iter != children.end(); 115 iter != children.end();
154 ++iter) { 116 ++iter) {
155 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL || 117 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL ||
156 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP) 118 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP)
157 (*iter)->SetBounds(bounds); 119 (*iter)->SetBounds(bounds);
158 } 120 }
159 } 121 }
160 122
123 void WindowManagerImpl::ToggleOverview() {
124 if (overview_) {
125 overview_.reset();
126 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
127 OnOverviewModeExit());
128 } else {
129 overview_ = WindowOverviewMode::Create(container_.get(), this);
130 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
131 OnOverviewModeEnter());
132 }
133 }
134
135 void WindowManagerImpl::InstallAccelerators() {
136 const AcceleratorData accelerator_data[] = {
137 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
138 AF_NONE},
139 };
140 AcceleratorManager::Get()->RegisterAccelerators(
141 accelerator_data, arraysize(accelerator_data), this);
142 }
143
144 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
145 observers_.AddObserver(observer);
146 }
147
148 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
149 observers_.RemoveObserver(observer);
150 }
151
152 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
153 CHECK_EQ(container_.get(), window->parent());
154 container_->StackChildAtTop(window);
155 overview_.reset();
156 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
157 OnOverviewModeExit());
158 }
159
160 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
161 if (window == container_)
162 container_.reset();
163 }
164
165 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
166 return true;
167 }
168
169 bool WindowManagerImpl::OnAcceleratorFired(int command_id,
170 const ui::Accelerator& accelerator) {
171 switch (command_id) {
172 case COMMAND_TOGGLE_OVERVIEW:
173 ToggleOverview();
174 break;
175 }
176 return true;
177 }
178
161 } // namespace 179 } // namespace
162 180
163 // static 181 // static
164 WindowManager* WindowManager::Create() { 182 WindowManager* WindowManager::Create() {
165 DCHECK(!instance); 183 DCHECK(!instance);
166 new WindowManagerImpl; 184 new WindowManagerImpl;
167 DCHECK(instance); 185 DCHECK(instance);
168 return instance; 186 return instance;
169 } 187 }
170 188
171 // static 189 // static
172 void WindowManager::Shutdown() { 190 void WindowManager::Shutdown() {
173 DCHECK(instance); 191 DCHECK(instance);
174 delete instance; 192 delete instance;
175 DCHECK(!instance); 193 DCHECK(!instance);
176 } 194 }
177 195
178 // static 196 // static
179 WindowManager* WindowManager::GetInstance() { 197 WindowManager* WindowManager::GetInstance() {
180 DCHECK(instance); 198 DCHECK(instance);
181 return instance; 199 return instance;
182 } 200 }
183 201
184 } // namespace athena 202 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698