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

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

Issue 461503002: Split Screen mode implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@coordinate_conversion
Patch Set: Rebase 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 <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"
13 #include "athena/wm/public/window_manager_observer.h" 14 #include "athena/wm/public/window_manager_observer.h"
14 #include "athena/wm/split_view_controller.h" 15 #include "athena/wm/split_view_controller.h"
15 #include "athena/wm/title_drag_controller.h" 16 #include "athena/wm/title_drag_controller.h"
16 #include "athena/wm/window_overview_mode.h" 17 #include "athena/wm/window_overview_mode.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/observer_list.h" 19 #include "base/observer_list.h"
19 #include "ui/aura/layout_manager.h" 20 #include "ui/aura/layout_manager.h"
20 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
21 #include "ui/wm/core/window_util.h" 22 #include "ui/wm/core/window_util.h"
22 #include "ui/wm/core/wm_state.h" 23 #include "ui/wm/core/wm_state.h"
23 #include "ui/wm/public/window_types.h" 24 #include "ui/wm/public/window_types.h"
24 25
25 namespace athena { 26 namespace athena {
26 namespace { 27 namespace {
27 28
28 class WindowManagerImpl : public WindowManager, 29 class WindowManagerImpl : public WindowManager,
29 public WindowOverviewModeDelegate, 30 public WindowOverviewModeDelegate,
30 public aura::WindowObserver, 31 public aura::WindowObserver,
31 public AcceleratorHandler, 32 public AcceleratorHandler,
32 public TitleDragControllerDelegate { 33 public TitleDragControllerDelegate {
33 public: 34 public:
34 WindowManagerImpl(); 35 WindowManagerImpl();
35 virtual ~WindowManagerImpl(); 36 virtual ~WindowManagerImpl();
36 37
37 void Layout(); 38 void Layout();
38 39
39 // WindowManager: 40 // WindowManager:
40 virtual void ToggleOverview() OVERRIDE; 41 virtual void ToggleOverview() OVERRIDE;
41 42
43 virtual bool IsOverviewModeActive() OVERRIDE;
44
42 private: 45 private:
43 enum Command { 46 enum Command {
44 COMMAND_TOGGLE_OVERVIEW, 47 COMMAND_TOGGLE_OVERVIEW,
45 }; 48 };
46 49
47 // Sets whether overview mode is active. 50 // Sets whether overview mode is active.
48 void SetInOverview(bool active); 51 void SetInOverview(bool active);
49 52
50 void InstallAccelerators(); 53 void InstallAccelerators();
51 54
(...skipping 12 matching lines...) Expand all
64 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; 67 virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
65 virtual bool OnAcceleratorFired(int command_id, 68 virtual bool OnAcceleratorFired(int command_id,
66 const ui::Accelerator& accelerator) OVERRIDE; 69 const ui::Accelerator& accelerator) OVERRIDE;
67 70
68 // TitleDragControllerDelegate: 71 // TitleDragControllerDelegate:
69 virtual aura::Window* GetWindowBehind(aura::Window* window) OVERRIDE; 72 virtual aura::Window* GetWindowBehind(aura::Window* window) OVERRIDE;
70 virtual void OnTitleDragStarted(aura::Window* window) OVERRIDE; 73 virtual void OnTitleDragStarted(aura::Window* window) OVERRIDE;
71 virtual void OnTitleDragCompleted(aura::Window* window) OVERRIDE; 74 virtual void OnTitleDragCompleted(aura::Window* window) OVERRIDE;
72 virtual void OnTitleDragCanceled(aura::Window* window) OVERRIDE; 75 virtual void OnTitleDragCanceled(aura::Window* window) OVERRIDE;
73 76
77 // Should be declared first so that it is destoyed last.
78 ObserverList<WindowManagerObserver> observers_;
79
74 scoped_ptr<aura::Window> container_; 80 scoped_ptr<aura::Window> container_;
81 scoped_ptr<MruWindowTracker> mru_window_tracker_;
75 scoped_ptr<WindowOverviewMode> overview_; 82 scoped_ptr<WindowOverviewMode> overview_;
76 scoped_ptr<BezelController> bezel_controller_; 83 scoped_ptr<BezelController> bezel_controller_;
77 scoped_ptr<SplitViewController> split_view_controller_; 84 scoped_ptr<SplitViewController> split_view_controller_;
78 scoped_ptr<wm::WMState> wm_state_; 85 scoped_ptr<wm::WMState> wm_state_;
79 scoped_ptr<TitleDragController> title_drag_controller_; 86 scoped_ptr<TitleDragController> title_drag_controller_;
80 ObserverList<WindowManagerObserver> observers_;
sadrul 2014/08/13 05:17:29 The CL is still breaking the asan builders. This c
mfomitchev 2014/08/13 13:27:31 Ok, I've done that. It seems a bit unfortunate tha
81 87
82 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 88 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
83 }; 89 };
84 90
85 class AthenaContainerLayoutManager : public aura::LayoutManager { 91 class AthenaContainerLayoutManager : public aura::LayoutManager {
86 public: 92 public:
87 AthenaContainerLayoutManager(); 93 AthenaContainerLayoutManager();
88 virtual ~AthenaContainerLayoutManager(); 94 virtual ~AthenaContainerLayoutManager();
89 95
90 private: 96 private:
(...skipping 11 matching lines...) Expand all
102 }; 108 };
103 109
104 class WindowManagerImpl* instance = NULL; 110 class WindowManagerImpl* instance = NULL;
105 111
106 WindowManagerImpl::WindowManagerImpl() { 112 WindowManagerImpl::WindowManagerImpl() {
107 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); 113 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT);
108 params.can_activate_children = true; 114 params.can_activate_children = true;
109 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); 115 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params));
110 container_->SetLayoutManager(new AthenaContainerLayoutManager); 116 container_->SetLayoutManager(new AthenaContainerLayoutManager);
111 container_->AddObserver(this); 117 container_->AddObserver(this);
118 mru_window_tracker_.reset(new MruWindowTracker(container_.get()));
112 bezel_controller_.reset(new BezelController(container_.get())); 119 bezel_controller_.reset(new BezelController(container_.get()));
113 split_view_controller_.reset(new SplitViewController()); 120 split_view_controller_.reset(new SplitViewController(
121 container_.get(), mru_window_tracker_.get(), this));
114 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); 122 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
115 container_->AddPreTargetHandler(bezel_controller_.get()); 123 container_->AddPreTargetHandler(bezel_controller_.get());
116 title_drag_controller_.reset(new TitleDragController(container_.get(), this)); 124 title_drag_controller_.reset(new TitleDragController(container_.get(), this));
117 wm_state_.reset(new wm::WMState()); 125 wm_state_.reset(new wm::WMState());
118 instance = this; 126 instance = this;
119 InstallAccelerators(); 127 InstallAccelerators();
120 } 128 }
121 129
122 WindowManagerImpl::~WindowManagerImpl() { 130 WindowManagerImpl::~WindowManagerImpl() {
123 overview_.reset(); 131 overview_.reset();
(...skipping 17 matching lines...) Expand all
141 ++iter) { 149 ++iter) {
142 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) 150 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL)
143 (*iter)->SetBounds(bounds); 151 (*iter)->SetBounds(bounds);
144 } 152 }
145 } 153 }
146 154
147 void WindowManagerImpl::ToggleOverview() { 155 void WindowManagerImpl::ToggleOverview() {
148 SetInOverview(overview_.get() == NULL); 156 SetInOverview(overview_.get() == NULL);
149 } 157 }
150 158
159 bool WindowManagerImpl::IsOverviewModeActive() {
160 return overview_;
161 }
162
151 void WindowManagerImpl::SetInOverview(bool active) { 163 void WindowManagerImpl::SetInOverview(bool active) {
152 bool in_overview = !!overview_; 164 bool in_overview = !!overview_;
153 if (active == in_overview) 165 if (active == in_overview)
154 return; 166 return;
155 167
156 if (active) { 168 if (active) {
157 overview_ = WindowOverviewMode::Create(container_.get(), this);
158 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 169 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
159 OnOverviewModeEnter()); 170 OnOverviewModeEnter());
171 // Re-stack all windows in the order defined by mru_window_tracker_.
172 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList();
173 aura::Window::Windows::iterator it;
174 for (it = window_list.begin(); it != window_list.end(); ++it)
175 container_->StackChildAtTop(*it);
176 overview_ = WindowOverviewMode::Create(container_.get(),
177 mru_window_tracker_.get(),
178 this);
160 } else { 179 } else {
161 overview_.reset(); 180 overview_.reset();
162 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 181 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
163 OnOverviewModeExit()); 182 OnOverviewModeExit());
164 } 183 }
165 } 184 }
166 185
167 void WindowManagerImpl::InstallAccelerators() { 186 void WindowManagerImpl::InstallAccelerators() {
168 const AcceleratorData accelerator_data[] = { 187 const AcceleratorData accelerator_data[] = {
169 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 188 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
170 AF_NONE}, 189 AF_NONE},
171 }; 190 };
172 AcceleratorManager::Get()->RegisterAccelerators( 191 AcceleratorManager::Get()->RegisterAccelerators(
173 accelerator_data, arraysize(accelerator_data), this); 192 accelerator_data, arraysize(accelerator_data), this);
174 } 193 }
175 194
176 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 195 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
177 observers_.AddObserver(observer); 196 observers_.AddObserver(observer);
178 } 197 }
179 198
180 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 199 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
181 observers_.RemoveObserver(observer); 200 observers_.RemoveObserver(observer);
182 } 201 }
183 202
184 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 203 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
185 CHECK_EQ(container_.get(), window->parent()); 204 mru_window_tracker_->MoveToFront(window);
186 container_->StackChildAtTop(window);
187 wm::ActivateWindow(window); 205 wm::ActivateWindow(window);
188 SetInOverview(false); 206 SetInOverview(false);
189 } 207 }
190 208
191 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { 209 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) {
192 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) 210 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL)
193 SetInOverview(false); 211 SetInOverview(false);
194 } 212 }
195 213
196 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 214 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 DCHECK(!instance); 303 DCHECK(!instance);
286 } 304 }
287 305
288 // static 306 // static
289 WindowManager* WindowManager::GetInstance() { 307 WindowManager* WindowManager::GetInstance() {
290 DCHECK(instance); 308 DCHECK(instance);
291 return instance; 309 return instance;
292 } 310 }
293 311
294 } // namespace athena 312 } // 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