summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-16 19:14:41 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-16 19:14:41 +0000
commite64376ec9bb7d40489f71c9c486a27be5c890a29 (patch)
tree7d69e47c8937a6ccec4bc5cba9056556cc45809d /ash
parente338057519cd315030d33c43a4968b649baa8f59 (diff)
downloadchromium_src-e64376ec9bb7d40489f71c9c486a27be5c890a29.zip
chromium_src-e64376ec9bb7d40489f71c9c486a27be5c890a29.tar.gz
chromium_src-e64376ec9bb7d40489f71c9c486a27be5c890a29.tar.bz2
Adds an interface between WorkspaceController and
WorkspaceManager. This will allow introducing different behavior. BUG=137342 TEST=none R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10827377 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151939 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp1
-rw-r--r--ash/wm/stacking_controller.cc3
-rw-r--r--ash/wm/workspace/base_workspace_manager.h50
-rw-r--r--ash/wm/workspace/workspace_manager.cc62
-rw-r--r--ash/wm/workspace/workspace_manager.h42
-rw-r--r--ash/wm/workspace_controller.cc25
-rw-r--r--ash/wm/workspace_controller.h10
7 files changed, 129 insertions, 64 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 36764d9..0c58a10 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -330,6 +330,7 @@
'wm/window_util.h',
'wm/workspace_controller.cc',
'wm/workspace_controller.h',
+ 'wm/workspace/base_workspace_manager.h',
'wm/workspace/frame_maximize_button.cc',
'wm/workspace/frame_maximize_button.h',
'wm/workspace/managed_workspace.cc',
diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc
index 73b30f2..6b06e4e 100644
--- a/ash/wm/stacking_controller.cc
+++ b/ash/wm/stacking_controller.cc
@@ -141,8 +141,7 @@ aura::Window* StackingController::GetSystemModalContainer(
// TODO(oshima): Remove this once extended desktop is on by default.
internal::AlwaysOnTopController*
-StackingController::GetAlwaysOnTopController(
- aura::RootWindow* root_window) {
+StackingController::GetAlwaysOnTopController(aura::RootWindow* root_window) {
internal::AlwaysOnTopController* controller =
root_window->GetProperty(internal::kAlwaysOnTopControllerKey);
if (!controller) {
diff --git a/ash/wm/workspace/base_workspace_manager.h b/ash/wm/workspace/base_workspace_manager.h
new file mode 100644
index 0000000..bce6650
--- /dev/null
+++ b/ash/wm/workspace/base_workspace_manager.h
@@ -0,0 +1,50 @@
+// 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.
+
+#ifndef ASH_WM_WORKSPACE_BASE_WORKSPACE_MANAGER_H_
+#define ASH_WM_WORKSPACE_BASE_WORKSPACE_MANAGER_H_
+
+#include "ash/ash_export.h"
+#include "ash/wm/workspace/workspace_types.h"
+
+namespace aura {
+class Window;
+}
+
+namespace ash {
+namespace internal {
+
+class ShelfLayoutManager;
+
+// TODO: this is temporary until WorkspaceManager2 is the default.
+class ASH_EXPORT BaseWorkspaceManager {
+ public:
+ virtual ~BaseWorkspaceManager() {}
+
+ // Returns true if in maximized or fullscreen mode.
+ virtual bool IsInMaximizedMode() const = 0;
+
+ // Sets the size of the grid. Newly added windows are forced to align to the
+ // size of the grid.
+ virtual void SetGridSize(int size) = 0;
+ virtual int GetGridSize() const = 0;
+
+ // Returns the current window state.
+ virtual WorkspaceWindowState GetWindowState() const = 0;
+
+ virtual void SetShelf(ShelfLayoutManager* shelf) = 0;
+
+ // Activates the workspace containing |window|. Does nothing if |window| is
+ // NULL or not contained in a workspace.
+ virtual void SetActiveWorkspaceByWindow(aura::Window* window) = 0;
+
+ // Returns the parent for |window|. This is invoked from StackingController
+ // when a new Window is being added.
+ virtual aura::Window* GetParentForNewWindow(aura::Window* window) = 0;
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_WM_WORKSPACE_BASE_WORKSPACE_MANAGER_H_
diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc
index db799c4..42d6d78 100644
--- a/ash/wm/workspace/workspace_manager.cc
+++ b/ash/wm/workspace/workspace_manager.cc
@@ -79,11 +79,6 @@ bool WorkspaceManager::Contains(aura::Window* window) const {
return FindBy(window) != NULL;
}
-bool WorkspaceManager::IsInMaximizedMode() const {
- return active_workspace_ &&
- active_workspace_->type() == Workspace::TYPE_MAXIMIZED;
-}
-
void WorkspaceManager::AddWindow(aura::Window* window) {
DCHECK(ShouldManageWindow(window));
@@ -128,19 +123,37 @@ void WorkspaceManager::RemoveWindow(aura::Window* window) {
CleanupWorkspace(workspace);
}
-void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
+void WorkspaceManager::UpdateShelfVisibility() {
+ if (shelf_)
+ shelf_->UpdateVisibilityState();
+}
+
+void WorkspaceManager::ShowStateChanged(aura::Window* window) {
Workspace* workspace = FindBy(window);
- if (workspace)
- workspace->Activate();
+ if (!workspace)
+ return;
+ if (!ShouldManageWindow(window)) {
+ RemoveWindow(window);
+ } else {
+ Workspace::Type old_type = workspace->type();
+ Workspace::Type new_type = Workspace::TypeForWindow(window);
+ if (new_type != old_type)
+ OnTypeOfWorkspacedNeededChanged(window);
+ }
+ UpdateShelfVisibility();
+}
+
+bool WorkspaceManager::IsInMaximizedMode() const {
+ return active_workspace_ &&
+ active_workspace_->type() == Workspace::TYPE_MAXIMIZED;
}
-void WorkspaceManager::SetGridSize(int grid_size) {
- grid_size_ = grid_size;
+void WorkspaceManager::SetGridSize(int size) {
+ grid_size_ = size;
}
-void WorkspaceManager::UpdateShelfVisibility() {
- if (shelf_)
- shelf_->UpdateVisibilityState();
+int WorkspaceManager::GetGridSize() const {
+ return grid_size_;
}
WorkspaceWindowState WorkspaceManager::GetWindowState() const {
@@ -175,19 +188,18 @@ WorkspaceWindowState WorkspaceManager::GetWindowState() const {
WORKSPACE_WINDOW_STATE_DEFAULT;
}
-void WorkspaceManager::ShowStateChanged(aura::Window* window) {
+void WorkspaceManager::SetShelf(ShelfLayoutManager* shelf) {
+ shelf_ = shelf;
+}
+
+void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
Workspace* workspace = FindBy(window);
- if (!workspace)
- return;
- if (!ShouldManageWindow(window)) {
- RemoveWindow(window);
- } else {
- Workspace::Type old_type = workspace->type();
- Workspace::Type new_type = Workspace::TypeForWindow(window);
- if (new_type != old_type)
- OnTypeOfWorkspacedNeededChanged(window);
- }
- UpdateShelfVisibility();
+ if (workspace)
+ workspace->Activate();
+}
+
+aura::Window* WorkspaceManager::GetParentForNewWindow(aura::Window* window) {
+ return contents_view_;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h
index 67a6068..624fc7e 100644
--- a/ash/wm/workspace/workspace_manager.h
+++ b/ash/wm/workspace/workspace_manager.h
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_WM_WORKSPACE_MANAGER_H_
-#define ASH_WM_WORKSPACE_MANAGER_H_
+#ifndef ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_
+#define ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_
#include <vector>
#include "ash/ash_export.h"
+#include "ash/wm/workspace/base_workspace_manager.h"
#include "ash/wm/workspace/workspace.h"
#include "ash/wm/workspace/workspace_types.h"
#include "base/basictypes.h"
@@ -31,7 +32,7 @@ class ShelfLayoutManager;
class WorkspaceManagerTest;
// WorkspaceManager manages multiple workspaces in the desktop.
-class ASH_EXPORT WorkspaceManager {
+class ASH_EXPORT WorkspaceManager : public BaseWorkspaceManager {
public:
explicit WorkspaceManager(aura::Window* viewport);
virtual ~WorkspaceManager();
@@ -43,43 +44,28 @@ class ASH_EXPORT WorkspaceManager {
// Returns true if |window| has been added to this WorkspaceManager.
bool Contains(aura::Window* window) const;
- // Returns true if in maximized or fullscreen mode.
- bool IsInMaximizedMode() const;
-
// Adds/removes a window creating/destroying workspace as necessary.
void AddWindow(aura::Window* window);
void RemoveWindow(aura::Window* window);
- // Activates the workspace containing |window|. Does nothing if |window| is
- // NULL or not contained in a workspace.
- void SetActiveWorkspaceByWindow(aura::Window* window);
-
// Returns the Window this WorkspaceManager controls.
aura::Window* contents_view() { return contents_view_; }
- // Returns the window for rotate operation based on the |location|.
- // TODO: this isn't currently used; remove if we do away with overview.
- aura::Window* FindRotateWindowForLocation(const gfx::Point& location);
-
- // Returns the bounds in which a window can be moved/resized.
- gfx::Rect GetDragAreaBounds();
-
- // Sets the size of the grid. Newly added windows are forced to align to the
- // size of the grid.
- void SetGridSize(int grid_size);
- int grid_size() const { return grid_size_; }
-
- void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; }
-
// Updates the visibility and whether any windows overlap the shelf.
void UpdateShelfVisibility();
- // Returns the current window state.
- WorkspaceWindowState GetWindowState() const;
-
// Invoked when the show state of the specified window changes.
void ShowStateChanged(aura::Window* window);
+ // BaseWorkspaceManager overrides:
+ virtual bool IsInMaximizedMode() const OVERRIDE;
+ virtual void SetGridSize(int size) OVERRIDE;
+ virtual int GetGridSize() const OVERRIDE;
+ virtual WorkspaceWindowState GetWindowState() const OVERRIDE;
+ virtual void SetShelf(ShelfLayoutManager* shelf) OVERRIDE;
+ virtual void SetActiveWorkspaceByWindow(aura::Window* window) OVERRIDE;
+ virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE;
+
private:
// Enumeration of whether windows should animate or not.
enum AnimateChangeType {
@@ -157,4 +143,4 @@ class ASH_EXPORT WorkspaceManager {
} // namespace internal
} // namespace ash
-#endif // ASH_WM_WORKSPACE_MANAGER_H_
+#endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_
diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc
index 765daeb..0592513 100644
--- a/ash/wm/workspace_controller.cc
+++ b/ash/wm/workspace_controller.cc
@@ -25,14 +25,14 @@ const int kGridSize = 16;
WorkspaceController::WorkspaceController(aura::Window* viewport)
: viewport_(viewport),
- workspace_manager_(new WorkspaceManager(viewport)),
layout_manager_(NULL),
event_filter_(NULL) {
aura::RootWindow* root_window = viewport->GetRootWindow();
event_filter_ = new WorkspaceEventFilter(viewport);
viewport->SetEventFilter(event_filter_);
- layout_manager_ = new WorkspaceLayoutManager(
- root_window, workspace_manager_.get());
+ WorkspaceManager* workspace_manager = new WorkspaceManager(viewport);
+ workspace_manager_.reset(workspace_manager);
+ layout_manager_ = new WorkspaceLayoutManager(root_window, workspace_manager);
viewport->SetLayoutManager(layout_manager_);
aura::client::GetActivationClient(root_window)->AddObserver(this);
SetGridSize(kGridSize);
@@ -52,11 +52,12 @@ bool WorkspaceController::IsInMaximizedMode() const {
void WorkspaceController::SetGridSize(int grid_size) {
workspace_manager_->SetGridSize(grid_size);
- event_filter_->set_grid_size(grid_size);
+ if (event_filter_)
+ event_filter_->set_grid_size(grid_size);
}
int WorkspaceController::GetGridSize() const {
- return workspace_manager_->grid_size();
+ return workspace_manager_->GetGridSize();
}
WorkspaceWindowState WorkspaceController::GetWindowState() const {
@@ -64,12 +65,22 @@ WorkspaceWindowState WorkspaceController::GetWindowState() const {
}
void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) {
- workspace_manager_->set_shelf(shelf);
+ workspace_manager_->SetShelf(shelf);
}
+void WorkspaceController::SetActiveWorkspaceByWindow(aura::Window* window) {
+ return workspace_manager_->SetActiveWorkspaceByWindow(window);
+}
+
+aura::Window* WorkspaceController::GetParentForNewWindow(aura::Window* window) {
+ return workspace_manager_->GetParentForNewWindow(window);
+}
+
+
void WorkspaceController::OnWindowActivated(aura::Window* window,
aura::Window* old_active) {
- workspace_manager_->SetActiveWorkspaceByWindow(window);
+ if (!window || window->GetRootWindow() == viewport_->GetRootWindow())
+ workspace_manager_->SetActiveWorkspaceByWindow(window);
}
} // namespace internal
diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h
index ea7710e..d7f7b6b 100644
--- a/ash/wm/workspace_controller.h
+++ b/ash/wm/workspace_controller.h
@@ -18,11 +18,11 @@ class Window;
namespace ash {
namespace internal {
+class BaseWorkspaceManager;
class ShelfLayoutManager;
class WorkspaceControllerTestHelper;
class WorkspaceEventFilter;
class WorkspaceLayoutManager;
-class WorkspaceManager;
// WorkspaceController acts as a central place that ties together all the
// various workspace pieces: WorkspaceManager, WorkspaceLayoutManager and
@@ -45,6 +45,12 @@ class ASH_EXPORT WorkspaceController
void SetShelf(ShelfLayoutManager* shelf);
+ // Sets the active workspace based on |window|.
+ void SetActiveWorkspaceByWindow(aura::Window* window);
+
+ // See description in BaseWorkspaceManager::GetParentForNewWindow().
+ aura::Window* GetParentForNewWindow(aura::Window* window);
+
// aura::client::ActivationChangeObserver overrides:
virtual void OnWindowActivated(aura::Window* window,
aura::Window* old_active) OVERRIDE;
@@ -54,7 +60,7 @@ class ASH_EXPORT WorkspaceController
aura::Window* viewport_;
- scoped_ptr<WorkspaceManager> workspace_manager_;
+ scoped_ptr<BaseWorkspaceManager> workspace_manager_;
// Owned by the window its attached to.
WorkspaceLayoutManager* layout_manager_;