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

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: Fixing a rebase glitch 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/core/wm_state.h" 20 #include "ui/wm/core/wm_state.h"
20 #include "ui/wm/public/window_types.h" 21 #include "ui/wm/public/window_types.h"
21 22
22 namespace athena { 23 namespace athena {
23 namespace { 24 namespace {
24 25
25 class WindowManagerImpl : public WindowManager, 26 class WindowManagerImpl : public WindowManager,
26 public WindowOverviewModeDelegate, 27 public WindowOverviewModeDelegate,
27 public aura::WindowObserver, 28 public aura::WindowObserver,
28 public AcceleratorHandler { 29 public AcceleratorHandler {
29 public: 30 public:
30 WindowManagerImpl(); 31 WindowManagerImpl();
31 virtual ~WindowManagerImpl(); 32 virtual ~WindowManagerImpl();
32 33
33 void Layout(); 34 void Layout();
34 35
35 // WindowManager: 36 // WindowManager:
36 virtual void ToggleOverview() OVERRIDE; 37 virtual void ToggleOverview() OVERRIDE;
37 38
39 virtual bool IsOverviewModeActive() OVERRIDE;
40
38 private: 41 private:
39 enum Command { 42 enum Command {
40 COMMAND_TOGGLE_OVERVIEW, 43 COMMAND_TOGGLE_OVERVIEW,
41 }; 44 };
42 45
43 // Sets whether overview mode is active. 46 // Sets whether overview mode is active.
44 void SetInOverview(bool active); 47 void SetInOverview(bool active);
45 48
46 void InstallAccelerators(); 49 void InstallAccelerators();
47 50
48 // WindowManager: 51 // WindowManager:
49 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; 52 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE;
50 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; 53 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE;
51 54
52 // WindowOverviewModeDelegate: 55 // WindowOverviewModeDelegate:
53 virtual void OnSelectWindow(aura::Window* window) OVERRIDE; 56 virtual void OnSelectWindow(aura::Window* window) OVERRIDE;
54 57
55 // aura::WindowObserver 58 // aura::WindowObserver
56 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; 59 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;
57 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 60 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
58 61
59 // AcceleratorHandler: 62 // AcceleratorHandler:
60 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; 63 virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
61 virtual bool OnAcceleratorFired(int command_id, 64 virtual bool OnAcceleratorFired(int command_id,
62 const ui::Accelerator& accelerator) OVERRIDE; 65 const ui::Accelerator& accelerator) OVERRIDE;
63 66
64 scoped_ptr<aura::Window> container_; 67 scoped_ptr<aura::Window> container_;
68 scoped_ptr<MruWindowTracker> mru_window_tracker_;
65 scoped_ptr<WindowOverviewMode> overview_; 69 scoped_ptr<WindowOverviewMode> overview_;
66 scoped_ptr<BezelController> bezel_controller_; 70 scoped_ptr<BezelController> bezel_controller_;
67 scoped_ptr<SplitViewController> split_view_controller_; 71 scoped_ptr<SplitViewController> split_view_controller_;
68 scoped_ptr<wm::WMState> wm_state_; 72 scoped_ptr<wm::WMState> wm_state_;
69 ObserverList<WindowManagerObserver> observers_; 73 ObserverList<WindowManagerObserver> observers_;
70 74
71 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 75 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
72 }; 76 };
73 77
74 class AthenaContainerLayoutManager : public aura::LayoutManager { 78 class AthenaContainerLayoutManager : public aura::LayoutManager {
(...skipping 16 matching lines...) Expand all
91 }; 95 };
92 96
93 class WindowManagerImpl* instance = NULL; 97 class WindowManagerImpl* instance = NULL;
94 98
95 WindowManagerImpl::WindowManagerImpl() { 99 WindowManagerImpl::WindowManagerImpl() {
96 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); 100 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT);
97 params.can_activate_children = true; 101 params.can_activate_children = true;
98 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); 102 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params));
99 container_->SetLayoutManager(new AthenaContainerLayoutManager); 103 container_->SetLayoutManager(new AthenaContainerLayoutManager);
100 container_->AddObserver(this); 104 container_->AddObserver(this);
105 mru_window_tracker_.reset(new MruWindowTracker(container_.get()));
101 bezel_controller_.reset(new BezelController(container_.get())); 106 bezel_controller_.reset(new BezelController(container_.get()));
102 split_view_controller_.reset(new SplitViewController()); 107 split_view_controller_.reset(new SplitViewController(
108 container_.get(), mru_window_tracker_.get(), this));
103 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); 109 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
104 container_->AddPreTargetHandler(bezel_controller_.get()); 110 container_->AddPreTargetHandler(bezel_controller_.get());
105 wm_state_.reset(new wm::WMState()); 111 wm_state_.reset(new wm::WMState());
106 instance = this; 112 instance = this;
107 InstallAccelerators(); 113 InstallAccelerators();
108 } 114 }
109 115
110 WindowManagerImpl::~WindowManagerImpl() { 116 WindowManagerImpl::~WindowManagerImpl() {
111 overview_.reset(); 117 overview_.reset();
112 if (container_) { 118 if (container_) {
(...skipping 14 matching lines...) Expand all
127 ++iter) { 133 ++iter) {
128 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) 134 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL)
129 (*iter)->SetBounds(bounds); 135 (*iter)->SetBounds(bounds);
130 } 136 }
131 } 137 }
132 138
133 void WindowManagerImpl::ToggleOverview() { 139 void WindowManagerImpl::ToggleOverview() {
134 SetInOverview(overview_.get() == NULL); 140 SetInOverview(overview_.get() == NULL);
135 } 141 }
136 142
143 bool WindowManagerImpl::IsOverviewModeActive() {
144 return overview_;
145 }
146
137 void WindowManagerImpl::SetInOverview(bool active) { 147 void WindowManagerImpl::SetInOverview(bool active) {
138 bool in_overview = !!overview_; 148 bool in_overview = !!overview_;
139 if (active == in_overview) 149 if (active == in_overview)
140 return; 150 return;
141 151
142 if (active) { 152 if (active) {
143 overview_ = WindowOverviewMode::Create(container_.get(), this);
144 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 153 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
145 OnOverviewModeEnter()); 154 OnOverviewModeEnter());
sadrul 2014/08/09 13:32:40 Can you clarify the doc for this that this is call
mfomitchev 2014/08/09 18:29:56 Done.
155 // Re-stack all windows in the order defined by mru_window_tracker_.
156 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList();
157 aura::Window::Windows::iterator it;
158 for (it = window_list.begin(); it != window_list.end(); ++it)
159 container_->StackChildAtTop(*it);
160 overview_ = WindowOverviewMode::Create(container_.get(),
161 mru_window_tracker_.get(),
162 this);
146 } else { 163 } else {
147 overview_.reset(); 164 overview_.reset();
148 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 165 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
149 OnOverviewModeExit()); 166 OnOverviewModeExit());
150 } 167 }
151 } 168 }
152 169
153 void WindowManagerImpl::InstallAccelerators() { 170 void WindowManagerImpl::InstallAccelerators() {
154 const AcceleratorData accelerator_data[] = { 171 const AcceleratorData accelerator_data[] = {
155 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 172 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
156 AF_NONE}, 173 AF_NONE},
157 }; 174 };
158 AcceleratorManager::Get()->RegisterAccelerators( 175 AcceleratorManager::Get()->RegisterAccelerators(
159 accelerator_data, arraysize(accelerator_data), this); 176 accelerator_data, arraysize(accelerator_data), this);
160 } 177 }
161 178
162 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 179 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
163 observers_.AddObserver(observer); 180 observers_.AddObserver(observer);
164 } 181 }
165 182
166 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 183 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
167 observers_.RemoveObserver(observer); 184 observers_.RemoveObserver(observer);
168 } 185 }
169 186
170 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 187 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
171 CHECK_EQ(container_.get(), window->parent()); 188 mru_window_tracker_->MoveToFront(window);
172 container_->StackChildAtTop(window);
173 wm::ActivateWindow(window); 189 wm::ActivateWindow(window);
174 SetInOverview(false); 190 SetInOverview(false);
175 } 191 }
176 192
177 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { 193 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) {
178 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) 194 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL)
179 SetInOverview(false); 195 SetInOverview(false);
180 } 196 }
181 197
182 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 198 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 DCHECK(!instance); 267 DCHECK(!instance);
252 } 268 }
253 269
254 // static 270 // static
255 WindowManager* WindowManager::GetInstance() { 271 WindowManager* WindowManager::GetInstance() {
256 DCHECK(instance); 272 DCHECK(instance);
257 return instance; 273 return instance;
258 } 274 }
259 275
260 } // namespace athena 276 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698