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

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

Issue 411813002: Exit overview mode when a new activity is opened in athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « athena/home/home_card_unittest.cc ('k') | no next file » | 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"
(...skipping 21 matching lines...) Expand all
32 void Layout(); 32 void Layout();
33 33
34 // WindowManager: 34 // WindowManager:
35 virtual void ToggleOverview() OVERRIDE; 35 virtual void ToggleOverview() OVERRIDE;
36 36
37 private: 37 private:
38 enum Command { 38 enum Command {
39 COMMAND_TOGGLE_OVERVIEW, 39 COMMAND_TOGGLE_OVERVIEW,
40 }; 40 };
41 41
42 // Sets whether overview mode is active.
43 void SetInOverview(bool active);
44
42 void InstallAccelerators(); 45 void InstallAccelerators();
43 46
44 // WindowManager: 47 // WindowManager:
45 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; 48 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE;
46 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; 49 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE;
47 50
48 // WindowOverviewModeDelegate: 51 // WindowOverviewModeDelegate:
49 virtual void OnSelectWindow(aura::Window* window) OVERRIDE; 52 virtual void OnSelectWindow(aura::Window* window) OVERRIDE;
50 53
51 // aura::WindowObserver 54 // aura::WindowObserver
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 container_->AddObserver(this); 97 container_->AddObserver(this);
95 bezel_controller_.reset(new BezelController(container_.get())); 98 bezel_controller_.reset(new BezelController(container_.get()));
96 split_view_controller_.reset(new SplitViewController()); 99 split_view_controller_.reset(new SplitViewController());
97 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); 100 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
98 container_->AddPreTargetHandler(bezel_controller_.get()); 101 container_->AddPreTargetHandler(bezel_controller_.get());
99 instance = this; 102 instance = this;
100 InstallAccelerators(); 103 InstallAccelerators();
101 } 104 }
102 105
103 WindowManagerImpl::~WindowManagerImpl() { 106 WindowManagerImpl::~WindowManagerImpl() {
107 overview_.reset();
104 if (container_) { 108 if (container_) {
105 container_->RemoveObserver(this); 109 container_->RemoveObserver(this);
106 container_->RemovePreTargetHandler(bezel_controller_.get()); 110 container_->RemovePreTargetHandler(bezel_controller_.get());
107 } 111 }
108 container_.reset(); 112 container_.reset();
109 instance = NULL; 113 instance = NULL;
110 } 114 }
111 115
112 void WindowManagerImpl::Layout() { 116 void WindowManagerImpl::Layout() {
113 if (!container_) 117 if (!container_)
114 return; 118 return;
119 SetInOverview(false);
115 gfx::Rect bounds = gfx::Rect(container_->bounds().size()); 120 gfx::Rect bounds = gfx::Rect(container_->bounds().size());
116 const aura::Window::Windows& children = container_->children(); 121 const aura::Window::Windows& children = container_->children();
117 for (aura::Window::Windows::const_iterator iter = children.begin(); 122 for (aura::Window::Windows::const_iterator iter = children.begin();
118 iter != children.end(); 123 iter != children.end();
119 ++iter) { 124 ++iter) {
120 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL || 125 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL ||
121 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP) 126 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP)
122 (*iter)->SetBounds(bounds); 127 (*iter)->SetBounds(bounds);
123 } 128 }
124 } 129 }
125 130
126 void WindowManagerImpl::ToggleOverview() { 131 void WindowManagerImpl::ToggleOverview() {
127 if (overview_) { 132 SetInOverview(overview_.get() == NULL);
133 }
134
135 void WindowManagerImpl::SetInOverview(bool active) {
136 bool in_overview = !!overview_;
137 if (active == in_overview)
138 return;
139
140 if (active) {
141 overview_ = WindowOverviewMode::Create(container_.get(), this);
142 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
143 OnOverviewModeEnter());
144 } else {
128 overview_.reset(); 145 overview_.reset();
129 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 146 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
130 OnOverviewModeExit()); 147 OnOverviewModeExit());
131 } else {
132 overview_ = WindowOverviewMode::Create(container_.get(), this);
133 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
134 OnOverviewModeEnter());
135 } 148 }
136 } 149 }
137 150
138 void WindowManagerImpl::InstallAccelerators() { 151 void WindowManagerImpl::InstallAccelerators() {
139 const AcceleratorData accelerator_data[] = { 152 const AcceleratorData accelerator_data[] = {
140 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 153 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
141 AF_NONE}, 154 AF_NONE},
142 }; 155 };
143 AcceleratorManager::Get()->RegisterAccelerators( 156 AcceleratorManager::Get()->RegisterAccelerators(
144 accelerator_data, arraysize(accelerator_data), this); 157 accelerator_data, arraysize(accelerator_data), this);
145 } 158 }
146 159
147 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 160 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
148 observers_.AddObserver(observer); 161 observers_.AddObserver(observer);
149 } 162 }
150 163
151 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 164 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
152 observers_.RemoveObserver(observer); 165 observers_.RemoveObserver(observer);
153 } 166 }
154 167
155 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 168 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
156 CHECK_EQ(container_.get(), window->parent()); 169 CHECK_EQ(container_.get(), window->parent());
157 container_->StackChildAtTop(window); 170 container_->StackChildAtTop(window);
158 wm::ActivateWindow(window); 171 wm::ActivateWindow(window);
159 overview_.reset(); 172 SetInOverview(false);
160 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
161 OnOverviewModeExit());
162 } 173 }
163 174
164 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 175 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
165 if (window == container_) 176 if (window == container_)
166 container_.reset(); 177 container_.reset();
167 } 178 }
168 179
169 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { 180 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
170 return true; 181 return true;
171 } 182 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 DCHECK(!instance); 244 DCHECK(!instance);
234 } 245 }
235 246
236 // static 247 // static
237 WindowManager* WindowManager::GetInstance() { 248 WindowManager* WindowManager::GetInstance() {
238 DCHECK(instance); 249 DCHECK(instance);
239 return instance; 250 return instance;
240 } 251 }
241 252
242 } // namespace athena 253 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/home_card_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698