| 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/workspace_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
| 6 | 6 |
| 7 #include "ash/shelf/shelf_layout_manager.h" | 7 #include "ash/shelf/shelf_layout_manager.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/base_layout_manager.h" | 10 #include "ash/wm/base_layout_manager.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 viewport_->SetLayoutManager(NULL); | 51 viewport_->SetLayoutManager(NULL); |
| 52 viewport_->SetEventFilter(NULL); | 52 viewport_->SetEventFilter(NULL); |
| 53 viewport_->RemovePreTargetHandler(event_handler_.get()); | 53 viewport_->RemovePreTargetHandler(event_handler_.get()); |
| 54 viewport_->RemovePostTargetHandler(event_handler_.get()); | 54 viewport_->RemovePostTargetHandler(event_handler_.get()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 WorkspaceWindowState WorkspaceController::GetWindowState() const { | 57 WorkspaceWindowState WorkspaceController::GetWindowState() const { |
| 58 if (!shelf_) | 58 if (!shelf_) |
| 59 return WORKSPACE_WINDOW_STATE_DEFAULT; | 59 return WORKSPACE_WINDOW_STATE_DEFAULT; |
| 60 | 60 |
| 61 // These are the container ids of containers which may contain windows that |
| 62 // may overlap the launcher shelf and affect its transparency. |
| 63 const int kWindowContainerIds[] = { |
| 64 internal::kShellWindowId_DefaultContainer, |
| 65 internal::kShellWindowId_DockedContainer, |
| 66 }; |
| 61 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); | 67 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
| 62 const aura::Window::Windows& windows(viewport_->children()); | |
| 63 bool window_overlaps_launcher = false; | 68 bool window_overlaps_launcher = false; |
| 64 bool has_maximized_window = false; | 69 bool has_maximized_window = false; |
| 65 for (aura::Window::Windows::const_iterator i = windows.begin(); | 70 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { |
| 66 i != windows.end(); ++i) { | 71 const aura::Window* container = Shell::GetContainer( |
| 67 wm::WindowState* window_state = wm::GetWindowState(*i); | 72 viewport_->GetRootWindow(), kWindowContainerIds[idx]); |
| 68 if (window_state->ignored_by_shelf()) | 73 const aura::Window::Windows& windows(container->children()); |
| 69 continue; | 74 for (aura::Window::Windows::const_iterator i = windows.begin(); |
| 70 ui::Layer* layer = (*i)->layer(); | 75 i != windows.end(); ++i) { |
| 71 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) | 76 wm::WindowState* window_state = wm::GetWindowState(*i); |
| 72 continue; | 77 if (window_state->ignored_by_shelf()) |
| 73 if (window_state->IsMaximized()) { | 78 continue; |
| 74 // An untracked window may still be fullscreen so we keep iterating when | 79 ui::Layer* layer = (*i)->layer(); |
| 75 // we hit a maximized window. | 80 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) |
| 76 has_maximized_window = true; | 81 continue; |
| 77 } else if (window_state->IsFullscreen()) { | 82 if (window_state->IsMaximized()) { |
| 78 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; | 83 // An untracked window may still be fullscreen so we keep iterating when |
| 84 // we hit a maximized window. |
| 85 has_maximized_window = true; |
| 86 } else if (window_state->IsFullscreen()) { |
| 87 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| 88 } |
| 89 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) |
| 90 window_overlaps_launcher = true; |
| 79 } | 91 } |
| 80 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) | |
| 81 window_overlaps_launcher = true; | |
| 82 } | 92 } |
| 83 if (has_maximized_window) | 93 if (has_maximized_window) |
| 84 return WORKSPACE_WINDOW_STATE_MAXIMIZED; | 94 return WORKSPACE_WINDOW_STATE_MAXIMIZED; |
| 85 | 95 |
| 86 return window_overlaps_launcher ? | 96 return window_overlaps_launcher ? |
| 87 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 97 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
| 88 WORKSPACE_WINDOW_STATE_DEFAULT; | 98 WORKSPACE_WINDOW_STATE_DEFAULT; |
| 89 } | 99 } |
| 90 | 100 |
| 91 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { | 101 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 119 settings.SetTweenType(gfx::Tween::EASE_OUT); | 129 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 120 settings.SetTransitionDuration( | 130 settings.SetTransitionDuration( |
| 121 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | 131 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
| 122 viewport_->layer()->SetTransform(gfx::Transform()); | 132 viewport_->layer()->SetTransform(gfx::Transform()); |
| 123 viewport_->layer()->SetOpacity(1.0f); | 133 viewport_->layer()->SetOpacity(1.0f); |
| 124 } | 134 } |
| 125 } | 135 } |
| 126 | 136 |
| 127 } // namespace internal | 137 } // namespace internal |
| 128 } // namespace ash | 138 } // namespace ash |
| OLD | NEW |