| 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.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "ash/wm/property_util.h" | |
| 10 #include "ash/wm/window_util.h" | |
| 11 #include "ash/wm/workspace/workspace_manager.h" | |
| 12 #include "base/logging.h" | |
| 13 #include "ui/aura/client/aura_constants.h" | |
| 14 #include "ui/aura/root_window.h" | |
| 15 #include "ui/aura/window.h" | |
| 16 #include "ui/base/ui_base_types.h" | |
| 17 | |
| 18 namespace ash { | |
| 19 namespace internal { | |
| 20 | |
| 21 Workspace::Workspace(WorkspaceManager* manager, Type type) | |
| 22 : type_(type), | |
| 23 workspace_manager_(manager) { | |
| 24 } | |
| 25 | |
| 26 Workspace::~Workspace() { | |
| 27 workspace_manager_->RemoveWorkspace(this); | |
| 28 } | |
| 29 | |
| 30 // static | |
| 31 Workspace::Type Workspace::TypeForWindow(aura::Window* window) { | |
| 32 if (wm::IsWindowMaximized(window) || wm::IsWindowFullscreen(window)) | |
| 33 return TYPE_MAXIMIZED; | |
| 34 return TYPE_MANAGED; | |
| 35 } | |
| 36 | |
| 37 bool Workspace::AddWindowAfter(aura::Window* window, aura::Window* after) { | |
| 38 if (!CanAdd(window)) | |
| 39 return false; | |
| 40 DCHECK(!Contains(window)); | |
| 41 | |
| 42 aura::Window::Windows::iterator i = | |
| 43 std::find(windows_.begin(), windows_.end(), after); | |
| 44 if (!after || i == windows_.end()) | |
| 45 windows_.push_back(window); | |
| 46 else | |
| 47 windows_.insert(++i, window); | |
| 48 OnWindowAddedAfter(window, after); | |
| 49 return true; | |
| 50 } | |
| 51 | |
| 52 void Workspace::RemoveWindow(aura::Window* window) { | |
| 53 DCHECK(Contains(window)); | |
| 54 windows_.erase(std::find(windows_.begin(), windows_.end(), window)); | |
| 55 OnWindowRemoved(window); | |
| 56 } | |
| 57 | |
| 58 bool Workspace::Contains(aura::Window* window) const { | |
| 59 return std::find(windows_.begin(), windows_.end(), window) != windows_.end(); | |
| 60 } | |
| 61 | |
| 62 void Workspace::Activate() { | |
| 63 workspace_manager_->SetActiveWorkspace(this); | |
| 64 } | |
| 65 | |
| 66 void Workspace::SetWindowBounds(aura::Window* window, const gfx::Rect& bounds) { | |
| 67 workspace_manager_->SetWindowBounds(window, bounds); | |
| 68 } | |
| 69 | |
| 70 } // namespace internal | |
| 71 } // namespace ash | |
| OLD | NEW |