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

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

Issue 420603011: Split Screen mode implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_view
Patch Set: Addressing review feedback. 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
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/common/container_priorities.h" 7 #include "athena/common/container_priorities.h"
8 #include "athena/input/public/accelerator_manager.h" 8 #include "athena/input/public/accelerator_manager.h"
9 #include "athena/screen/public/screen_manager.h" 9 #include "athena/screen/public/screen_manager.h"
10 #include "athena/wm/bezel_controller.h" 10 #include "athena/wm/bezel_controller.h"
11 #include "athena/wm/mru_window_tracker.h"
11 #include "athena/wm/public/window_manager_observer.h" 12 #include "athena/wm/public/window_manager_observer.h"
12 #include "athena/wm/split_view_controller.h" 13 #include "athena/wm/split_view_controller.h"
13 #include "athena/wm/window_overview_mode.h" 14 #include "athena/wm/window_overview_mode.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/observer_list.h" 16 #include "base/observer_list.h"
16 #include "ui/aura/layout_manager.h" 17 #include "ui/aura/layout_manager.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/wm/core/window_util.h" 19 #include "ui/wm/core/window_util.h"
19 #include "ui/wm/public/window_types.h" 20 #include "ui/wm/public/window_types.h"
20 21
21 namespace athena { 22 namespace athena {
22 namespace { 23 namespace {
23 24
24 class WindowManagerImpl : public WindowManager, 25 class WindowManagerImpl : public WindowManager,
25 public WindowOverviewModeDelegate, 26 public WindowOverviewModeDelegate,
26 public aura::WindowObserver, 27 public aura::WindowObserver,
27 public AcceleratorHandler { 28 public AcceleratorHandler {
28 public: 29 public:
29 WindowManagerImpl(); 30 WindowManagerImpl();
30 virtual ~WindowManagerImpl(); 31 virtual ~WindowManagerImpl();
31 32
32 void Layout(); 33 void Layout();
33 34
34 // WindowManager: 35 // WindowManager:
35 virtual void ToggleOverview() OVERRIDE; 36 virtual void ToggleOverview() OVERRIDE;
36 37
38 virtual bool IsOverviewModeActive() OVERRIDE { return overview_; }
oshima 2014/08/08 18:00:40 nit: virtual body should be in .cc
mfomitchev 2014/08/08 18:40:28 Done.
39
37 private: 40 private:
38 enum Command { 41 enum Command {
39 COMMAND_TOGGLE_OVERVIEW, 42 COMMAND_TOGGLE_OVERVIEW,
40 }; 43 };
41 44
42 // Sets whether overview mode is active. 45 // Sets whether overview mode is active.
43 void SetInOverview(bool active); 46 void SetInOverview(bool active);
44 47
45 void InstallAccelerators(); 48 void InstallAccelerators();
46 49
47 // WindowManager: 50 // WindowManager:
48 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; 51 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE;
49 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; 52 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE;
50 53
51 // WindowOverviewModeDelegate: 54 // WindowOverviewModeDelegate:
52 virtual void OnSelectWindow(aura::Window* window) OVERRIDE; 55 virtual void OnSelectWindow(aura::Window* window) OVERRIDE;
53 56
54 // aura::WindowObserver 57 // aura::WindowObserver
55 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; 58 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;
56 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 59 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
57 60
58 // AcceleratorHandler: 61 // AcceleratorHandler:
59 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; 62 virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
60 virtual bool OnAcceleratorFired(int command_id, 63 virtual bool OnAcceleratorFired(int command_id,
61 const ui::Accelerator& accelerator) OVERRIDE; 64 const ui::Accelerator& accelerator) OVERRIDE;
62 65
63 scoped_ptr<aura::Window> container_; 66 scoped_ptr<aura::Window> container_;
67 scoped_ptr<MruWindowTracker> mru_window_tracker_;
64 scoped_ptr<WindowOverviewMode> overview_; 68 scoped_ptr<WindowOverviewMode> overview_;
65 scoped_ptr<BezelController> bezel_controller_; 69 scoped_ptr<BezelController> bezel_controller_;
66 scoped_ptr<SplitViewController> split_view_controller_; 70 scoped_ptr<SplitViewController> split_view_controller_;
67 ObserverList<WindowManagerObserver> observers_; 71 ObserverList<WindowManagerObserver> observers_;
68 72
69 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 73 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
70 }; 74 };
71 75
72 class AthenaContainerLayoutManager : public aura::LayoutManager { 76 class AthenaContainerLayoutManager : public aura::LayoutManager {
73 public: 77 public:
(...skipping 15 matching lines...) Expand all
89 }; 93 };
90 94
91 class WindowManagerImpl* instance = NULL; 95 class WindowManagerImpl* instance = NULL;
92 96
93 WindowManagerImpl::WindowManagerImpl() { 97 WindowManagerImpl::WindowManagerImpl() {
94 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); 98 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT);
95 params.can_activate_children = true; 99 params.can_activate_children = true;
96 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); 100 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params));
97 container_->SetLayoutManager(new AthenaContainerLayoutManager); 101 container_->SetLayoutManager(new AthenaContainerLayoutManager);
98 container_->AddObserver(this); 102 container_->AddObserver(this);
103 mru_window_tracker_.reset(new MruWindowTracker(container_.get()));
99 bezel_controller_.reset(new BezelController(container_.get())); 104 bezel_controller_.reset(new BezelController(container_.get()));
100 split_view_controller_.reset(new SplitViewController()); 105 split_view_controller_.reset(new SplitViewController(
106 container_.get(), mru_window_tracker_.get(), this));
101 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); 107 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
102 container_->AddPreTargetHandler(bezel_controller_.get()); 108 container_->AddPreTargetHandler(bezel_controller_.get());
103 instance = this; 109 instance = this;
104 InstallAccelerators(); 110 InstallAccelerators();
105 } 111 }
106 112
107 WindowManagerImpl::~WindowManagerImpl() { 113 WindowManagerImpl::~WindowManagerImpl() {
108 overview_.reset(); 114 overview_.reset();
109 if (container_) { 115 if (container_) {
110 container_->RemoveObserver(this); 116 container_->RemoveObserver(this);
(...skipping 19 matching lines...) Expand all
130 void WindowManagerImpl::ToggleOverview() { 136 void WindowManagerImpl::ToggleOverview() {
131 SetInOverview(overview_.get() == NULL); 137 SetInOverview(overview_.get() == NULL);
132 } 138 }
133 139
134 void WindowManagerImpl::SetInOverview(bool active) { 140 void WindowManagerImpl::SetInOverview(bool active) {
135 bool in_overview = !!overview_; 141 bool in_overview = !!overview_;
136 if (active == in_overview) 142 if (active == in_overview)
137 return; 143 return;
138 144
139 if (active) { 145 if (active) {
140 overview_ = WindowOverviewMode::Create(container_.get(), this);
141 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 146 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
142 OnOverviewModeEnter()); 147 OnOverviewModeEnter());
148 // Re-stack all windows in the order defined by mru_window_tracker_.
149 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList();
150 aura::Window::Windows::iterator it;
151 for (it = window_list.begin(); it != window_list.end(); ++it) {
152 container_->StackChildAtTop(*it);
153 }
oshima 2014/08/08 18:00:40 nit: nuke {}
mfomitchev 2014/08/08 18:40:28 Done.
154 overview_ = WindowOverviewMode::Create(container_.get(),
155 mru_window_tracker_.get(),
156 this);
143 } else { 157 } else {
144 overview_.reset(); 158 overview_.reset();
145 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 159 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
146 OnOverviewModeExit()); 160 OnOverviewModeExit());
147 } 161 }
148 } 162 }
149 163
150 void WindowManagerImpl::InstallAccelerators() { 164 void WindowManagerImpl::InstallAccelerators() {
151 const AcceleratorData accelerator_data[] = { 165 const AcceleratorData accelerator_data[] = {
152 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 166 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
153 AF_NONE}, 167 AF_NONE},
154 }; 168 };
155 AcceleratorManager::Get()->RegisterAccelerators( 169 AcceleratorManager::Get()->RegisterAccelerators(
156 accelerator_data, arraysize(accelerator_data), this); 170 accelerator_data, arraysize(accelerator_data), this);
157 } 171 }
158 172
159 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 173 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
160 observers_.AddObserver(observer); 174 observers_.AddObserver(observer);
161 } 175 }
162 176
163 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 177 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
164 observers_.RemoveObserver(observer); 178 observers_.RemoveObserver(observer);
165 } 179 }
166 180
167 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 181 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
168 CHECK_EQ(container_.get(), window->parent()); 182 mru_window_tracker_->MoveToFront(window);
169 container_->StackChildAtTop(window);
170 wm::ActivateWindow(window); 183 wm::ActivateWindow(window);
171 SetInOverview(false); 184 SetInOverview(false);
172 } 185 }
173 186
174 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { 187 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) {
175 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) 188 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL)
176 SetInOverview(false); 189 SetInOverview(false);
177 } 190 }
178 191
179 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 192 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DCHECK(!instance); 261 DCHECK(!instance);
249 } 262 }
250 263
251 // static 264 // static
252 WindowManager* WindowManager::GetInstance() { 265 WindowManager* WindowManager::GetInstance() {
253 DCHECK(instance); 266 DCHECK(instance);
254 return instance; 267 return instance;
255 } 268 }
256 269
257 } // namespace athena 270 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698