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

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: Changes as requested by sadrul@ 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 container_->RemoveObserver(this); 108 container_->RemoveObserver(this);
106 container_->RemovePreTargetHandler(bezel_controller_.get()); 109 container_->RemovePreTargetHandler(bezel_controller_.get());
107 } 110 }
108 container_.reset(); 111 container_.reset();
109 instance = NULL; 112 instance = NULL;
110 } 113 }
111 114
112 void WindowManagerImpl::Layout() { 115 void WindowManagerImpl::Layout() {
113 if (!container_) 116 if (!container_)
114 return; 117 return;
118 SetInOverview(false);
115 gfx::Rect bounds = gfx::Rect(container_->bounds().size()); 119 gfx::Rect bounds = gfx::Rect(container_->bounds().size());
116 const aura::Window::Windows& children = container_->children(); 120 const aura::Window::Windows& children = container_->children();
117 for (aura::Window::Windows::const_iterator iter = children.begin(); 121 for (aura::Window::Windows::const_iterator iter = children.begin();
118 iter != children.end(); 122 iter != children.end();
119 ++iter) { 123 ++iter) {
120 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL || 124 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL ||
121 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP) 125 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP)
122 (*iter)->SetBounds(bounds); 126 (*iter)->SetBounds(bounds);
123 } 127 }
124 } 128 }
125 129
126 void WindowManagerImpl::ToggleOverview() { 130 void WindowManagerImpl::ToggleOverview() {
127 if (overview_) { 131 SetInOverview(overview_.get() == NULL);
132 }
133
134 void WindowManagerImpl::SetInOverview(bool active) {
135 bool in_overview = !!overview_;
136 if (active == in_overview)
137 return;
138
139 if (active) {
140 overview_ = WindowOverviewMode::Create(container_.get(), this);
141 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
142 OnOverviewModeEnter());
143 } else {
128 overview_.reset(); 144 overview_.reset();
129 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 145 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
130 OnOverviewModeExit()); 146 OnOverviewModeExit());
131 } else {
132 overview_ = WindowOverviewMode::Create(container_.get(), this);
133 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
134 OnOverviewModeEnter());
135 } 147 }
136 } 148 }
137 149
138 void WindowManagerImpl::InstallAccelerators() { 150 void WindowManagerImpl::InstallAccelerators() {
139 const AcceleratorData accelerator_data[] = { 151 const AcceleratorData accelerator_data[] = {
140 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 152 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
141 AF_NONE}, 153 AF_NONE},
142 }; 154 };
143 AcceleratorManager::Get()->RegisterAccelerators( 155 AcceleratorManager::Get()->RegisterAccelerators(
144 accelerator_data, arraysize(accelerator_data), this); 156 accelerator_data, arraysize(accelerator_data), this);
145 } 157 }
146 158
147 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 159 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
148 observers_.AddObserver(observer); 160 observers_.AddObserver(observer);
149 } 161 }
150 162
151 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 163 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
152 observers_.RemoveObserver(observer); 164 observers_.RemoveObserver(observer);
153 } 165 }
154 166
155 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 167 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
156 CHECK_EQ(container_.get(), window->parent()); 168 CHECK_EQ(container_.get(), window->parent());
157 container_->StackChildAtTop(window); 169 container_->StackChildAtTop(window);
158 wm::ActivateWindow(window); 170 wm::ActivateWindow(window);
159 overview_.reset(); 171 SetInOverview(false);
160 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
161 OnOverviewModeExit());
162 } 172 }
163 173
164 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 174 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
165 if (window == container_) 175 if (window == container_)
166 container_.reset(); 176 container_.reset();
167 } 177 }
168 178
169 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { 179 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
170 return true; 180 return true;
171 } 181 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 DCHECK(!instance); 243 DCHECK(!instance);
234 } 244 }
235 245
236 // static 246 // static
237 WindowManager* WindowManager::GetInstance() { 247 WindowManager* WindowManager::GetInstance() {
238 DCHECK(instance); 248 DCHECK(instance);
239 return instance; 249 return instance;
240 } 250 }
241 251
242 } // namespace athena 252 } // namespace athena
OLDNEW
« athena/home/home_card_unittest.cc ('K') | « athena/home/home_card_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698