OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
14 #include "ash/shelf/shelf_util.h" | 14 #include "ash/shelf/shelf_util.h" |
15 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 18 #include "ash/wm/overview/window_selector_controller.h" |
18 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
19 #include "ash/wm/window_state.h" | 20 #include "ash/wm/window_state.h" |
20 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
21 #include "base/auto_reset.h" | 22 #include "base/auto_reset.h" |
22 #include "base/bind.h" | 23 #include "base/bind.h" |
23 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.h" |
24 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
25 #include "third_party/skia/include/core/SkPaint.h" | 26 #include "third_party/skia/include/core/SkPaint.h" |
26 #include "third_party/skia/include/core/SkPath.h" | 27 #include "third_party/skia/include/core/SkPath.h" |
27 #include "ui/aura/client/focus_client.h" | 28 #include "ui/aura/client/focus_client.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void PanelLayoutManager::OnShelfIconPositionsChanged() { | 458 void PanelLayoutManager::OnShelfIconPositionsChanged() { |
458 // TODO: As this is called for every animation step now. Relayout needs to be | 459 // TODO: As this is called for every animation step now. Relayout needs to be |
459 // updated to use current icon position instead of use the ideal bounds so | 460 // updated to use current icon position instead of use the ideal bounds so |
460 // that the panels slide with their icons instead of jumping. | 461 // that the panels slide with their icons instead of jumping. |
461 Relayout(); | 462 Relayout(); |
462 } | 463 } |
463 | 464 |
464 //////////////////////////////////////////////////////////////////////////////// | 465 //////////////////////////////////////////////////////////////////////////////// |
465 // PanelLayoutManager, ash::ShellObserver implementation: | 466 // PanelLayoutManager, ash::ShellObserver implementation: |
466 | 467 |
| 468 void PanelLayoutManager::OnOverviewModeEnded() { |
| 469 Relayout(); |
| 470 } |
| 471 |
467 void PanelLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) { | 472 void PanelLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) { |
468 if (panel_container_->GetRootWindow() == root_window) | 473 if (panel_container_->GetRootWindow() == root_window) |
469 Relayout(); | 474 Relayout(); |
470 } | 475 } |
471 | 476 |
472 ///////////////////////////////////////////////////////////////////////////// | 477 ///////////////////////////////////////////////////////////////////////////// |
473 // PanelLayoutManager, WindowObserver implementation: | 478 // PanelLayoutManager, WindowObserver implementation: |
474 | 479 |
475 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, | 480 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, |
476 const void* key, | 481 const void* key, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 std::find(panel_windows_.begin(), panel_windows_.end(), panel); | 597 std::find(panel_windows_.begin(), panel_windows_.end(), panel); |
593 DCHECK(found != panel_windows_.end()); | 598 DCHECK(found != panel_windows_.end()); |
594 found->slide_in = true; | 599 found->slide_in = true; |
595 Relayout(); | 600 Relayout(); |
596 } | 601 } |
597 | 602 |
598 void PanelLayoutManager::Relayout() { | 603 void PanelLayoutManager::Relayout() { |
599 if (!shelf_ || !shelf_->shelf_widget()) | 604 if (!shelf_ || !shelf_->shelf_widget()) |
600 return; | 605 return; |
601 | 606 |
602 if (in_layout_) | 607 // Suppress layouts during overview mode because changing window bounds |
| 608 // interfered with overview mode animations. However, layouts need to be done |
| 609 // when the WindowSelectorController is restoring minimized windows so that |
| 610 // they actually become visible. |
| 611 WindowSelectorController* window_selector_controller = |
| 612 Shell::GetInstance()->window_selector_controller(); |
| 613 if (in_layout_ || !window_selector_controller || |
| 614 (window_selector_controller->IsSelecting() && |
| 615 !window_selector_controller->IsRestoringMinimizedWindows())) |
603 return; | 616 return; |
604 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 617 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
605 | 618 |
606 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); | 619 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); |
607 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || | 620 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || |
608 alignment == SHELF_ALIGNMENT_BOTTOM; | 621 alignment == SHELF_ALIGNMENT_BOTTOM; |
609 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( | 622 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( |
610 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); | 623 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); |
611 int panel_start_bounds = kPanelIdealSpacing; | 624 int panel_start_bounds = kPanelIdealSpacing; |
612 int panel_end_bounds = horizontal ? | 625 int panel_end_bounds = horizontal ? |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 // Keyboard hidden, restore original bounds if they exist. | 949 // Keyboard hidden, restore original bounds if they exist. |
937 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); | 950 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); |
938 } | 951 } |
939 } | 952 } |
940 // This bounds change will have caused a change to the Shelf which does not | 953 // This bounds change will have caused a change to the Shelf which does not |
941 // propogate automatically to this class, so manually recalculate bounds. | 954 // propogate automatically to this class, so manually recalculate bounds. |
942 OnWindowResized(); | 955 OnWindowResized(); |
943 } | 956 } |
944 | 957 |
945 } // namespace ash | 958 } // namespace ash |
OLD | NEW |