| 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/common/wm/workspace_controller.h" | 5 #include "ash/common/wm/workspace_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/wm/dock/docked_window_layout_manager.h" | |
| 11 #include "ash/common/wm/fullscreen_window_finder.h" | 10 #include "ash/common/wm/fullscreen_window_finder.h" |
| 12 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm/wm_window_animations.h" | 12 #include "ash/common/wm/wm_window_animations.h" |
| 14 #include "ash/common/wm/workspace/workspace_event_handler.h" | 13 #include "ash/common/wm/workspace/workspace_event_handler.h" |
| 15 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 14 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 16 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" | 15 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 17 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 17 #include "ash/common/wm_window.h" |
| 19 #include "ash/public/cpp/shell_window_ids.h" | 18 #include "ash/public/cpp/shell_window_ids.h" |
| 20 #include "ash/root_window_controller.h" | 19 #include "ash/root_window_controller.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 51 } |
| 53 | 52 |
| 54 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { | 53 wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { |
| 55 if (!viewport_ || !viewport_->GetRootWindowController()->HasShelf()) | 54 if (!viewport_ || !viewport_->GetRootWindowController()->HasShelf()) |
| 56 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 55 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| 57 | 56 |
| 58 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); | 57 const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); |
| 59 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) | 58 if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) |
| 60 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; | 59 return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| 61 | 60 |
| 62 // These are the container ids of containers which may contain windows that | |
| 63 // may overlap the launcher shelf and affect its transparency. | |
| 64 const int kWindowContainerIds[] = { | |
| 65 kShellWindowId_DefaultContainer, kShellWindowId_DockedContainer, | |
| 66 }; | |
| 67 const gfx::Rect shelf_bounds(WmShelf::ForWindow(viewport_)->GetIdealBounds()); | 61 const gfx::Rect shelf_bounds(WmShelf::ForWindow(viewport_)->GetIdealBounds()); |
| 68 bool window_overlaps_launcher = false; | 62 bool window_overlaps_launcher = false; |
| 69 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { | 63 // The default container may contain windows that may overlap the launcher |
| 70 WmWindow* container = viewport_->GetRootWindow()->GetChildByShellWindowId( | 64 // shelf and affect its transparency. |
| 71 kWindowContainerIds[i]); | 65 WmWindow* container = viewport_->GetRootWindow()->GetChildByShellWindowId( |
| 72 for (WmWindow* window : container->GetChildren()) { | 66 kShellWindowId_DefaultContainer); |
| 73 wm::WindowState* window_state = window->GetWindowState(); | 67 for (WmWindow* window : container->GetChildren()) { |
| 74 if (window_state->ignored_by_shelf() || | 68 wm::WindowState* window_state = window->GetWindowState(); |
| 75 (window->GetLayer() && !window->GetLayer()->GetTargetVisibility())) { | 69 if (window_state->ignored_by_shelf() || |
| 76 continue; | 70 (window->GetLayer() && !window->GetLayer()->GetTargetVisibility())) { |
| 77 } | 71 continue; |
| 78 if (window_state->IsMaximized()) | |
| 79 return wm::WORKSPACE_WINDOW_STATE_MAXIMIZED; | |
| 80 window_overlaps_launcher |= window->GetBounds().Intersects(shelf_bounds); | |
| 81 } | 72 } |
| 73 if (window_state->IsMaximized()) |
| 74 return wm::WORKSPACE_WINDOW_STATE_MAXIMIZED; |
| 75 window_overlaps_launcher |= window->GetBounds().Intersects(shelf_bounds); |
| 82 } | 76 } |
| 83 | 77 |
| 84 // Check if there are visible docked windows in the same display. | 78 return window_overlaps_launcher |
| 85 DockedWindowLayoutManager* dock = DockedWindowLayoutManager::Get(viewport_); | |
| 86 const bool docked_area_visible = dock && !dock->docked_bounds().IsEmpty(); | |
| 87 return (window_overlaps_launcher || docked_area_visible) | |
| 88 ? wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF | 79 ? wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF |
| 89 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 80 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| 90 } | 81 } |
| 91 | 82 |
| 92 void WorkspaceController::DoInitialAnimation() { | 83 void WorkspaceController::DoInitialAnimation() { |
| 93 viewport_->Show(); | 84 viewport_->Show(); |
| 94 | 85 |
| 95 ui::Layer* layer = viewport_->GetLayer(); | 86 ui::Layer* layer = viewport_->GetLayer(); |
| 96 layer->SetOpacity(0.0f); | 87 layer->SetOpacity(0.0f); |
| 97 SetTransformForScaleAnimation(layer, LAYER_SCALE_ANIMATION_ABOVE); | 88 SetTransformForScaleAnimation(layer, LAYER_SCALE_ANIMATION_ABOVE); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 125 void WorkspaceController::OnWindowDestroying(aura::Window* window) { | 116 void WorkspaceController::OnWindowDestroying(aura::Window* window) { |
| 126 DCHECK_EQ(WmWindow::Get(window), viewport_); | 117 DCHECK_EQ(WmWindow::Get(window), viewport_); |
| 127 viewport_->aura_window()->RemoveObserver(this); | 118 viewport_->aura_window()->RemoveObserver(this); |
| 128 viewport_ = nullptr; | 119 viewport_ = nullptr; |
| 129 // Destroy |event_handler_| too as it depends upon |window|. | 120 // Destroy |event_handler_| too as it depends upon |window|. |
| 130 event_handler_.reset(); | 121 event_handler_.reset(); |
| 131 layout_manager_ = nullptr; | 122 layout_manager_ = nullptr; |
| 132 } | 123 } |
| 133 | 124 |
| 134 } // namespace ash | 125 } // namespace ash |
| OLD | NEW |