summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/shelf/shelf_layout_manager.cc44
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc16
2 files changed, 44 insertions, 16 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index 8210b5b..e392cc2 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -36,6 +36,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "ui/aura/client/activation_client.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/root_window.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_handler.h"
@@ -954,9 +955,6 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (visibility_state != SHELF_AUTO_HIDE || !shelf_)
return SHELF_AUTO_HIDE_HIDDEN;
- if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
- return gesture_drag_auto_hide_state_;
-
Shell* shell = Shell::GetInstance();
if (shell->GetAppListTargetVisibility())
return SHELF_AUTO_HIDE_SHOWN;
@@ -974,10 +972,36 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (shelf_->IsActive() || shelf_->status_area_widget()->IsActive())
return SHELF_AUTO_HIDE_SHOWN;
+ const std::vector<aura::Window*> windows =
+ ash::MruWindowTracker::BuildWindowList(false);
+
+ // Process the window list and check if there are any visible windows.
+ bool visible_window = false;
+ for (size_t i = 0; i < windows.size(); ++i) {
+ if (windows[i] && windows[i]->IsVisible() &&
+ !ash::wm::IsWindowMinimized(windows[i]) &&
+ root_window_ == windows[i]->GetRootWindow()) {
+ visible_window = true;
+ break;
+ }
+ }
+ // If there are no visible windows do not hide the shelf.
+ if (!visible_window)
+ return SHELF_AUTO_HIDE_SHOWN;
+
+ if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
+ return gesture_drag_auto_hide_state_;
+
// Don't show if the user is dragging the mouse.
if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag())
return SHELF_AUTO_HIDE_HIDDEN;
+ // Ignore the mouse position if mouse events are disabled.
+ aura::client::CursorClient* cursor_client = aura::client::GetCursorClient(
+ shelf_->GetNativeWindow()->GetRootWindow());
+ if (!cursor_client->IsMouseEventsEnabled())
+ return SHELF_AUTO_HIDE_HIDDEN;
+
gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen();
if (shelf_->status_area_widget() &&
shelf_->status_area_widget()->IsMessageBubbleShown() &&
@@ -1018,19 +1042,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
return SHELF_AUTO_HIDE_SHOWN;
}
- const std::vector<aura::Window*> windows =
- ash::MruWindowTracker::BuildWindowList(false);
-
- // Process the window list and check if there are any visible windows.
- for (size_t i = 0; i < windows.size(); ++i) {
- if (windows[i] && windows[i]->IsVisible() &&
- !ash::wm::IsWindowMinimized(windows[i]) &&
- root_window_ == windows[i]->GetRootWindow())
- return SHELF_AUTO_HIDE_HIDDEN;
- }
-
- // If there are no visible windows do not hide the shelf.
- return SHELF_AUTO_HIDE_SHOWN;
+ return SHELF_AUTO_HIDE_HIDDEN;
}
void ShelfLayoutManager::UpdateHitTestBounds() {
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 2781e6c..e62bcec 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -576,6 +576,22 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
// is fullscreen status.
widget->Close();
RunAllPendingInMessageLoop();
+
+ // The shelf should be shown because there are no more visible windows.
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
+
+ // Swipe-up to hide. This should have no effect because there are no visible
+ // windows.
+ end = below_start - delta;
+ generator.GestureScrollSequenceWithCallback(below_start, end,
+ base::TimeDelta::FromMilliseconds(10), kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
}
// Fails on Mac only. Need to be implemented. http://crbug.com/111279.