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/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
10 #include "athena/util/container_priorities.h" | 10 #include "athena/util/container_priorities.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (container_) { | 169 if (container_) { |
170 container_->RemoveObserver(this); | 170 container_->RemoveObserver(this); |
171 container_->RemovePreTargetHandler(bezel_controller_.get()); | 171 container_->RemovePreTargetHandler(bezel_controller_.get()); |
172 } | 172 } |
173 // |title_drag_controller_| needs to be reset before |container_|. | 173 // |title_drag_controller_| needs to be reset before |container_|. |
174 title_drag_controller_.reset(); | 174 title_drag_controller_.reset(); |
175 container_.reset(); | 175 container_.reset(); |
176 instance = NULL; | 176 instance = NULL; |
177 } | 177 } |
178 | 178 |
| 179 void WindowManagerImpl::ToggleSplitView() { |
| 180 if (IsOverviewModeActive()) |
| 181 return; |
| 182 |
| 183 if (split_view_controller_->IsSplitViewModeActive()) { |
| 184 split_view_controller_->DeactivateSplitMode(); |
| 185 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
| 186 // Relayout so that windows are maximzied. |
| 187 container_->layout_manager()->OnWindowResized(); |
| 188 } else if (split_view_controller_->CanActivateSplitViewMode()) { |
| 189 FOR_EACH_OBSERVER(WindowManagerObserver, |
| 190 observers_, |
| 191 OnSplitViewModeEnter()); |
| 192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL); |
| 193 } |
| 194 } |
| 195 |
179 void WindowManagerImpl::ToggleOverview() { | 196 void WindowManagerImpl::ToggleOverview() { |
180 if (IsOverviewModeActive()) { | 197 if (IsOverviewModeActive()) { |
181 SetInOverview(false); | 198 SetInOverview(false); |
182 | 199 |
183 // Activate the window which was active prior to entering overview. | 200 // Activate the window which was active prior to entering overview. |
184 const aura::Window::Windows windows = | 201 const aura::Window::Windows windows = |
185 window_list_provider_->GetWindowList(); | 202 window_list_provider_->GetWindowList(); |
186 if (!windows.empty()) { | 203 if (!windows.empty()) { |
187 aura::Window* window = windows.back(); | 204 aura::Window* window = windows.back(); |
188 // Show the window in case the exit overview animation has finished and | 205 // Show the window in case the exit overview animation has finished and |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 251 |
235 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { | 252 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { |
236 observers_.AddObserver(observer); | 253 observers_.AddObserver(observer); |
237 } | 254 } |
238 | 255 |
239 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 256 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
240 observers_.RemoveObserver(observer); | 257 observers_.RemoveObserver(observer); |
241 } | 258 } |
242 | 259 |
243 void WindowManagerImpl::ToggleSplitViewForTest() { | 260 void WindowManagerImpl::ToggleSplitViewForTest() { |
244 ToggleSplitview(); | 261 ToggleSplitView(); |
245 } | 262 } |
246 | 263 |
247 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { | 264 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { |
248 return window_list_provider_.get(); | 265 return window_list_provider_.get(); |
249 } | 266 } |
250 | 267 |
251 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 268 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
252 SetInOverview(false); | 269 SetInOverview(false); |
253 | 270 |
254 // Show the window in case the exit overview animation has finished and | 271 // Show the window in case the exit overview animation has finished and |
(...skipping 28 matching lines...) Expand all Loading... |
283 gfx::Transform()))); | 300 gfx::Transform()))); |
284 window->SetTransform(transform); | 301 window->SetTransform(transform); |
285 } | 302 } |
286 } | 303 } |
287 | 304 |
288 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left, | 305 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left, |
289 aura::Window* right, | 306 aura::Window* right, |
290 aura::Window* to_activate) { | 307 aura::Window* to_activate) { |
291 SetInOverview(false); | 308 SetInOverview(false); |
292 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); | 309 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); |
293 split_view_controller_->ActivateSplitMode(left, right); | 310 split_view_controller_->ActivateSplitMode(left, right, to_activate); |
294 wm::ActivateWindow(to_activate); | |
295 } | 311 } |
296 | 312 |
297 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { | 313 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { |
298 if (window == container_) | 314 if (window == container_) |
299 container_.reset(); | 315 container_.reset(); |
300 } | 316 } |
301 | 317 |
302 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 318 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
303 return true; | 319 return true; |
304 } | 320 } |
305 | 321 |
306 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 322 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
307 const ui::Accelerator& accelerator) { | 323 const ui::Accelerator& accelerator) { |
308 switch (command_id) { | 324 switch (command_id) { |
309 case CMD_TOGGLE_OVERVIEW: | 325 case CMD_TOGGLE_OVERVIEW: |
310 ToggleOverview(); | 326 ToggleOverview(); |
311 break; | 327 break; |
312 case CMD_TOGGLE_SPLIT_VIEW: | 328 case CMD_TOGGLE_SPLIT_VIEW: |
313 ToggleSplitview(); | 329 ToggleSplitView(); |
314 break; | 330 break; |
315 } | 331 } |
316 return true; | 332 return true; |
317 } | 333 } |
318 | 334 |
319 void WindowManagerImpl::ToggleSplitview() { | |
320 if (IsOverviewModeActive()) | |
321 return; | |
322 | |
323 if (split_view_controller_->IsSplitViewModeActive()) { | |
324 split_view_controller_->DeactivateSplitMode(); | |
325 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | |
326 // Relayout so that windows are maximzied. | |
327 container_->layout_manager()->OnWindowResized(); | |
328 } else if (split_view_controller_->CanActivateSplitViewMode()) { | |
329 FOR_EACH_OBSERVER(WindowManagerObserver, | |
330 observers_, | |
331 OnSplitViewModeEnter()); | |
332 split_view_controller_->ActivateSplitMode(NULL, NULL); | |
333 } | |
334 } | |
335 | |
336 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 335 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
337 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); | 336 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); |
338 aura::Window::Windows::const_reverse_iterator iter = | 337 aura::Window::Windows::const_reverse_iterator iter = |
339 std::find(windows.rbegin(), windows.rend(), window); | 338 std::find(windows.rbegin(), windows.rend(), window); |
340 CHECK(iter != windows.rend()); | 339 CHECK(iter != windows.rend()); |
341 ++iter; | 340 ++iter; |
342 aura::Window* behind = NULL; | 341 aura::Window* behind = NULL; |
343 if (iter != windows.rend()) | 342 if (iter != windows.rend()) |
344 behind = *iter++; | 343 behind = *iter++; |
345 | 344 |
(...skipping 30 matching lines...) Expand all Loading... |
376 next_window->SetTransform(transform); | 375 next_window->SetTransform(transform); |
377 } | 376 } |
378 } | 377 } |
379 | 378 |
380 void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) { | 379 void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) { |
381 aura::Window* next_window = GetWindowBehind(window); | 380 aura::Window* next_window = GetWindowBehind(window); |
382 if (!next_window) | 381 if (!next_window) |
383 return; | 382 return; |
384 if (split_view_controller_->IsSplitViewModeActive()) { | 383 if (split_view_controller_->IsSplitViewModeActive()) { |
385 split_view_controller_->ReplaceWindow(window, next_window); | 384 split_view_controller_->ReplaceWindow(window, next_window); |
386 wm::ActivateWindow(next_window); | |
387 } else { | 385 } else { |
388 ui::ScopedLayerAnimationSettings | 386 ui::ScopedLayerAnimationSettings |
389 settings(next_window->layer()->GetAnimator()); | 387 settings(next_window->layer()->GetAnimator()); |
390 settings.AddObserver(new ui::ClosureAnimationObserver( | 388 settings.AddObserver(new ui::ClosureAnimationObserver( |
391 base::Bind(&SetWindowState, | 389 base::Bind(&SetWindowState, |
392 base::Unretained(next_window), | 390 base::Unretained(next_window), |
393 window->bounds(), | 391 window->bounds(), |
394 gfx::Transform()))); | 392 gfx::Transform()))); |
395 | 393 |
396 gfx::Transform transform; | 394 gfx::Transform transform; |
(...skipping 30 matching lines...) Expand all Loading... |
427 DCHECK(!instance); | 425 DCHECK(!instance); |
428 } | 426 } |
429 | 427 |
430 // static | 428 // static |
431 WindowManager* WindowManager::Get() { | 429 WindowManager* WindowManager::Get() { |
432 DCHECK(instance); | 430 DCHECK(instance); |
433 return instance; | 431 return instance; |
434 } | 432 } |
435 | 433 |
436 } // namespace athena | 434 } // namespace athena |
OLD | NEW |