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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/workspace/workspace2.h ('k') | ash/wm/workspace/workspace_manager2.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace2.cc
diff --git a/ash/wm/workspace/workspace2.cc b/ash/wm/workspace/workspace2.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9d585b5c67fc4dfb7de7dad78803974c772206d5
--- /dev/null
+++ b/ash/wm/workspace/workspace2.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/workspace/workspace2.h"
+
+#include "ash/shell_window_ids.h"
+#include "ash/wm/property_util.h"
+#include "ash/wm/window_properties.h"
+#include "ash/wm/window_util.h"
+#include "ash/wm/workspace/workspace_event_filter.h"
+#include "ash/wm/workspace/workspace_manager2.h"
+#include "ui/aura/window.h"
+
+namespace ash {
+namespace internal {
+
+Workspace2::Workspace2(WorkspaceManager2* manager,
+ aura::Window* parent,
+ bool is_maximized)
+ : is_maximized_(is_maximized),
+ workspace_manager_(manager),
+ window_(new aura::Window(NULL)),
+ event_filter_(new WorkspaceEventFilter(window_)) {
+ window_->set_id(kShellWindowId_WorkspaceContainer);
+ window_->SetName("WorkspaceContainer");
+ window_->Init(ui::LAYER_NOT_DRAWN);
+ window_->Show();
+ window_->SetParent(parent);
+ window_->SetEventFilter(event_filter_);
+ window_->SetProperty(internal::kUsesScreenCoordinatesKey, true);
+}
+
+Workspace2::~Workspace2() {
+ // ReleaseWindow() should have been invoked before we're deleted.
+ DCHECK(!window_);
+}
+
+aura::Window* Workspace2::ReleaseWindow() {
+ // Remove the LayoutManager and EventFilter as they refer back to us and/or
+ // WorkspaceManager.
+ window_->SetLayoutManager(NULL);
+ window_->SetEventFilter(NULL);
+ aura::Window* window = window_;
+ window_ = NULL;
+ event_filter_ = NULL;
+ return window;
+}
+
+void Workspace2::SetGridSize(int grid_size) {
+ event_filter_->set_grid_size(grid_size);
+}
+
+bool Workspace2::ShouldMoveToPending() const {
+ if (!is_maximized_)
+ return false;
+
+ bool has_visible_non_maximized_window = false;
+ for (size_t i = 0; i < window_->children().size(); ++i) {
+ aura::Window* child(window_->children()[i]);
+ if (!child->TargetVisibility() || wm::IsWindowMinimized(child))
+ continue;
+ if (WorkspaceManager2::IsMaximized(child))
+ return false;
+
+ if (GetTrackedByWorkspace(child) && !GetPersistsAcrossAllWorkspaces(child))
+ has_visible_non_maximized_window = true;
+ }
+ return !has_visible_non_maximized_window;
+}
+
+int Workspace2::GetNumMaximizedWindows() const {
+ int count = 0;
+ for (size_t i = 0; i < window_->children().size(); ++i) {
+ aura::Window* child = window_->children()[i];
+ if (WorkspaceManager2::IsMaximized(child) ||
+ WorkspaceManager2::WillRestoreMaximized(child)) {
+ if (++count == 2)
+ return count;
+ }
+ }
+ return count;
+}
+
+} // namespace internal
+} // namespace ash
« 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