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/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 void WorkspaceManager::UpdateShelfVisibility() { | 131 void WorkspaceManager::UpdateShelfVisibility() { |
132 shelf_->UpdateVisibilityState(); | 132 shelf_->UpdateVisibilityState(); |
133 } | 133 } |
134 | 134 |
135 WorkspaceManager::WindowState WorkspaceManager::GetWindowState() { | 135 WorkspaceManager::WindowState WorkspaceManager::GetWindowState() { |
136 if (!shelf_ || !active_workspace_) | 136 if (!shelf_ || !active_workspace_) |
137 return WINDOW_STATE_DEFAULT; | 137 return WINDOW_STATE_DEFAULT; |
138 | 138 |
139 // TODO: this code needs to be made multi-monitor aware. | 139 // TODO: this code needs to be made multi-monitor aware. |
140 gfx::Rect bounds( | 140 gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
141 gfx::Screen::GetMonitorNearestWindow(contents_view_).bounds()); | |
142 bounds.set_height(bounds.height() - shelf_->shelf_height()); | |
143 const aura::Window::Windows& windows(contents_view_->children()); | 141 const aura::Window::Windows& windows(contents_view_->children()); |
144 bool window_overlaps_launcher = false; | 142 bool window_overlaps_launcher = false; |
145 bool has_maximized_window = false; | 143 bool has_maximized_window = false; |
146 for (aura::Window::Windows::const_iterator i = windows.begin(); | 144 for (aura::Window::Windows::const_iterator i = windows.begin(); |
147 i != windows.end(); ++i) { | 145 i != windows.end(); ++i) { |
148 ui::Layer* layer = (*i)->layer(); | 146 ui::Layer* layer = (*i)->layer(); |
149 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) | 147 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) |
150 continue; | 148 continue; |
151 if (wm::IsWindowMaximized(*i)) { | 149 if (wm::IsWindowMaximized(*i)) { |
152 // An untracked window may still be fullscreen so we keep iterating when | 150 // An untracked window may still be fullscreen so we keep iterating when |
153 // we hit a maximized window. | 151 // we hit a maximized window. |
154 has_maximized_window = true; | 152 has_maximized_window = true; |
155 } else if (wm::IsWindowFullscreen(*i)) { | 153 } else if (wm::IsWindowFullscreen(*i)) { |
156 return WINDOW_STATE_FULL_SCREEN; | 154 return WINDOW_STATE_FULL_SCREEN; |
157 } | 155 } |
158 if (!window_overlaps_launcher && (*i)->bounds().bottom() > bounds.bottom()) | 156 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) |
159 window_overlaps_launcher = true; | 157 window_overlaps_launcher = true; |
160 } | 158 } |
161 if (has_maximized_window) | 159 if (has_maximized_window) |
162 return WINDOW_STATE_MAXIMIZED; | 160 return WINDOW_STATE_MAXIMIZED; |
163 | 161 |
164 return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 162 return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
165 WINDOW_STATE_DEFAULT; | 163 WINDOW_STATE_DEFAULT; |
166 } | 164 } |
167 | 165 |
168 void WorkspaceManager::ShowStateChanged(aura::Window* window) { | 166 void WorkspaceManager::ShowStateChanged(aura::Window* window) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 return workspace; | 336 return workspace; |
339 } | 337 } |
340 | 338 |
341 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { | 339 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { |
342 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) | 340 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) |
343 delete workspace; | 341 delete workspace; |
344 } | 342 } |
345 | 343 |
346 } // namespace internal | 344 } // namespace internal |
347 } // namespace ash | 345 } // namespace ash |
OLD | NEW |