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

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

Issue 10830365: Initial crack at new workspace behavior. Each workspace now has its (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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_manager2.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_properties.h"
10 #include "ash/wm/window_util.h"
11 #include "ash/wm/workspace/workspace_event_filter.h"
12 #include "ash/wm/workspace/workspace_manager2.h"
13 #include "ui/aura/window.h"
14
15 namespace ash {
16 namespace internal {
17
18 Workspace2::Workspace2(WorkspaceManager2* manager,
19 aura::Window* parent,
20 bool is_maximized)
21 : is_maximized_(is_maximized),
22 workspace_manager_(manager),
23 window_(new aura::Window(NULL)),
24 event_filter_(new WorkspaceEventFilter(window_)) {
25 window_->set_id(kShellWindowId_WorkspaceContainer);
26 window_->SetName("WorkspaceContainer");
27 window_->Init(ui::LAYER_NOT_DRAWN);
28 window_->Show();
29 window_->SetParent(parent);
30 window_->SetEventFilter(event_filter_);
31 window_->SetProperty(internal::kUsesScreenCoordinatesKey, true);
32 }
33
34 Workspace2::~Workspace2() {
35 // ReleaseWindow() should have been invoked before we're deleted.
36 DCHECK(!window_);
37 }
38
39 aura::Window* Workspace2::ReleaseWindow() {
40 // Remove the LayoutManager and EventFilter as they refer back to us and/or
41 // WorkspaceManager.
42 window_->SetLayoutManager(NULL);
43 window_->SetEventFilter(NULL);
44 aura::Window* window = window_;
45 window_ = NULL;
46 event_filter_ = NULL;
47 return window;
48 }
49
50 void Workspace2::SetGridSize(int grid_size) {
51 event_filter_->set_grid_size(grid_size);
52 }
53
54 bool Workspace2::ShouldMoveToPending() const {
55 if (!is_maximized_)
56 return false;
57
58 bool has_visible_non_maximized_window = false;
59 for (size_t i = 0; i < window_->children().size(); ++i) {
60 aura::Window* child(window_->children()[i]);
61 if (!child->TargetVisibility() || wm::IsWindowMinimized(child))
62 continue;
63 if (WorkspaceManager2::IsMaximized(child))
64 return false;
65
66 if (GetTrackedByWorkspace(child) && !GetPersistsAcrossAllWorkspaces(child))
67 has_visible_non_maximized_window = true;
68 }
69 return !has_visible_non_maximized_window;
70 }
71
72 int Workspace2::GetNumMaximizedWindows() const {
73 int count = 0;
74 for (size_t i = 0; i < window_->children().size(); ++i) {
75 aura::Window* child = window_->children()[i];
76 if (WorkspaceManager2::IsMaximized(child) ||
77 WorkspaceManager2::WillRestoreMaximized(child)) {
78 if (++count == 2)
79 return count;
80 }
81 }
82 return count;
83 }
84
85 } // namespace internal
86 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace2.h ('k') | ash/wm/workspace/workspace_manager2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698