OLD | NEW |
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/window_manager_impl.h" | 5 #include "athena/wm/window_manager_impl.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/screen/public/screen_manager.h" | 10 #include "athena/screen/public/screen_manager.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 175 } |
176 | 176 |
177 void WindowManagerImpl::SetInOverview(bool active) { | 177 void WindowManagerImpl::SetInOverview(bool active) { |
178 bool in_overview = !!overview_; | 178 bool in_overview = !!overview_; |
179 if (active == in_overview) | 179 if (active == in_overview) |
180 return; | 180 return; |
181 | 181 |
182 bezel_controller_->set_left_right_delegate( | 182 bezel_controller_->set_left_right_delegate( |
183 active ? NULL : split_view_controller_.get()); | 183 active ? NULL : split_view_controller_.get()); |
184 if (active) { | 184 if (active) { |
185 split_view_controller_->DeactivateSplitMode(); | |
186 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); | 185 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); |
187 | 186 |
188 // Re-stack all windows in the order defined by window_list_provider_. | 187 // Re-stack all windows in the order defined by window_list_provider_. |
189 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); | 188 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); |
190 aura::Window::Windows::iterator it; | 189 aura::Window::Windows::iterator it; |
191 for (it = window_list.begin(); it != window_list.end(); ++it) | 190 for (it = window_list.begin(); it != window_list.end(); ++it) |
192 container_->StackChildAtTop(*it); | 191 container_->StackChildAtTop(*it); |
193 overview_ = WindowOverviewMode::Create( | 192 overview_ = WindowOverviewMode::Create( |
194 container_.get(), window_list_provider_.get(), this); | 193 container_.get(), window_list_provider_.get(), |
| 194 split_view_controller_.get(), this); |
195 } else { | 195 } else { |
196 CHECK(!split_view_controller_->IsSplitViewModeActive()); | |
197 overview_.reset(); | 196 overview_.reset(); |
198 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | 197 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
199 } | 198 } |
200 } | 199 } |
201 | 200 |
202 void WindowManagerImpl::InstallAccelerators() { | 201 void WindowManagerImpl::InstallAccelerators() { |
203 const AcceleratorData accelerator_data[] = { | 202 const AcceleratorData accelerator_data[] = { |
204 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 203 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
205 AF_NONE}, | 204 AF_NONE}, |
206 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, | 205 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, |
207 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, | 206 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, |
208 }; | 207 }; |
209 AcceleratorManager::Get()->RegisterAccelerators( | 208 AcceleratorManager::Get()->RegisterAccelerators( |
210 accelerator_data, arraysize(accelerator_data), this); | 209 accelerator_data, arraysize(accelerator_data), this); |
211 } | 210 } |
212 | 211 |
213 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { | 212 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { |
214 observers_.AddObserver(observer); | 213 observers_.AddObserver(observer); |
215 } | 214 } |
216 | 215 |
217 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 216 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
218 observers_.RemoveObserver(observer); | 217 observers_.RemoveObserver(observer); |
219 } | 218 } |
220 | 219 |
221 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 220 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
| 221 if (split_view_controller_->IsSplitViewModeActive()) |
| 222 split_view_controller_->DeactivateSplitMode(); |
222 wm::ActivateWindow(window); | 223 wm::ActivateWindow(window); |
223 SetInOverview(false); | 224 SetInOverview(false); |
| 225 // If |window| does not have the size of the work-area, then make sure it is |
| 226 // resized. |
| 227 const gfx::Size work_area = |
| 228 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| 229 if (window->GetTargetBounds().size() != work_area) { |
| 230 const gfx::Rect& window_bounds = window->bounds(); |
| 231 const gfx::Rect desired_bounds(work_area); |
| 232 gfx::Transform transform; |
| 233 transform.Translate(desired_bounds.x() - window_bounds.x(), |
| 234 desired_bounds.y() - window_bounds.y()); |
| 235 transform.Scale(desired_bounds.width() / window_bounds.width(), |
| 236 desired_bounds.height() / window_bounds.height()); |
| 237 window->layer()->GetAnimator()->AbortAllAnimations(); |
| 238 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 239 settings.SetPreemptionStrategy( |
| 240 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 241 settings.AddObserver( |
| 242 new ui::ClosureAnimationObserver(base::Bind(&SetWindowState, |
| 243 base::Unretained(window), |
| 244 desired_bounds, |
| 245 gfx::Transform()))); |
| 246 window->SetTransform(transform); |
| 247 } |
224 } | 248 } |
225 | 249 |
226 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, | 250 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, |
227 aura::Window* right) { | 251 aura::Window* right) { |
228 SetInOverview(false); | 252 SetInOverview(false); |
229 split_view_controller_->ActivateSplitMode(left, right); | 253 split_view_controller_->ActivateSplitMode(left, right); |
230 } | 254 } |
231 | 255 |
232 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { | 256 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { |
233 // TODO(oshima): Creating a new window should updates the ovewview mode | 257 // TODO(oshima): Creating a new window should updates the ovewview mode |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 base::Unretained(next_window), | 364 base::Unretained(next_window), |
341 window->bounds(), | 365 window->bounds(), |
342 gfx::Transform()))); | 366 gfx::Transform()))); |
343 | 367 |
344 gfx::Transform transform; | 368 gfx::Transform transform; |
345 transform.Scale(window->bounds().width() / next_window->bounds().width(), | 369 transform.Scale(window->bounds().width() / next_window->bounds().width(), |
346 window->bounds().height() / next_window->bounds().height()); | 370 window->bounds().height() / next_window->bounds().height()); |
347 transform.Translate(window->bounds().x() - next_window->bounds().x(), 0); | 371 transform.Translate(window->bounds().x() - next_window->bounds().x(), 0); |
348 next_window->SetTransform(transform); | 372 next_window->SetTransform(transform); |
349 | 373 |
350 OnSelectWindow(next_window); | 374 wm::ActivateWindow(next_window); |
351 } | 375 } |
352 window->Hide(); | 376 window->Hide(); |
353 } | 377 } |
354 | 378 |
355 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) { | 379 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) { |
356 aura::Window* next_window = GetWindowBehind(window); | 380 aura::Window* next_window = GetWindowBehind(window); |
357 if (!next_window) | 381 if (!next_window) |
358 return; | 382 return; |
359 next_window->SetTransform(gfx::Transform()); | 383 next_window->SetTransform(gfx::Transform()); |
360 next_window->Hide(); | 384 next_window->Hide(); |
(...skipping 14 matching lines...) Expand all Loading... |
375 DCHECK(!instance); | 399 DCHECK(!instance); |
376 } | 400 } |
377 | 401 |
378 // static | 402 // static |
379 WindowManager* WindowManager::GetInstance() { | 403 WindowManager* WindowManager::GetInstance() { |
380 DCHECK(instance); | 404 DCHECK(instance); |
381 return instance; | 405 return instance; |
382 } | 406 } |
383 | 407 |
384 } // namespace athena | 408 } // namespace athena |
OLD | NEW |