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

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

Issue 465983002: Add shoftcut (ctrl-f6) to toggle split view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "athena/common/container_priorities.h" 9 #include "athena/common/container_priorities.h"
10 #include "athena/input/public/accelerator_manager.h" 10 #include "athena/input/public/accelerator_manager.h"
(...skipping 29 matching lines...) Expand all
40 void Layout(); 40 void Layout();
41 41
42 // WindowManager: 42 // WindowManager:
43 virtual void ToggleOverview() OVERRIDE; 43 virtual void ToggleOverview() OVERRIDE;
44 44
45 virtual bool IsOverviewModeActive() OVERRIDE; 45 virtual bool IsOverviewModeActive() OVERRIDE;
46 46
47 private: 47 private:
48 enum Command { 48 enum Command {
49 CMD_TOGGLE_OVERVIEW, 49 CMD_TOGGLE_OVERVIEW,
50 CMD_TOGGLE_SPLIT_VIEW,
50 }; 51 };
51 52
52 // Sets whether overview mode is active. 53 // Sets whether overview mode is active.
53 void SetInOverview(bool active); 54 void SetInOverview(bool active);
54 55
55 void InstallAccelerators(); 56 void InstallAccelerators();
56 57
57 // WindowManager: 58 // WindowManager:
58 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; 59 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE;
59 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; 60 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) 157 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL)
157 (*iter)->SetBounds(bounds); 158 (*iter)->SetBounds(bounds);
158 } 159 }
159 } 160 }
160 161
161 void WindowManagerImpl::ToggleOverview() { 162 void WindowManagerImpl::ToggleOverview() {
162 SetInOverview(overview_.get() == NULL); 163 SetInOverview(overview_.get() == NULL);
163 } 164 }
164 165
165 bool WindowManagerImpl::IsOverviewModeActive() { 166 bool WindowManagerImpl::IsOverviewModeActive() {
166 return overview_; 167 return !!overview_;
167 } 168 }
168 169
169 void WindowManagerImpl::SetInOverview(bool active) { 170 void WindowManagerImpl::SetInOverview(bool active) {
170 bool in_overview = !!overview_; 171 bool in_overview = !!overview_;
171 if (active == in_overview) 172 if (active == in_overview)
172 return; 173 return;
173 174
174 if (active) { 175 if (active) {
175 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 176 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
176 OnOverviewModeEnter()); 177 OnOverviewModeEnter());
177 // Re-stack all windows in the order defined by mru_window_tracker_. 178 // Re-stack all windows in the order defined by mru_window_tracker_.
178 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList(); 179 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList();
179 aura::Window::Windows::iterator it; 180 aura::Window::Windows::iterator it;
180 for (it = window_list.begin(); it != window_list.end(); ++it) 181 for (it = window_list.begin(); it != window_list.end(); ++it)
181 container_->StackChildAtTop(*it); 182 container_->StackChildAtTop(*it);
182 overview_ = WindowOverviewMode::Create(container_.get(), 183 overview_ = WindowOverviewMode::Create(
183 mru_window_tracker_.get(), 184 container_.get(), mru_window_tracker_.get(), this);
184 this);
185 } else { 185 } else {
186 overview_.reset(); 186 overview_.reset();
187 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 187 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
188 OnOverviewModeExit()); 188 OnOverviewModeExit());
189 } 189 }
190 } 190 }
191 191
192 void WindowManagerImpl::InstallAccelerators() { 192 void WindowManagerImpl::InstallAccelerators() {
193 const AcceleratorData accelerator_data[] = { 193 const AcceleratorData accelerator_data[] = {
194 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, 194 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW,
195 AF_NONE}, 195 AF_NONE},
196 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN,
197 CMD_TOGGLE_SPLIT_VIEW, AF_NONE},
196 }; 198 };
197 AcceleratorManager::Get()->RegisterAccelerators( 199 AcceleratorManager::Get()->RegisterAccelerators(
198 accelerator_data, arraysize(accelerator_data), this); 200 accelerator_data, arraysize(accelerator_data), this);
199 } 201 }
200 202
201 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 203 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
202 observers_.AddObserver(observer); 204 observers_.AddObserver(observer);
203 } 205 }
204 206
205 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 207 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
206 observers_.RemoveObserver(observer); 208 observers_.RemoveObserver(observer);
207 } 209 }
208 210
209 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 211 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
210 mru_window_tracker_->MoveToFront(window); 212 mru_window_tracker_->MoveToFront(window);
211 wm::ActivateWindow(window); 213 wm::ActivateWindow(window);
212 SetInOverview(false); 214 SetInOverview(false);
213 } 215 }
214 216
215 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { 217 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) {
218 // TODO(oshima): Creating a new window should simply updates the overview
219 // mode.
216 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) 220 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL)
217 SetInOverview(false); 221 SetInOverview(false);
218 } 222 }
219 223
220 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 224 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
221 if (window == container_) 225 if (window == container_)
222 container_.reset(); 226 container_.reset();
223 } 227 }
224 228
225 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { 229 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
226 return true; 230 return true;
227 } 231 }
228 232
229 bool WindowManagerImpl::OnAcceleratorFired(int command_id, 233 bool WindowManagerImpl::OnAcceleratorFired(int command_id,
230 const ui::Accelerator& accelerator) { 234 const ui::Accelerator& accelerator) {
231 switch (command_id) { 235 switch (command_id) {
232 case CMD_TOGGLE_OVERVIEW: 236 case CMD_TOGGLE_OVERVIEW:
233 ToggleOverview(); 237 ToggleOverview();
234 break; 238 break;
239 case CMD_TOGGLE_SPLIT_VIEW:
240 split_view_controller_->ToggleSplitView();
241 break;
235 } 242 }
236 return true; 243 return true;
237 } 244 }
238 245
239 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { 246 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) {
240 const aura::Window::Windows& windows = container_->children(); 247 const aura::Window::Windows& windows = container_->children();
241 aura::Window::Windows::const_iterator iter = 248 aura::Window::Windows::const_iterator iter =
242 std::find(windows.begin(), windows.end(), window); 249 std::find(windows.begin(), windows.end(), window);
243 CHECK(iter != windows.end()); 250 CHECK(iter != windows.end());
244 return (iter == windows.begin()) ? NULL : *(iter - 1); 251 return (iter == windows.begin()) ? NULL : *(iter - 1);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 DCHECK(!instance); 316 DCHECK(!instance);
310 } 317 }
311 318
312 // static 319 // static
313 WindowManager* WindowManager::GetInstance() { 320 WindowManager* WindowManager::GetInstance() {
314 DCHECK(instance); 321 DCHECK(instance);
315 return instance; 322 return instance;
316 } 323 }
317 324
318 } // namespace athena 325 } // namespace athena
OLDNEW
« athena/wm/split_view_controller.cc ('K') | « athena/wm/split_view_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698