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

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

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

Powered by Google App Engine
This is Rietveld 408576698