| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/wm/workspace/workspace_layout_manager.h" | |
| 6 | |
| 7 #include "ash/screen_ash.h" | |
| 8 #include "ash/wm/window_properties.h" | |
| 9 #include "ash/wm/window_util.h" | |
| 10 #include "ash/wm/workspace/workspace.h" | |
| 11 #include "ash/wm/workspace/workspace_manager.h" | |
| 12 #include "ui/aura/client/aura_constants.h" | |
| 13 #include "ui/aura/root_window.h" | |
| 14 #include "ui/aura/window.h" | |
| 15 #include "ui/aura/window_observer.h" | |
| 16 #include "ui/base/events/event.h" | |
| 17 #include "ui/base/ui_base_types.h" | |
| 18 #include "ui/gfx/rect.h" | |
| 19 | |
| 20 namespace ash { | |
| 21 namespace internal { | |
| 22 | |
| 23 WorkspaceLayoutManager::WorkspaceLayoutManager( | |
| 24 aura::RootWindow* root_window, | |
| 25 WorkspaceManager* workspace_manager) | |
| 26 : BaseLayoutManager(root_window), | |
| 27 workspace_manager_(workspace_manager) { | |
| 28 } | |
| 29 | |
| 30 WorkspaceLayoutManager::~WorkspaceLayoutManager() { | |
| 31 } | |
| 32 | |
| 33 void WorkspaceLayoutManager::OnWindowResized() { | |
| 34 // Workspace is updated via OnRootWindowResized. | |
| 35 } | |
| 36 | |
| 37 void WorkspaceLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | |
| 38 BaseLayoutManager::OnWindowAddedToLayout(child); | |
| 39 if (!workspace_manager_->ShouldManageWindow(child)) { | |
| 40 if (child->IsVisible()) | |
| 41 workspace_manager_->UpdateShelfVisibility(); | |
| 42 return; | |
| 43 } | |
| 44 | |
| 45 if (child->IsVisible()) | |
| 46 workspace_manager_->AddWindow(child); | |
| 47 } | |
| 48 | |
| 49 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { | |
| 50 workspace_manager_->RemoveWindow(child); | |
| 51 BaseLayoutManager::OnWillRemoveWindowFromLayout(child); | |
| 52 } | |
| 53 | |
| 54 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | |
| 55 workspace_manager_->UpdateShelfVisibility(); | |
| 56 BaseLayoutManager::OnWindowRemovedFromLayout(child); | |
| 57 } | |
| 58 | |
| 59 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged( | |
| 60 aura::Window* child, | |
| 61 bool visible) { | |
| 62 BaseLayoutManager::OnChildWindowVisibilityChanged(child, visible); | |
| 63 if (!workspace_manager_->ShouldManageWindow(child)) { | |
| 64 workspace_manager_->UpdateShelfVisibility(); | |
| 65 return; | |
| 66 } | |
| 67 | |
| 68 if (visible) | |
| 69 workspace_manager_->AddWindow(child); | |
| 70 else | |
| 71 workspace_manager_->RemoveWindow(child); | |
| 72 } | |
| 73 | |
| 74 void WorkspaceLayoutManager::SetChildBounds( | |
| 75 aura::Window* child, | |
| 76 const gfx::Rect& requested_bounds) { | |
| 77 if (GetTrackedByWorkspace(child)) | |
| 78 BaseLayoutManager::SetChildBounds(child, requested_bounds); | |
| 79 else | |
| 80 SetChildBoundsDirect(child, requested_bounds); | |
| 81 workspace_manager_->UpdateShelfVisibility(); | |
| 82 } | |
| 83 | |
| 84 void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window, | |
| 85 const void* key, | |
| 86 intptr_t old) { | |
| 87 BaseLayoutManager::OnWindowPropertyChanged(window, key, old); | |
| 88 if (key == ash::internal::kWindowTrackedByWorkspaceKey && | |
| 89 ash::GetTrackedByWorkspace(window)) { | |
| 90 // We currently don't need to support transitioning from true to false, so | |
| 91 // we ignore it. | |
| 92 workspace_manager_->AddWindow(window); | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 void WorkspaceLayoutManager::ShowStateChanged( | |
| 97 aura::Window* window, | |
| 98 ui::WindowShowState last_show_state) { | |
| 99 if (workspace_manager_->ShouldManageWindow(window)) { | |
| 100 if (wm::IsWindowMinimized(window)) { | |
| 101 workspace_manager_->RemoveWindow(window); | |
| 102 } else if ((window->TargetVisibility() || | |
| 103 last_show_state == ui::SHOW_STATE_MINIMIZED) && | |
| 104 !workspace_manager_->Contains(window)) { | |
| 105 workspace_manager_->AddWindow(window); | |
| 106 } | |
| 107 } | |
| 108 BaseLayoutManager::ShowStateChanged(window, last_show_state); | |
| 109 workspace_manager_->ShowStateChanged(window); | |
| 110 // As BaseLayoutManager::ShowStateChanged() may change the visibility of the | |
| 111 // window we need to invoke UpdateShelfVisibility() after ShowStateChanged(). | |
| 112 workspace_manager_->UpdateShelfVisibility(); | |
| 113 } | |
| 114 | |
| 115 } // namespace internal | |
| 116 } // namespace ash | |
| OLD | NEW |