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

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 mukai's 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 {
39 return overview_;
40 }
41
37 private: 42 private:
38 enum Command { 43 enum Command {
39 COMMAND_TOGGLE_OVERVIEW, 44 COMMAND_TOGGLE_OVERVIEW,
40 }; 45 };
41 46
42 // Sets whether overview mode is active. 47 // Sets whether overview mode is active.
43 void SetInOverview(bool active); 48 void SetInOverview(bool active);
44 49
45 void InstallAccelerators(); 50 void InstallAccelerators();
46 51
47 // WindowManager: 52 // WindowManager:
48 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; 53 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE;
49 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; 54 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE;
50 55
51 // WindowOverviewModeDelegate: 56 // WindowOverviewModeDelegate:
52 virtual void OnSelectWindow(aura::Window* window) OVERRIDE; 57 virtual void OnSelectWindow(aura::Window* window) OVERRIDE;
53 58
54 // aura::WindowObserver 59 // aura::WindowObserver
55 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 60 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
56 61
57 // AcceleratorHandler: 62 // AcceleratorHandler:
58 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; 63 virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
59 virtual bool OnAcceleratorFired(int command_id, 64 virtual bool OnAcceleratorFired(int command_id,
60 const ui::Accelerator& accelerator) OVERRIDE; 65 const ui::Accelerator& accelerator) OVERRIDE;
61 66
62 scoped_ptr<aura::Window> container_; 67 scoped_ptr<aura::Window> container_;
68 scoped_ptr<MruWindowTracker> mru_window_tracker_;
63 scoped_ptr<WindowOverviewMode> overview_; 69 scoped_ptr<WindowOverviewMode> overview_;
64 scoped_ptr<BezelController> bezel_controller_; 70 scoped_ptr<BezelController> bezel_controller_;
65 scoped_ptr<SplitViewController> split_view_controller_; 71 scoped_ptr<SplitViewController> split_view_controller_;
66 ObserverList<WindowManagerObserver> observers_; 72 ObserverList<WindowManagerObserver> observers_;
67 73
68 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 74 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
69 }; 75 };
70 76
71 class AthenaContainerLayoutManager : public aura::LayoutManager { 77 class AthenaContainerLayoutManager : public aura::LayoutManager {
72 public: 78 public:
(...skipping 15 matching lines...) Expand all
88 }; 94 };
89 95
90 class WindowManagerImpl* instance = NULL; 96 class WindowManagerImpl* instance = NULL;
91 97
92 WindowManagerImpl::WindowManagerImpl() { 98 WindowManagerImpl::WindowManagerImpl() {
93 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); 99 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT);
94 params.can_activate_children = true; 100 params.can_activate_children = true;
95 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); 101 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params));
96 container_->SetLayoutManager(new AthenaContainerLayoutManager); 102 container_->SetLayoutManager(new AthenaContainerLayoutManager);
97 container_->AddObserver(this); 103 container_->AddObserver(this);
104 mru_window_tracker_.reset(new MruWindowTracker(container_.get()));
98 bezel_controller_.reset(new BezelController(container_.get())); 105 bezel_controller_.reset(new BezelController(container_.get()));
99 split_view_controller_.reset(new SplitViewController()); 106 split_view_controller_.reset(new SplitViewController(
107 container_.get(), mru_window_tracker_.get(), this));
100 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); 108 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
101 container_->AddPreTargetHandler(bezel_controller_.get()); 109 container_->AddPreTargetHandler(bezel_controller_.get());
102 instance = this; 110 instance = this;
103 InstallAccelerators(); 111 InstallAccelerators();
104 } 112 }
105 113
106 WindowManagerImpl::~WindowManagerImpl() { 114 WindowManagerImpl::~WindowManagerImpl() {
107 overview_.reset(); 115 overview_.reset();
108 if (container_) { 116 if (container_) {
109 container_->RemoveObserver(this); 117 container_->RemoveObserver(this);
(...skipping 21 matching lines...) Expand all
131 void WindowManagerImpl::ToggleOverview() { 139 void WindowManagerImpl::ToggleOverview() {
132 SetInOverview(overview_.get() == NULL); 140 SetInOverview(overview_.get() == NULL);
133 } 141 }
134 142
135 void WindowManagerImpl::SetInOverview(bool active) { 143 void WindowManagerImpl::SetInOverview(bool active) {
136 bool in_overview = !!overview_; 144 bool in_overview = !!overview_;
137 if (active == in_overview) 145 if (active == in_overview)
138 return; 146 return;
139 147
140 if (active) { 148 if (active) {
141 overview_ = WindowOverviewMode::Create(container_.get(), this);
142 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 149 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
143 OnOverviewModeEnter()); 150 OnOverviewModeEnter());
151 // Re-stack all windows in the order defined by mru_window_tracker_.
152 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList();
153 aura::Window::Windows::iterator it;
154 for (it = window_list.begin(); it != window_list.end(); ++it) {
155 container_->StackChildAtTop(*it);
156 }
157 overview_ =
158 WindowOverviewMode::Create(container_.get(),
159 mru_window_tracker_->GetWindowList(),
160 this);
144 } else { 161 } else {
145 overview_.reset(); 162 overview_.reset();
146 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 163 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
147 OnOverviewModeExit()); 164 OnOverviewModeExit());
148 } 165 }
149 } 166 }
150 167
151 void WindowManagerImpl::InstallAccelerators() { 168 void WindowManagerImpl::InstallAccelerators() {
152 const AcceleratorData accelerator_data[] = { 169 const AcceleratorData accelerator_data[] = {
153 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 170 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
154 AF_NONE}, 171 AF_NONE},
155 }; 172 };
156 AcceleratorManager::Get()->RegisterAccelerators( 173 AcceleratorManager::Get()->RegisterAccelerators(
157 accelerator_data, arraysize(accelerator_data), this); 174 accelerator_data, arraysize(accelerator_data), this);
158 } 175 }
159 176
160 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 177 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
161 observers_.AddObserver(observer); 178 observers_.AddObserver(observer);
162 } 179 }
163 180
164 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 181 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
165 observers_.RemoveObserver(observer); 182 observers_.RemoveObserver(observer);
166 } 183 }
167 184
168 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 185 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
169 CHECK_EQ(container_.get(), window->parent()); 186 mru_window_tracker_->MoveToFront(window);
170 container_->StackChildAtTop(window);
171 wm::ActivateWindow(window); 187 wm::ActivateWindow(window);
172 SetInOverview(false); 188 SetInOverview(false);
173 } 189 }
174 190
175 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 191 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
176 if (window == container_) 192 if (window == container_)
177 container_.reset(); 193 container_.reset();
178 } 194 }
179 195
180 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { 196 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DCHECK(!instance); 260 DCHECK(!instance);
245 } 261 }
246 262
247 // static 263 // static
248 WindowManager* WindowManager::GetInstance() { 264 WindowManager* WindowManager::GetInstance() {
249 DCHECK(instance); 265 DCHECK(instance);
250 return instance; 266 return instance;
251 } 267 }
252 268
253 } // namespace athena 269 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698