Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: ash/wm/workspace/workspace2.cc

Issue 11293014: Renames Workspace*2 -> Workspace*. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/workspace/workspace2.h ('k') | ash/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/workspace2.h"
6
7 #include "ash/shell_window_ids.h"
8 #include "ash/wm/property_util.h"
9 #include "ash/wm/window_animations.h"
10 #include "ash/wm/window_properties.h"
11 #include "ash/wm/window_util.h"
12 #include "ash/wm/workspace/workspace_event_handler.h"
13 #include "ash/wm/workspace/workspace_layout_manager2.h"
14 #include "ash/wm/workspace/workspace_manager2.h"
15 #include "ui/aura/window.h"
16
17 namespace ash {
18 namespace internal {
19
20 Workspace2::Workspace2(WorkspaceManager2* manager,
21 aura::Window* parent,
22 bool is_maximized)
23 : is_maximized_(is_maximized),
24 workspace_manager_(manager),
25 window_(new aura::Window(NULL)),
26 event_handler_(new WorkspaceEventHandler(window_)),
27 workspace_layout_manager_(NULL) {
28 window_->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey,
29 true);
30 SetWindowVisibilityAnimationTransition(window_, ANIMATE_NONE);
31 window_->set_id(kShellWindowId_WorkspaceContainer);
32 window_->SetName("WorkspaceContainer");
33 window_->Init(ui::LAYER_NOT_DRAWN);
34 // Do this so when animating out windows don't extend beyond the bounds.
35 window_->layer()->SetMasksToBounds(true);
36 window_->Hide();
37 window_->SetParent(parent);
38 window_->SetProperty(internal::kUsesScreenCoordinatesKey, true);
39
40 // The layout-manager cannot be created in the initializer list since it
41 // depends on the window to have been initialized.
42 workspace_layout_manager_ = new WorkspaceLayoutManager2(this);
43 window_->SetLayoutManager(workspace_layout_manager_);
44 }
45
46 Workspace2::~Workspace2() {
47 // ReleaseWindow() should have been invoked before we're deleted.
48 DCHECK(!window_);
49 }
50
51 aura::Window* Workspace2::ReleaseWindow() {
52 // Remove the LayoutManager and EventFilter as they refer back to us and/or
53 // WorkspaceManager.
54 window_->SetLayoutManager(NULL);
55 window_->SetEventFilter(NULL);
56 aura::Window* window = window_;
57 window_ = NULL;
58 return window;
59 }
60
61 bool Workspace2::ShouldMoveToPending() const {
62 if (!is_maximized_)
63 return false;
64
65 bool has_visible_non_maximized_window = false;
66 for (size_t i = 0; i < window_->children().size(); ++i) {
67 aura::Window* child(window_->children()[i]);
68 if (!GetTrackedByWorkspace(child) || !child->TargetVisibility() ||
69 wm::IsWindowMinimized(child))
70 continue;
71 if (WorkspaceManager2::IsMaximized(child))
72 return false;
73
74 if (GetTrackedByWorkspace(child) && !GetPersistsAcrossAllWorkspaces(child))
75 has_visible_non_maximized_window = true;
76 }
77 return !has_visible_non_maximized_window;
78 }
79
80 int Workspace2::GetNumMaximizedWindows() const {
81 int count = 0;
82 for (size_t i = 0; i < window_->children().size(); ++i) {
83 aura::Window* child = window_->children()[i];
84 if (GetTrackedByWorkspace(child) &&
85 (WorkspaceManager2::IsMaximized(child) ||
86 WorkspaceManager2::WillRestoreMaximized(child))) {
87 if (++count == 2)
88 return count;
89 }
90 }
91 return count;
92 }
93
94 } // namespace internal
95 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace2.h ('k') | ash/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698