Commit de99a643 authored by oshima@google.com's avatar oshima@google.com

Drag and rotate windows between/within workspaces

BUG=none
TEST=new tests in workspace_manager_unittests

Review URL: http://codereview.chromium.org/8391035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107643 0039d316-1c4b-4281-b951-d872f2087c98
parent 1efc51c6
...@@ -26,6 +26,10 @@ bool DefaultContainerEventFilter::PreHandleMouseEvent(aura::Window* target, ...@@ -26,6 +26,10 @@ bool DefaultContainerEventFilter::PreHandleMouseEvent(aura::Window* target,
static_cast<DefaultContainerLayoutManager*>(owner()->layout_manager()); static_cast<DefaultContainerLayoutManager*>(owner()->layout_manager());
DCHECK(layout_manager); DCHECK(layout_manager);
// TODO(oshima|derat): Move ToplevelWindowEventFilter to the shell,
// incorporate the logic below and intorduce DragObserver (or something
// similar) to decouple DCLM.
// Notify layout manager that drag event may move/resize the target wnidow. // Notify layout manager that drag event may move/resize the target wnidow.
if (event->type() == ui::ET_MOUSE_DRAGGED && drag_state_ == DRAG_NONE) if (event->type() == ui::ET_MOUSE_DRAGGED && drag_state_ == DRAG_NONE)
layout_manager->PrepareForMoveOrResize(target, event); layout_manager->PrepareForMoveOrResize(target, event);
...@@ -36,8 +40,21 @@ bool DefaultContainerEventFilter::PreHandleMouseEvent(aura::Window* target, ...@@ -36,8 +40,21 @@ bool DefaultContainerEventFilter::PreHandleMouseEvent(aura::Window* target,
case ui::ET_MOUSE_DRAGGED: case ui::ET_MOUSE_DRAGGED:
// Cancel move/resize if the event wasn't handled, or // Cancel move/resize if the event wasn't handled, or
// drag_state_ didn't move to MOVE or RESIZE. // drag_state_ didn't move to MOVE or RESIZE.
if (!handled || (drag_state_ == DRAG_NONE && !UpdateDragState())) if (handled) {
switch (drag_state_) {
case DRAG_NONE:
if (!UpdateDragState())
layout_manager->CancelMoveOrResize(target, event);
break;
case DRAG_MOVE:
layout_manager->ProcessMove(target, event);
break;
case DRAG_RESIZE:
break;
}
} else {
layout_manager->CancelMoveOrResize(target, event); layout_manager->CancelMoveOrResize(target, event);
}
break; break;
case ui::ET_MOUSE_RELEASED: case ui::ET_MOUSE_RELEASED:
if (drag_state_ == DRAG_MOVE) if (drag_state_ == DRAG_MOVE)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "ui/aura/desktop.h" #include "ui/aura/desktop.h"
#include "ui/aura/event.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/screen_aura.h" #include "ui/aura/screen_aura.h"
#include "ui/aura/window_types.h" #include "ui/aura/window_types.h"
...@@ -44,6 +45,29 @@ void DefaultContainerLayoutManager::CancelMoveOrResize( ...@@ -44,6 +45,29 @@ void DefaultContainerLayoutManager::CancelMoveOrResize(
drag_window_ = NULL; drag_window_ = NULL;
} }
void DefaultContainerLayoutManager::ProcessMove(
aura::Window* drag,
aura::MouseEvent* event) {
AutoReset<bool> reset(&ignore_calculate_bounds_, true);
// TODO(oshima): Just zooming out may (and will) move/swap window without
// a users's intent. We probably should scroll viewport, but that may not
// be enough. See crbug.com/101826 for more discussion.
workspace_manager_->SetOverview(true);
gfx::Point point_in_owner = event->location();
aura::Window::ConvertPointToWindow(
drag,
owner_,
&point_in_owner);
// TODO(oshima): We should support simply moving to another
// workspace when the destination workspace has enough room to accomodate.
aura::Window* rotate_target =
workspace_manager_->FindRotateWindowForLocation(point_in_owner);
if (rotate_target)
workspace_manager_->RotateWindows(drag, rotate_target);
}
void DefaultContainerLayoutManager::EndMove( void DefaultContainerLayoutManager::EndMove(
aura::Window* drag, aura::Window* drag,
aura::MouseEvent* evnet) { aura::MouseEvent* evnet) {
...@@ -52,7 +76,8 @@ void DefaultContainerLayoutManager::EndMove( ...@@ -52,7 +76,8 @@ void DefaultContainerLayoutManager::EndMove(
drag_window_ = NULL; drag_window_ = NULL;
Workspace* workspace = workspace_manager_->GetActiveWorkspace(); Workspace* workspace = workspace_manager_->GetActiveWorkspace();
if (workspace) if (workspace)
workspace->Layout(NULL); workspace->Layout(NULL, NULL);
workspace_manager_->SetOverview(false);
} }
void DefaultContainerLayoutManager::EndResize( void DefaultContainerLayoutManager::EndResize(
...@@ -62,7 +87,8 @@ void DefaultContainerLayoutManager::EndResize( ...@@ -62,7 +87,8 @@ void DefaultContainerLayoutManager::EndResize(
drag_window_ = NULL; drag_window_ = NULL;
Workspace* workspace = workspace_manager_->GetActiveWorkspace(); Workspace* workspace = workspace_manager_->GetActiveWorkspace();
if (workspace) if (workspace)
workspace->Layout(NULL); workspace->Layout(NULL, NULL);
workspace_manager_->SetOverview(false);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -39,6 +39,9 @@ class AURA_SHELL_EXPORT DefaultContainerLayoutManager ...@@ -39,6 +39,9 @@ class AURA_SHELL_EXPORT DefaultContainerLayoutManager
// Invoked when a drag event didn't start any drag operation. // Invoked when a drag event didn't start any drag operation.
void CancelMoveOrResize(aura::Window* drag, aura::MouseEvent* event); void CancelMoveOrResize(aura::Window* drag, aura::MouseEvent* event);
// Invoked when a drag event moved the |window|.
void ProcessMove(aura::Window* window, aura::MouseEvent* event);
// Invoked when a user finished moving window. // Invoked when a user finished moving window.
void EndMove(aura::Window* drag, aura::MouseEvent* evnet); void EndMove(aura::Window* drag, aura::MouseEvent* evnet);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/aura_shell/workspace/workspace.h" #include "ui/aura_shell/workspace/workspace.h"
#include "base/logging.h" #include "base/logging.h"
#include "ui/aura/desktop.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura_shell/workspace/workspace_manager.h" #include "ui/aura_shell/workspace/workspace_manager.h"
#include "ui/gfx/compositor/layer.h" #include "ui/gfx/compositor/layer.h"
...@@ -12,6 +13,9 @@ ...@@ -12,6 +13,9 @@
namespace { namespace {
// Horizontal margin between windows. // Horizontal margin between windows.
const int kWindowHorizontalMargin = 10; const int kWindowHorizontalMargin = 10;
// Maximum number of windows a workspace can have.
size_t g_max_windows_per_workspace = 2;
} }
namespace aura_shell { namespace aura_shell {
...@@ -29,7 +33,7 @@ void Workspace::SetBounds(const gfx::Rect& bounds) { ...@@ -29,7 +33,7 @@ void Workspace::SetBounds(const gfx::Rect& bounds) {
bool bounds_changed = bounds_ != bounds; bool bounds_changed = bounds_ != bounds;
bounds_ = bounds; bounds_ = bounds;
if (bounds_changed) if (bounds_changed)
Layout(NULL); Layout(NULL, NULL);
} }
gfx::Rect Workspace::GetWorkAreaBounds() const { gfx::Rect Workspace::GetWorkAreaBounds() const {
...@@ -49,7 +53,7 @@ bool Workspace::AddWindowAfter(aura::Window* window, aura::Window* after) { ...@@ -49,7 +53,7 @@ bool Workspace::AddWindowAfter(aura::Window* window, aura::Window* after) {
std::find(windows_.begin(), windows_.end(), after); std::find(windows_.begin(), windows_.end(), after);
windows_.insert(++i, window); windows_.insert(++i, window);
} }
Layout(window); Layout(NULL, window);
return true; return true;
} }
...@@ -57,45 +61,124 @@ bool Workspace::AddWindowAfter(aura::Window* window, aura::Window* after) { ...@@ -57,45 +61,124 @@ bool Workspace::AddWindowAfter(aura::Window* window, aura::Window* after) {
void Workspace::RemoveWindow(aura::Window* window) { void Workspace::RemoveWindow(aura::Window* window) {
DCHECK(Contains(window)); DCHECK(Contains(window));
windows_.erase(std::find(windows_.begin(), windows_.end(), window)); windows_.erase(std::find(windows_.begin(), windows_.end(), window));
Layout(NULL); Layout(NULL, NULL);
} }
bool Workspace::Contains(aura::Window* window) const { bool Workspace::Contains(aura::Window* window) const {
return std::find(windows_.begin(), windows_.end(), window) != windows_.end(); return std::find(windows_.begin(), windows_.end(), window) != windows_.end();
} }
aura::Window* Workspace::FindRotateWindowForLocation(
const gfx::Point& position) {
aura::Window* active = aura::Desktop::GetInstance()->active_window();
if (GetTotalWindowsWidth() < bounds_.width()) {
// If all windows fit to the width of the workspace, it returns the
// window which contains |position|'s x coordinate.
for (aura::Window::Windows::const_iterator i = windows_.begin();
i != windows_.end();
++i) {
if (active == *i)
continue;
gfx::Rect bounds = (*i)->GetTargetBounds();
if (bounds.x() < position.x() && position.x() < bounds.right())
return *i;
}
} else if (bounds_.x() < position.x() && position.x() < bounds_.right()) {
// If windows are overlapping, it divides the workspace into
// regions with the same width, and returns the Nth window that
// corresponds to the region that contains the |position|.
int width = bounds_.width() / windows_.size();
size_t index = (position.x() - bounds_.x()) / width;
DCHECK(index < windows_.size());
aura::Window* window = windows_[index];
if (window != active)
return window;
}
return NULL;
}
void Workspace::RotateWindows(aura::Window* source, aura::Window* target) {
DCHECK(Contains(source));
DCHECK(Contains(target));
aura::Window::Windows::iterator source_iter =
std::find(windows_.begin(), windows_.end(), source);
aura::Window::Windows::iterator target_iter =
std::find(windows_.begin(), windows_.end(), target);
DCHECK(source_iter != target_iter);
if (source_iter < target_iter)
std::rotate(source_iter, source_iter + 1, target_iter + 1);
else
std::rotate(target_iter, source_iter, source_iter + 1);
Layout(source, NULL);
}
aura::Window* Workspace::ShiftWindows(aura::Window* insert,
aura::Window* until,
aura::Window* target,
ShiftDirection direction) {
DCHECK(until);
DCHECK(!Contains(insert));
bool shift_reached_until = GetIndexOf(until) >= 0;
if (shift_reached_until)
RemoveWindow(until);
aura::Window* pushed = NULL;
if (direction == SHIFT_TO_RIGHT) {
aura::Window::Windows::iterator iter =
std::find(windows_.begin(), windows_.end(), target);
// Insert at |target| position, or at the begining.
if (iter == windows_.end())
iter = windows_.begin();
windows_.insert(iter, insert);
if (!shift_reached_until) {
pushed = windows_.back();
windows_.erase(--windows_.end());
}
} else {
aura::Window::Windows::iterator iter =
std::find(windows_.begin(), windows_.end(), target);
// Insert after |target|, or at the end.
if (iter != windows_.end())
++iter;
windows_.insert(iter, insert);
if (!shift_reached_until) {
pushed = windows_.front();
windows_.erase(windows_.begin());
}
}
Layout(shift_reached_until ? until : NULL, NULL);
return pushed;
}
void Workspace::Activate() { void Workspace::Activate() {
workspace_manager_->SetActiveWorkspace(this); workspace_manager_->SetActiveWorkspace(this);
} }
void Workspace::Layout(aura::Window* no_animation) { void Workspace::Layout(aura::Window* ignore, aura::Window* no_animation) {
gfx::Rect work_area = workspace_manager_->GetWorkAreaBounds(bounds_); gfx::Rect work_area = workspace_manager_->GetWorkAreaBounds(bounds_);
int total_width = 0; int total_width = GetTotalWindowsWidth();
for (aura::Window::Windows::const_iterator i = windows_.begin();
i != windows_.end();
++i) {
if (total_width)
total_width += kWindowHorizontalMargin;
// TODO(oshima): use restored bounds.
total_width += (*i)->bounds().width();
}
if (total_width < work_area.width()) { if (total_width < work_area.width()) {
int dx = (work_area.width() - total_width) / 2; int dx = (work_area.width() - total_width) / 2;
for (aura::Window::Windows::iterator i = windows_.begin(); for (aura::Window::Windows::iterator i = windows_.begin();
i != windows_.end(); i != windows_.end();
++i) { ++i) {
MoveWindowTo(*i, if (*i != ignore) {
gfx::Point(work_area.x() + dx, work_area.y()), MoveWindowTo(*i,
no_animation != *i); gfx::Point(work_area.x() + dx, work_area.y()),
no_animation != *i);
}
dx += (*i)->bounds().width() + kWindowHorizontalMargin; dx += (*i)->bounds().width() + kWindowHorizontalMargin;
} }
} else { } else {
DCHECK_LT(windows_.size(), 3U); DCHECK_LT(windows_.size(), 3U);
// TODO(oshima): Figure out general algorithm to layout more than // TODO(oshima): This is messy. Figure out general algorithm to
// 2 windows. // layout more than 2 windows.
MoveWindowTo(windows_[0], work_area.origin(), no_animation != windows_[0]); if (windows_[0] != ignore) {
if (windows_.size() == 2) { MoveWindowTo(windows_[0],
work_area.origin(),
no_animation != windows_[0]);
}
if (windows_.size() == 2 && windows_[1] != ignore) {
MoveWindowTo(windows_[1], MoveWindowTo(windows_[1],
gfx::Point(work_area.right() - windows_[1]->bounds().width(), gfx::Point(work_area.right() - windows_[1]->bounds().width(),
work_area.y()), work_area.y()),
...@@ -114,7 +197,7 @@ bool Workspace::CanAdd(aura::Window* window) const { ...@@ -114,7 +197,7 @@ bool Workspace::CanAdd(aura::Window* window) const {
// TODO(oshima): This should be based on available space and the // TODO(oshima): This should be based on available space and the
// size of the |window|. // size of the |window|.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return windows_.size() < 2; return windows_.size() < g_max_windows_per_workspace;
} }
void Workspace::MoveWindowTo( void Workspace::MoveWindowTo(
...@@ -134,4 +217,24 @@ void Workspace::MoveWindowTo( ...@@ -134,4 +217,24 @@ void Workspace::MoveWindowTo(
} }
} }
int Workspace::GetTotalWindowsWidth() const {
int total_width = 0;
for (aura::Window::Windows::const_iterator i = windows_.begin();
i != windows_.end();
++i) {
if (total_width)
total_width += kWindowHorizontalMargin;
// TODO(oshima): use restored bounds.
total_width += (*i)->bounds().width();
}
return total_width;
}
// static
size_t Workspace::SetMaxWindowsCount(size_t max) {
int old = g_max_windows_per_workspace;
g_max_windows_per_workspace = max;
return old;
}
} // namespace aura_shell } // namespace aura_shell
...@@ -32,6 +32,12 @@ class AURA_SHELL_EXPORT Workspace { ...@@ -32,6 +32,12 @@ class AURA_SHELL_EXPORT Workspace {
explicit Workspace(WorkspaceManager* manager); explicit Workspace(WorkspaceManager* manager);
virtual ~Workspace(); virtual ~Workspace();
// Specifies the direction to shift windows in |ShiftWindows()|.
enum ShiftDirection {
SHIFT_TO_RIGHT,
SHIFT_TO_LEFT
};
// Returns true if this workspace has no windows. // Returns true if this workspace has no windows.
bool is_empty() const { return windows_.empty(); } bool is_empty() const { return windows_.empty(); }
...@@ -49,23 +55,48 @@ class AURA_SHELL_EXPORT Workspace { ...@@ -49,23 +55,48 @@ class AURA_SHELL_EXPORT Workspace {
// failed. // failed.
bool AddWindowAfter(aura::Window* window, aura::Window* after); bool AddWindowAfter(aura::Window* window, aura::Window* after);
// Removes the |window| from this workspace. // Removes |window| from this workspace.
void RemoveWindow(aura::Window* window); void RemoveWindow(aura::Window* window);
// Return true if this workspace has the |window|. // Return true if this workspace has |window|.
bool Contains(aura::Window* window) const; bool Contains(aura::Window* window) const;
// Returns a window to rotate to based on |position|.
aura::Window* FindRotateWindowForLocation(const gfx::Point& position);
// Rotates the windows by removing |source| and inserting it to the
// position that |target| was in. It re-layouts windows except for |source|.
void RotateWindows(aura::Window* source, aura::Window* target);
// Shift the windows in the workspace by inserting |window| until it
// reaches |until|. If |direction| is |SHIFT_TO_RIGHT|, |insert| is
// inserted at the position of |target| or at the beginning if
// |target| is NULL. If |direction| is |SHIFT_TO_LEFT|, |insert| is
// inserted after the position of |target|, or at the end if
// |target| is NULL. It returns the window that is overflowed by
// shifting, or NULL if shifting stopped at |until|.
aura::Window* ShiftWindows(aura::Window* insert,
aura::Window* until,
aura::Window* target,
ShiftDirection direction);
// Activates this workspace. // Activates this workspace.
void Activate(); void Activate();
// Layout windows. Moving animation is applied to all windows except // Layout windows. The workspace doesn't set bounds on |ignore| if it's
// for the window specified by |no_animation|. // given. It still uses |ignore| window's bounds to calculate
void Layout(aura::Window* no_animation); // bounds for other windows. Moving animation is applied to all
// windows except for the window specified by |no_animation| and |ignore|.
void Layout(aura::Window* ignore, aura::Window* no_animation);
private: private:
FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, WorkspaceBasic); FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, WorkspaceBasic);
FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, RotateWindows);
FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, ShiftWindowsSingle);
FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, ShiftWindowsMultiple);
FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, RotateWindows);
// Returns the index in layout order of the |window| in this workspace. // Returns the index in layout order of |window| in this workspace.
int GetIndexOf(aura::Window* window) const; int GetIndexOf(aura::Window* window) const;
// Returns true if the given |window| can be added to this workspace. // Returns true if the given |window| can be added to this workspace.
...@@ -77,6 +108,14 @@ class AURA_SHELL_EXPORT Workspace { ...@@ -77,6 +108,14 @@ class AURA_SHELL_EXPORT Workspace {
const gfx::Point& origin, const gfx::Point& origin,
bool animate); bool animate);
// Returns the sum of all window's width.
int GetTotalWindowsWidth() const;
// Test only: Changes how may windows workspace can have.
// Returns the current value so that it can be reverted back to
// original value.
static size_t SetMaxWindowsCount(size_t max);
WorkspaceManager* workspace_manager_; WorkspaceManager* workspace_manager_;
gfx::Rect bounds_; gfx::Rect bounds_;
......
...@@ -60,11 +60,18 @@ Workspace* WorkspaceManager::GetActiveWorkspace() const { ...@@ -60,11 +60,18 @@ Workspace* WorkspaceManager::GetActiveWorkspace() const {
} }
Workspace* WorkspaceManager::FindBy(aura::Window* window) const { Workspace* WorkspaceManager::FindBy(aura::Window* window) const {
int index = GetWorkspaceIndexContaining(window);
return index < 0 ? NULL : workspaces_[index];
}
aura::Window* WorkspaceManager::FindRotateWindowForLocation(
const gfx::Point& point) {
for (Workspaces::const_iterator i = workspaces_.begin(); for (Workspaces::const_iterator i = workspaces_.begin();
i != workspaces_.end(); i != workspaces_.end();
++i) { ++i) {
if ((*i)->Contains(window)) aura::Window* window = (*i)->FindRotateWindowForLocation(point);
return *i; if (window)
return window;
} }
return NULL; return NULL;
} }
...@@ -128,6 +135,36 @@ void WorkspaceManager::SetOverview(bool overview) { ...@@ -128,6 +135,36 @@ void WorkspaceManager::SetOverview(bool overview) {
viewport_->layer()->SetTransform(transform); viewport_->layer()->SetTransform(transform);
} }
void WorkspaceManager::RotateWindows(aura::Window* source,
aura::Window* target) {
DCHECK(source);
DCHECK(target);
int source_ws_index = GetWorkspaceIndexContaining(source);
int target_ws_index = GetWorkspaceIndexContaining(target);
DCHECK(source_ws_index >= 0);
DCHECK(target_ws_index >= 0);
if (source_ws_index == target_ws_index) {
workspaces_[source_ws_index]->RotateWindows(source, target);
} else {
aura::Window* insert = source;
if (source_ws_index < target_ws_index) {
for (int i = target_ws_index; i >= source_ws_index; --i) {
insert = workspaces_[i]->ShiftWindows(
insert, source, target, Workspace::SHIFT_TO_LEFT);
// |target| can only be in the 1st workspace.
target = NULL;
}
} else {
for (int i = target_ws_index; i <= source_ws_index; ++i) {
insert = workspaces_[i]->ShiftWindows(
insert, source, target, Workspace::SHIFT_TO_RIGHT);
// |target| can only be in the 1st workspace.
target = NULL;
}
}
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// WorkspaceManager, Overridden from aura::DesktopObserver: // WorkspaceManager, Overridden from aura::DesktopObserver:
...@@ -186,6 +223,17 @@ gfx::Rect WorkspaceManager::GetWorkAreaBounds( ...@@ -186,6 +223,17 @@ gfx::Rect WorkspaceManager::GetWorkAreaBounds(
return bounds; return bounds;
} }
// Returns the index of the workspace that contains the |window|.
int WorkspaceManager::GetWorkspaceIndexContaining(aura::Window* window) const {
for (Workspaces::const_iterator i = workspaces_.begin();
i != workspaces_.end();
++i) {
if ((*i)->Contains(window))
return i - workspaces_.begin();
}
return -1;
}
void WorkspaceManager::UpdateViewport() { void WorkspaceManager::UpdateViewport() {
int num_workspaces = std::max(1, static_cast<int>(workspaces_.size())); int num_workspaces = std::max(1, static_cast<int>(workspaces_.size()));
int total_width = workspace_size_.width() * num_workspaces + int total_width = workspace_size_.width() * num_workspaces +
......
...@@ -44,6 +44,9 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver { ...@@ -44,6 +44,9 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver {
// Returns the workspace that contanis the |window|. // Returns the workspace that contanis the |window|.
Workspace* FindBy(aura::Window* window) const; Workspace* FindBy(aura::Window* window) const;
// Returns the window for rotate operation based on the |location|.
aura::Window* FindRotateWindowForLocation(const gfx::Point& location);
// Sets the bounds of all workspaces. // Sets the bounds of all workspaces.
void LayoutWorkspaces(); void LayoutWorkspaces();
...@@ -54,6 +57,9 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver { ...@@ -54,6 +57,9 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver {
void SetOverview(bool overview); void SetOverview(bool overview);
bool is_overview() const { return is_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);
// Overridden from aura::DesktopObserver: // Overridden from aura::DesktopObserver:
virtual void OnDesktopResized(const gfx::Size& new_size) OVERRIDE; virtual void OnDesktopResized(const gfx::Size& new_size) OVERRIDE;
virtual void OnActiveWindowChanged(aura::Window* active) OVERRIDE; virtual void OnActiveWindowChanged(aura::Window* active) OVERRIDE;
...@@ -62,6 +68,7 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver { ...@@ -62,6 +68,7 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver {
friend class Workspace; friend class Workspace;
FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, Overview); FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, Overview);
FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, LayoutWorkspaces); FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, LayoutWorkspaces);
FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, FindRotateWindow);
void AddWorkspace(Workspace* workspace); void AddWorkspace(Workspace* workspace);
void RemoveWorkspace(Workspace* workspace); void RemoveWorkspace(Workspace* workspace);
...@@ -72,6 +79,9 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver { ...@@ -72,6 +79,9 @@ class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver {
// Returns the bounds of the work are given |workspace_bounds|. // Returns the bounds of the work are given |workspace_bounds|.
gfx::Rect GetWorkAreaBounds(const gfx::Rect& workspace_bounds); gfx::Rect GetWorkAreaBounds(const gfx::Rect& workspace_bounds);
// Returns the index of the workspace that contains the |window|.
int GetWorkspaceIndexContaining(aura::Window* window) const;
// Update viewport size and move to the active workspace. // Update viewport size and move to the active workspace.
void UpdateViewport(); void UpdateViewport();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment