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

Unified Diff: ash/wm/workspace/workspace_manager.h

Issue 9113045: Reworks the workspace code. Here's the new heuristics: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged and all that good stuff. Created 8 years, 11 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/workspace_layout_manager_unittest.cc ('k') | ash/wm/workspace/workspace_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_manager.h
diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h
index 99560e94643da9e141158b32ca069d9814e4fd0e..055893e1f0095bceeaf4414551e28a4d33289ec7 100644
--- a/ash/wm/workspace/workspace_manager.h
+++ b/ash/wm/workspace/workspace_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -9,8 +9,8 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/observer_list.h"
#include "ash/ash_export.h"
+#include "ui/aura/window_observer.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/size.h"
@@ -26,34 +26,32 @@ class Rect;
namespace ash {
namespace internal {
class Workspace;
-class WorkspaceObserver;
+class WorkspaceManagerTest;
// WorkspaceManager manages multiple workspaces in the desktop.
-class ASH_EXPORT WorkspaceManager {
+class ASH_EXPORT WorkspaceManager : public aura::WindowObserver{
public:
explicit WorkspaceManager(aura::Window* viewport);
virtual ~WorkspaceManager();
- // Returns the Window this WorkspaceManager controls.
- aura::Window* contents_view() { return contents_view_; }
+ // Returns true if |window| should be managed by the WorkspaceManager.
+ bool IsManagedWindow(aura::Window* window) const;
- // Create new workspace. Workspace objects are managed by
- // this WorkspaceManager. Deleting workspace will automatically
- // remove the workspace from the workspace_manager.
- Workspace* CreateWorkspace();
+ // Adds/removes a window creating/destroying workspace as necessary.
+ void AddWindow(aura::Window* window);
+ void RemoveWindow(aura::Window* window);
- // Returns the active workspace.
- Workspace* GetActiveWorkspace() const;
+ // Activates the workspace containing |window|. Does nothing if |window| is
+ // NULL or not contained in a workspace.
+ void SetActiveWorkspaceByWindow(aura::Window* window);
- // Returns the workspace that contanis the |window|.
- Workspace* FindBy(aura::Window* window) const;
+ // 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);
- // Sets the bounds of all workspaces.
- void LayoutWorkspaces();
-
// Returns the bounds in which a window can be moved/resized.
gfx::Rect GetDragAreaBounds();
@@ -61,25 +59,9 @@ class ASH_EXPORT WorkspaceManager {
void SetOverview(bool overview);
bool is_overview() const { return is_overview_; }
- // Rotate windows by moving |source| window to the position of |target|.
- void RotateWindows(aura::Window* source, aura::Window* target);
-
// Sets the size of a single workspace (all workspaces have the same size).
void SetWorkspaceSize(const gfx::Size& workspace_size);
- // Adds/Removes workspace observer.
- void AddObserver(WorkspaceObserver* observer);
- void RemoveObserver(WorkspaceObserver* observer);
-
- // Returns true if this workspace manager is laying out windows.
- // When true, LayoutManager must give windows their requested bounds.
- bool layout_in_progress() const { return layout_in_progress_; }
-
- // Sets the |layout_in_progress_| flag.
- void set_layout_in_progress(bool layout_in_progress) {
- layout_in_progress_ = layout_in_progress;
- }
-
// Sets/Returns the ignored window that the workspace manager does not
// set bounds on.
void set_ignored_window(aura::Window* ignored_window) {
@@ -87,23 +69,47 @@ class ASH_EXPORT WorkspaceManager {
}
aura::Window* ignored_window() { return ignored_window_; }
+ // Overriden from aura::WindowObserver:
+ virtual void OnWindowPropertyChanged(aura::Window* window,
+ const char* name,
+ void* old) OVERRIDE;
+
private:
friend class Workspace;
+ friend class WorkspaceManagerTest;
void AddWorkspace(Workspace* workspace);
void RemoveWorkspace(Workspace* workspace);
+ // Returns the active workspace.
+ Workspace* GetActiveWorkspace() const;
+
+ // Returns the workspace that contanis the |window|.
+ Workspace* FindBy(aura::Window* window) const;
+
// Sets the active workspace.
void SetActiveWorkspace(Workspace* workspace);
- // Returns the bounds of the work are given |workspace_bounds|.
- gfx::Rect GetWorkAreaBounds(const gfx::Rect& workspace_bounds);
+ // Returns the bounds of the work area.
+ gfx::Rect GetWorkAreaBounds();
// Returns the index of the workspace that contains the |window|.
int GetWorkspaceIndexContaining(aura::Window* window) const;
- // Update contents_view size and move the viewport to the active workspace.
- void UpdateContentsView();
+ // Sets the bounds of |window|. This sets |ignored_window_| to |window| so
+ // that the bounds change is allowed through.
+ void SetWindowBounds(aura::Window* window, const gfx::Rect& bounds);
+
+ // Resets the bounds of |window| to its restored bounds (if set), ensuring
+ // it fits in the the windows current workspace.
+ void SetWindowBoundsFromRestoreBounds(aura::Window* window);
+
+ // Invoked when the maximized state of |window| changes.
+ void MaximizedStateChanged(aura::Window* window);
+
+ // Returns the Workspace whose type is TYPE_NORMAL, or NULL if there isn't
+ // one.
+ Workspace* GetNormalWorkspace();
aura::Window* contents_view_;
@@ -118,14 +124,9 @@ class ASH_EXPORT WorkspaceManager {
// True if the workspace manager is in overview mode.
bool is_overview_;
- // True if this layout manager is laying out windows.
- bool layout_in_progress_;
-
// The window that WorkspaceManager does not set the bounds on.
aura::Window* ignored_window_;
- ObserverList<WorkspaceObserver> observers_;
-
DISALLOW_COPY_AND_ASSIGN(WorkspaceManager);
};
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager_unittest.cc ('k') | ash/wm/workspace/workspace_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698