summaryrefslogtreecommitdiffstats
path: root/ash/wm/workspace
diff options
context:
space:
mode:
Diffstat (limited to 'ash/wm/workspace')
-rw-r--r--ash/wm/workspace/workspace_manager.cc35
-rw-r--r--ash/wm/workspace/workspace_manager.h17
-rw-r--r--ash/wm/workspace/workspace_manager_unittest.cc7
3 files changed, 36 insertions, 23 deletions
diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc
index c6c9dd6..e4cec4b 100644
--- a/ash/wm/workspace/workspace_manager.cc
+++ b/ash/wm/workspace/workspace_manager.cc
@@ -158,18 +158,17 @@ gfx::Rect WorkspaceManager::AlignBoundsToGrid(const gfx::Rect& bounds) {
}
void WorkspaceManager::UpdateShelfVisibility() {
- if (!shelf_ || !active_workspace_) {
- shelf_->SetState(ShelfLayoutManager::VISIBLE);
- shelf_->SetWindowOverlapsShelf(false);
- return;
- }
+ shelf_->UpdateVisibilityState();
+}
+
+WorkspaceManager::WindowState WorkspaceManager::GetWindowState() {
+ if (!shelf_ || !active_workspace_)
+ return WINDOW_STATE_DEFAULT;
// TODO: this code needs to be made multi-monitor aware.
gfx::Rect bounds(gfx::Screen::GetMonitorAreaNearestWindow(contents_view_));
bounds.set_height(bounds.height() - shelf_->shelf_height());
const aura::Window::Windows& windows(contents_view_->children());
- bool has_full_screen_window = false;
- bool has_max_window = false;
bool window_overlaps_launcher = false;
for (aura::Window::Windows::const_iterator i = windows.begin();
i != windows.end(); ++i) {
@@ -178,26 +177,16 @@ void WorkspaceManager::UpdateShelfVisibility() {
ui::Layer* layer = (*i)->layer();
if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f)
continue;
- if (wm::IsWindowMaximized(*i)) {
- has_max_window = true;
- break;
- }
- if (wm::IsWindowFullscreen(*i)) {
- has_full_screen_window = true;
- break;
- }
+ if (wm::IsWindowMaximized(*i))
+ return WINDOW_STATE_MAXIMIZED;
+ if (wm::IsWindowFullscreen(*i))
+ return WINDOW_STATE_FULL_SCREEN;
if (!window_overlaps_launcher && (*i)->bounds().bottom() > bounds.bottom())
window_overlaps_launcher = true;
}
- ShelfLayoutManager::VisibilityState visibility_state =
- ShelfLayoutManager::VISIBLE;
- if (has_full_screen_window)
- visibility_state = ShelfLayoutManager::HIDDEN;
- else if (has_max_window)
- visibility_state = ShelfLayoutManager::AUTO_HIDE;
- shelf_->SetState(visibility_state);
- shelf_->SetWindowOverlapsShelf(window_overlaps_launcher);
+ return window_overlaps_launcher ? WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
+ WINDOW_STATE_DEFAULT;
}
void WorkspaceManager::ShowStateChanged(aura::Window* window) {
diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h
index e1dbf05..9912f8d 100644
--- a/ash/wm/workspace/workspace_manager.h
+++ b/ash/wm/workspace/workspace_manager.h
@@ -32,6 +32,20 @@ class WorkspaceManagerTest;
// WorkspaceManager manages multiple workspaces in the desktop.
class ASH_EXPORT WorkspaceManager {
public:
+ enum WindowState {
+ // There's a full screen window.
+ WINDOW_STATE_FULL_SCREEN,
+
+ // There's a maximized window.
+ WINDOW_STATE_MAXIMIZED,
+
+ // At least one window overlaps the shelf.
+ WINDOW_STATE_WINDOW_OVERLAPS_SHELF,
+
+ // None of the windows are fullscreen, maximized or touch the shelf.
+ WINDOW_STATE_DEFAULT,
+ };
+
explicit WorkspaceManager(aura::Window* viewport);
virtual ~WorkspaceManager();
@@ -80,6 +94,9 @@ class ASH_EXPORT WorkspaceManager {
// Updates the visibility and whether any windows overlap the shelf.
void UpdateShelfVisibility();
+ // Returns the current window state.
+ WindowState GetWindowState();
+
// Invoked when the show state of the specified window changes.
void ShowStateChanged(aura::Window* window);
diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc
index f15dbfc..5d04322 100644
--- a/ash/wm/workspace/workspace_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_manager_unittest.cc
@@ -17,6 +17,7 @@
#include "ash/wm/workspace/workspace_layout_manager.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/compositor/layer.h"
@@ -444,6 +445,12 @@ TEST_F(WorkspaceManagerTest, MinimizeMaximizedWindow) {
// Verifies ShelfLayoutManager's visibility/auto-hide state is correctly
// updated.
TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
+ // Since ShelfLayoutManager queries for mouse location, move the mouse so
+ // it isn't over the shelf.
+ aura::test::EventGenerator generator(
+ Shell::GetInstance()->GetRootWindow(), gfx::Point());
+ generator.MoveMouseTo(0, 0);
+
// Two windows, w1 normal, w2 maximized.
scoped_ptr<Window> w1(CreateTestWindow());
w1->SetBounds(gfx::Rect(0, 1, 101, 102));