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.h" | 5 #include "ash/wm/workspace/workspace.h" |
6 | 6 |
7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
8 #include "ash/wm/property_util.h" | 8 #include "ash/wm/property_util.h" |
9 #include "ash/wm/window_animations.h" | 9 #include "ash/wm/window_animations.h" |
10 #include "ash/wm/window_properties.h" | 10 #include "ash/wm/window_properties.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "ash/wm/workspace/workspace_event_handler.h" | 12 #include "ash/wm/workspace/workspace_event_handler.h" |
13 #include "ash/wm/workspace/workspace_layout_manager.h" | 13 #include "ash/wm/workspace/workspace_layout_manager.h" |
14 #include "ash/wm/workspace/workspace_manager.h" | 14 #include "ash/wm/workspace/workspace_manager.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/views/corewm/visibility_controller.h" | 16 #include "ui/views/corewm/visibility_controller.h" |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 Workspace::Workspace(WorkspaceManager* manager, | 21 Workspace::Workspace(WorkspaceManager* manager, |
22 aura::Window* parent, | 22 aura::Window* parent) |
23 bool is_fullscreen) | 23 : workspace_manager_(manager), |
24 : is_fullscreen_(is_fullscreen), | |
25 workspace_manager_(manager), | |
26 window_(new aura::Window(NULL)), | 24 window_(new aura::Window(NULL)), |
27 event_handler_(new WorkspaceEventHandler(window_)), | 25 event_handler_(new WorkspaceEventHandler(window_)), |
28 workspace_layout_manager_(NULL) { | 26 workspace_layout_manager_(NULL) { |
29 views::corewm::SetChildWindowVisibilityChangesAnimated(window_); | 27 views::corewm::SetChildWindowVisibilityChangesAnimated(window_); |
30 SetWindowVisibilityAnimationTransition(window_, views::corewm::ANIMATE_NONE); | 28 SetWindowVisibilityAnimationTransition(window_, views::corewm::ANIMATE_NONE); |
31 window_->set_id(kShellWindowId_WorkspaceContainer); | 29 window_->set_id(kShellWindowId_WorkspaceContainer); |
32 window_->SetName("WorkspaceContainer"); | 30 window_->SetName("WorkspaceContainer"); |
33 window_->Init(ui::LAYER_NOT_DRAWN); | 31 window_->Init(ui::LAYER_NOT_DRAWN); |
34 // Do this so when animating out windows don't extend beyond the bounds. | 32 // Do this so when animating out windows don't extend beyond the bounds. |
35 window_->layer()->SetMasksToBounds(true); | 33 window_->layer()->SetMasksToBounds(true); |
(...skipping 28 matching lines...) Expand all Loading... |
64 // WorkspaceManager. | 62 // WorkspaceManager. |
65 window_->SetLayoutManager(NULL); | 63 window_->SetLayoutManager(NULL); |
66 window_->SetEventFilter(NULL); | 64 window_->SetEventFilter(NULL); |
67 window_->RemovePreTargetHandler(event_handler_.get()); | 65 window_->RemovePreTargetHandler(event_handler_.get()); |
68 window_->RemovePostTargetHandler(event_handler_.get()); | 66 window_->RemovePostTargetHandler(event_handler_.get()); |
69 aura::Window* window = window_; | 67 aura::Window* window = window_; |
70 window_ = NULL; | 68 window_ = NULL; |
71 return window; | 69 return window; |
72 } | 70 } |
73 | 71 |
74 bool Workspace::ShouldMoveToPending() const { | |
75 if (!is_fullscreen_) | |
76 return false; | |
77 | |
78 for (size_t i = 0; i < window_->children().size(); ++i) { | |
79 aura::Window* child(window_->children()[i]); | |
80 if (!child->TargetVisibility() || wm::IsWindowMinimized(child)) | |
81 continue; | |
82 | |
83 // If we have a fullscreen window don't move to pending. | |
84 if (wm::IsWindowFullscreen(child)) | |
85 return false; | |
86 | |
87 if (GetTrackedByWorkspace(child) && !GetPersistsAcrossAllWorkspaces(child)) | |
88 return false; | |
89 } | |
90 return true; | |
91 } | |
92 | |
93 int Workspace::GetNumFullscreenWindows() const { | |
94 int count = 0; | |
95 for (size_t i = 0; i < window_->children().size(); ++i) { | |
96 aura::Window* child = window_->children()[i]; | |
97 if (GetTrackedByWorkspace(child) && | |
98 (wm::IsWindowFullscreen(child) || | |
99 WorkspaceManager::WillRestoreToWorkspace(child))) { | |
100 if (++count == 2) | |
101 return count; | |
102 } | |
103 } | |
104 return count; | |
105 } | |
106 | |
107 } // namespace internal | 72 } // namespace internal |
108 } // namespace ash | 73 } // namespace ash |
OLD | NEW |