| 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/root_window_controller.h" |
| 7 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/base_layout_manager.h" | 11 #include "ash/wm/base_layout_manager.h" |
| 11 #include "ash/wm/window_animations.h" | 12 #include "ash/wm/window_animations.h" |
| 12 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 13 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 14 #include "ash/wm/workspace/workspace_event_handler.h" | 15 #include "ash/wm/workspace/workspace_event_handler.h" |
| 15 #include "ash/wm/workspace/workspace_layout_manager.h" | 16 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 16 #include "ui/aura/client/activation_client.h" | 17 #include "ui/aura/client/activation_client.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 WorkspaceController::~WorkspaceController() { | 60 WorkspaceController::~WorkspaceController() { |
| 60 viewport_->SetLayoutManager(NULL); | 61 viewport_->SetLayoutManager(NULL); |
| 61 viewport_->SetEventFilter(NULL); | 62 viewport_->SetEventFilter(NULL); |
| 62 viewport_->RemovePreTargetHandler(event_handler_.get()); | 63 viewport_->RemovePreTargetHandler(event_handler_.get()); |
| 63 viewport_->RemovePostTargetHandler(event_handler_.get()); | 64 viewport_->RemovePostTargetHandler(event_handler_.get()); |
| 64 } | 65 } |
| 65 | 66 |
| 66 WorkspaceWindowState WorkspaceController::GetWindowState() const { | 67 WorkspaceWindowState WorkspaceController::GetWindowState() const { |
| 67 if (!shelf_) | 68 if (!shelf_) |
| 68 return WORKSPACE_WINDOW_STATE_DEFAULT; | 69 return WORKSPACE_WINDOW_STATE_DEFAULT; |
| 70 const aura::Window* topmost_fullscreen_window = GetRootWindowController( |
| 71 viewport_->GetRootWindow())->GetWindowForFullscreenMode(); |
| 72 if (topmost_fullscreen_window && |
| 73 !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) { |
| 74 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| 75 } |
| 69 | 76 |
| 70 // These are the container ids of containers which may contain windows that | 77 // These are the container ids of containers which may contain windows that |
| 71 // may overlap the launcher shelf and affect its transparency. | 78 // may overlap the launcher shelf and affect its transparency. |
| 72 const int kWindowContainerIds[] = { | 79 const int kWindowContainerIds[] = { |
| 73 internal::kShellWindowId_DefaultContainer, | 80 internal::kShellWindowId_DefaultContainer, |
| 74 internal::kShellWindowId_DockedContainer, | 81 internal::kShellWindowId_DockedContainer, |
| 75 }; | 82 }; |
| 76 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); | 83 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
| 77 bool window_overlaps_launcher = false; | 84 bool window_overlaps_launcher = false; |
| 78 bool has_maximized_window = false; | |
| 79 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { | 85 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { |
| 80 const aura::Window* container = Shell::GetContainer( | 86 const aura::Window* container = Shell::GetContainer( |
| 81 viewport_->GetRootWindow(), kWindowContainerIds[idx]); | 87 viewport_->GetRootWindow(), kWindowContainerIds[idx]); |
| 82 const aura::Window::Windows& windows(container->children()); | 88 const aura::Window::Windows& windows(container->children()); |
| 83 for (aura::Window::Windows::const_iterator i = windows.begin(); | 89 for (aura::Window::Windows::const_iterator i = windows.begin(); |
| 84 i != windows.end(); ++i) { | 90 i != windows.end(); ++i) { |
| 85 wm::WindowState* window_state = wm::GetWindowState(*i); | 91 wm::WindowState* window_state = wm::GetWindowState(*i); |
| 86 if (window_state->ignored_by_shelf()) | 92 if (window_state->ignored_by_shelf()) |
| 87 continue; | 93 continue; |
| 88 ui::Layer* layer = (*i)->layer(); | 94 ui::Layer* layer = (*i)->layer(); |
| 89 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) | 95 if (!layer->GetTargetVisibility()) |
| 90 continue; | 96 continue; |
| 91 if (window_state->IsMaximized()) { | 97 if (window_state->IsMaximized()) |
| 92 // An untracked window may still be fullscreen so we keep iterating when | 98 return WORKSPACE_WINDOW_STATE_MAXIMIZED; |
| 93 // we hit a maximized window. | |
| 94 has_maximized_window = true; | |
| 95 } else if (window_state->IsFullscreen()) { | |
| 96 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; | |
| 97 } | |
| 98 if (!window_overlaps_launcher && | 99 if (!window_overlaps_launcher && |
| 99 ((*i)->bounds().Intersects(shelf_bounds) || | 100 ((*i)->bounds().Intersects(shelf_bounds) || |
| 100 IsDockedAndVisible(*i))) { | 101 IsDockedAndVisible(*i))) { |
| 101 window_overlaps_launcher = true; | 102 window_overlaps_launcher = true; |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 if (has_maximized_window) | |
| 106 return WORKSPACE_WINDOW_STATE_MAXIMIZED; | |
| 107 | 106 |
| 108 return window_overlaps_launcher ? | 107 return window_overlaps_launcher ? |
| 109 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 108 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
| 110 WORKSPACE_WINDOW_STATE_DEFAULT; | 109 WORKSPACE_WINDOW_STATE_DEFAULT; |
| 111 } | 110 } |
| 112 | 111 |
| 113 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { | 112 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { |
| 114 shelf_ = shelf; | 113 shelf_ = shelf; |
| 115 layout_manager_->SetShelf(shelf); | 114 layout_manager_->SetShelf(shelf); |
| 116 } | 115 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 settings.SetTweenType(gfx::Tween::EASE_OUT); | 140 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 142 settings.SetTransitionDuration( | 141 settings.SetTransitionDuration( |
| 143 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | 142 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
| 144 viewport_->layer()->SetTransform(gfx::Transform()); | 143 viewport_->layer()->SetTransform(gfx::Transform()); |
| 145 viewport_->layer()->SetOpacity(1.0f); | 144 viewport_->layer()->SetOpacity(1.0f); |
| 146 } | 145 } |
| 147 } | 146 } |
| 148 | 147 |
| 149 } // namespace internal | 148 } // namespace internal |
| 150 } // namespace ash | 149 } // namespace ash |
| OLD | NEW |