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