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

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

Issue 470083004: athena: A simpler implementation of WindowListProvider. (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"
11 #include "athena/screen/public/screen_manager.h" 11 #include "athena/screen/public/screen_manager.h"
12 #include "athena/wm/bezel_controller.h" 12 #include "athena/wm/bezel_controller.h"
13 #include "athena/wm/mru_window_tracker.h"
14 #include "athena/wm/public/window_manager_observer.h" 13 #include "athena/wm/public/window_manager_observer.h"
15 #include "athena/wm/split_view_controller.h" 14 #include "athena/wm/split_view_controller.h"
16 #include "athena/wm/title_drag_controller.h" 15 #include "athena/wm/title_drag_controller.h"
16 #include "athena/wm/window_list_provider_impl.h"
17 #include "athena/wm/window_overview_mode.h" 17 #include "athena/wm/window_overview_mode.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "ui/aura/layout_manager.h" 20 #include "ui/aura/layout_manager.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/wm/core/shadow_controller.h" 22 #include "ui/wm/core/shadow_controller.h"
23 #include "ui/wm/core/window_util.h" 23 #include "ui/wm/core/window_util.h"
24 #include "ui/wm/core/wm_state.h" 24 #include "ui/wm/core/wm_state.h"
25 #include "ui/wm/public/activation_client.h" 25 #include "ui/wm/public/activation_client.h"
26 #include "ui/wm/public/window_types.h" 26 #include "ui/wm/public/window_types.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 virtual bool OnAcceleratorFired(int command_id, 72 virtual bool OnAcceleratorFired(int command_id,
73 const ui::Accelerator& accelerator) OVERRIDE; 73 const ui::Accelerator& accelerator) OVERRIDE;
74 74
75 // TitleDragControllerDelegate: 75 // TitleDragControllerDelegate:
76 virtual aura::Window* GetWindowBehind(aura::Window* window) OVERRIDE; 76 virtual aura::Window* GetWindowBehind(aura::Window* window) OVERRIDE;
77 virtual void OnTitleDragStarted(aura::Window* window) OVERRIDE; 77 virtual void OnTitleDragStarted(aura::Window* window) OVERRIDE;
78 virtual void OnTitleDragCompleted(aura::Window* window) OVERRIDE; 78 virtual void OnTitleDragCompleted(aura::Window* window) OVERRIDE;
79 virtual void OnTitleDragCanceled(aura::Window* window) OVERRIDE; 79 virtual void OnTitleDragCanceled(aura::Window* window) OVERRIDE;
80 80
81 scoped_ptr<aura::Window> container_; 81 scoped_ptr<aura::Window> container_;
82 scoped_ptr<MruWindowTracker> mru_window_tracker_; 82 scoped_ptr<WindowListProvider> window_list_provider_;
83 scoped_ptr<WindowOverviewMode> overview_; 83 scoped_ptr<WindowOverviewMode> overview_;
84 scoped_ptr<BezelController> bezel_controller_; 84 scoped_ptr<BezelController> bezel_controller_;
85 scoped_ptr<SplitViewController> split_view_controller_; 85 scoped_ptr<SplitViewController> split_view_controller_;
86 scoped_ptr<wm::WMState> wm_state_; 86 scoped_ptr<wm::WMState> wm_state_;
87 scoped_ptr<TitleDragController> title_drag_controller_; 87 scoped_ptr<TitleDragController> title_drag_controller_;
88 scoped_ptr<wm::ShadowController> shadow_controller_; 88 scoped_ptr<wm::ShadowController> shadow_controller_;
89 ObserverList<WindowManagerObserver> observers_; 89 ObserverList<WindowManagerObserver> observers_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 91 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
92 }; 92 };
(...skipping 18 matching lines...) Expand all
111 }; 111 };
112 112
113 class WindowManagerImpl* instance = NULL; 113 class WindowManagerImpl* instance = NULL;
114 114
115 WindowManagerImpl::WindowManagerImpl() { 115 WindowManagerImpl::WindowManagerImpl() {
116 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); 116 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT);
117 params.can_activate_children = true; 117 params.can_activate_children = true;
118 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); 118 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params));
119 container_->SetLayoutManager(new AthenaContainerLayoutManager); 119 container_->SetLayoutManager(new AthenaContainerLayoutManager);
120 container_->AddObserver(this); 120 container_->AddObserver(this);
121 mru_window_tracker_.reset(new MruWindowTracker(container_.get())); 121 window_list_provider_.reset(new WindowListProviderImpl(container_.get()));
122 bezel_controller_.reset(new BezelController(container_.get())); 122 bezel_controller_.reset(new BezelController(container_.get()));
123 split_view_controller_.reset(new SplitViewController( 123 split_view_controller_.reset(new SplitViewController(
124 container_.get(), mru_window_tracker_.get(), this)); 124 container_.get(), window_list_provider_.get(), this));
125 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); 125 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
126 container_->AddPreTargetHandler(bezel_controller_.get()); 126 container_->AddPreTargetHandler(bezel_controller_.get());
127 title_drag_controller_.reset(new TitleDragController(container_.get(), this)); 127 title_drag_controller_.reset(new TitleDragController(container_.get(), this));
128 wm_state_.reset(new wm::WMState()); 128 wm_state_.reset(new wm::WMState());
129 aura::client::ActivationClient* activation_client = 129 aura::client::ActivationClient* activation_client =
130 aura::client::GetActivationClient(container_->GetRootWindow()); 130 aura::client::GetActivationClient(container_->GetRootWindow());
131 shadow_controller_.reset(new wm::ShadowController(activation_client)); 131 shadow_controller_.reset(new wm::ShadowController(activation_client));
132 instance = this; 132 instance = this;
133 InstallAccelerators(); 133 InstallAccelerators();
134 } 134 }
135 135
136 WindowManagerImpl::~WindowManagerImpl() { 136 WindowManagerImpl::~WindowManagerImpl() {
137 overview_.reset(); 137 overview_.reset();
138 split_view_controller_.reset(); 138 split_view_controller_.reset();
139 mru_window_tracker_.reset(); 139 window_list_provider_.reset();
140 if (container_) { 140 if (container_) {
141 container_->RemoveObserver(this); 141 container_->RemoveObserver(this);
142 container_->RemovePreTargetHandler(bezel_controller_.get()); 142 container_->RemovePreTargetHandler(bezel_controller_.get());
143 } 143 }
144 // |title_drag_controller_| needs to be reset before |container_|. 144 // |title_drag_controller_| needs to be reset before |container_|.
145 title_drag_controller_.reset(); 145 title_drag_controller_.reset();
146 container_.reset(); 146 container_.reset();
147 instance = NULL; 147 instance = NULL;
148 } 148 }
149 149
(...skipping 19 matching lines...) Expand all
169 } 169 }
170 170
171 void WindowManagerImpl::SetInOverview(bool active) { 171 void WindowManagerImpl::SetInOverview(bool active) {
172 bool in_overview = !!overview_; 172 bool in_overview = !!overview_;
173 if (active == in_overview) 173 if (active == in_overview)
174 return; 174 return;
175 175
176 if (active) { 176 if (active) {
177 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 177 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
178 OnOverviewModeEnter()); 178 OnOverviewModeEnter());
179 // Re-stack all windows in the order defined by mru_window_tracker_. 179 // Re-stack all windows in the order defined by window_list_provider_.
180 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList(); 180 aura::Window::Windows window_list = window_list_provider_->GetWindowList();
181 aura::Window::Windows::iterator it; 181 aura::Window::Windows::iterator it;
182 for (it = window_list.begin(); it != window_list.end(); ++it) 182 for (it = window_list.begin(); it != window_list.end(); ++it)
183 container_->StackChildAtTop(*it); 183 container_->StackChildAtTop(*it);
184 overview_ = WindowOverviewMode::Create(container_.get(), 184 overview_ = WindowOverviewMode::Create(container_.get(),
185 mru_window_tracker_.get(), 185 window_list_provider_.get(),
186 this); 186 this);
187 } else { 187 } else {
188 overview_.reset(); 188 overview_.reset();
189 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 189 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
190 OnOverviewModeExit()); 190 OnOverviewModeExit());
191 } 191 }
192 } 192 }
193 193
194 void WindowManagerImpl::InstallAccelerators() { 194 void WindowManagerImpl::InstallAccelerators() {
195 const AcceleratorData accelerator_data[] = { 195 const AcceleratorData accelerator_data[] = {
196 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, 196 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW,
197 AF_NONE}, 197 AF_NONE},
198 }; 198 };
199 AcceleratorManager::Get()->RegisterAccelerators( 199 AcceleratorManager::Get()->RegisterAccelerators(
200 accelerator_data, arraysize(accelerator_data), this); 200 accelerator_data, arraysize(accelerator_data), this);
201 } 201 }
202 202
203 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 203 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
204 observers_.AddObserver(observer); 204 observers_.AddObserver(observer);
205 } 205 }
206 206
207 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 207 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
208 observers_.RemoveObserver(observer); 208 observers_.RemoveObserver(observer);
209 } 209 }
210 210
211 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 211 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
212 mru_window_tracker_->MoveToFront(window); 212 window_list_provider_->MoveToFront(window);
213 wm::ActivateWindow(window); 213 wm::ActivateWindow(window);
214 SetInOverview(false); 214 SetInOverview(false);
215 } 215 }
216 216
217 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, 217 void WindowManagerImpl::OnSplitViewMode(aura::Window* left,
218 aura::Window* right) { 218 aura::Window* right) {
219 SetInOverview(false); 219 SetInOverview(false);
220 split_view_controller_->ActivateSplitMode(left, right); 220 split_view_controller_->ActivateSplitMode(left, right);
221 } 221 }
222 222
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 DCHECK(!instance); 317 DCHECK(!instance);
318 } 318 }
319 319
320 // static 320 // static
321 WindowManager* WindowManager::GetInstance() { 321 WindowManager* WindowManager::GetInstance() {
322 DCHECK(instance); 322 DCHECK(instance);
323 return instance; 323 return instance;
324 } 324 }
325 325
326 } // namespace athena 326 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698