summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 21:42:37 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 21:42:37 +0000
commit5f1d99dceda9a8d8e137635b375d9e3b46921680 (patch)
treebe4249e59b7c053966c4760f09fa5ede25405ec5 /ash
parentb8df2e8eba057759d4f4fbe5db7e3f4f8c345ae6 (diff)
downloadchromium_src-5f1d99dceda9a8d8e137635b375d9e3b46921680.zip
chromium_src-5f1d99dceda9a8d8e137635b375d9e3b46921680.tar.gz
chromium_src-5f1d99dceda9a8d8e137635b375d9e3b46921680.tar.bz2
Changes launcher auto-hide not to appear if mouse is down.
BUG=120894 TEST=see bug R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10065022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/shelf_layout_manager.cc25
-rw-r--r--ash/wm/shelf_layout_manager.h3
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc19
3 files changed, 46 insertions, 1 deletions
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 1708f37..c2fd695 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -49,6 +49,9 @@ class ShelfLayoutManager::AutoHideEventFilter : public aura::EventFilter {
explicit AutoHideEventFilter(ShelfLayoutManager* shelf);
virtual ~AutoHideEventFilter();
+ // Returns true if the last mouse event was a mouse drag.
+ bool in_mouse_drag() const { return in_mouse_drag_; }
+
// Overridden from aura::EventFilter:
virtual bool PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) OVERRIDE;
@@ -62,13 +65,15 @@ class ShelfLayoutManager::AutoHideEventFilter : public aura::EventFilter {
private:
ShelfLayoutManager* shelf_;
+ bool in_mouse_drag_;
DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter);
};
ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter(
ShelfLayoutManager* shelf)
- : shelf_(shelf) {
+ : shelf_(shelf),
+ in_mouse_drag_(false) {
Shell::GetInstance()->AddRootWindowEventFilter(this);
}
@@ -85,6 +90,12 @@ bool ShelfLayoutManager::AutoHideEventFilter::PreHandleKeyEvent(
bool ShelfLayoutManager::AutoHideEventFilter::PreHandleMouseEvent(
aura::Window* target,
aura::MouseEvent* event) {
+ // This also checks IsShelfWindow() to make sure we don't attempt to hide the
+ // shelf if the mouse down occurs on the shelf.
+ in_mouse_drag_ = (event->type() == ui::ET_MOUSE_DRAGGED ||
+ (in_mouse_drag_ && event->type() != ui::ET_MOUSE_RELEASED &&
+ event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) &&
+ !shelf_->IsShelfWindow(target);
if (event->type() == ui::ET_MOUSE_MOVED)
shelf_->UpdateAutoHideState();
return false; // Not handled.
@@ -417,6 +428,10 @@ ShelfLayoutManager::AutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (launcher_widget()->IsActive() || status_->IsActive())
return AUTO_HIDE_SHOWN;
+ // Don't show if the user is dragging the mouse.
+ if (event_filter_.get() && event_filter_->in_mouse_drag())
+ return AUTO_HIDE_HIDDEN;
+
aura::RootWindow* root = launcher_widget()->GetNativeView()->GetRootWindow();
bool mouse_over_launcher =
launcher_widget()->GetWindowScreenBounds().Contains(
@@ -439,5 +454,13 @@ void ShelfLayoutManager::UpdateHitTestBounds() {
status_->GetNativeWindow()->set_hit_test_bounds_override_outer(insets);
}
+bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) {
+ if (!window)
+ return false;
+ return (launcher_widget() &&
+ launcher_widget()->GetNativeWindow()->Contains(window)) ||
+ (status_ && status_->GetNativeWindow()->Contains(window));
+}
+
} // namespace internal
} // namespace ash
diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h
index 10988c4..9c3cc1d 100644
--- a/ash/wm/shelf_layout_manager.h
+++ b/ash/wm/shelf_layout_manager.h
@@ -195,6 +195,9 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager,
// Updates the hit test bounds override for launcher and status area.
void UpdateHitTestBounds();
+ // Returns true if |window| is a descendant of the shelf.
+ bool IsShelfWindow(aura::Window* window);
+
// The RootWindow is cached so that we don't invoke Shell::GetInstance() from
// our destructor. We avoid that as at the time we're deleted Shell is being
// deleted too.
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index 3813e2e..559316e 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -53,6 +53,10 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
shelf->SetState(state);
}
+ void UpdateAutoHideStateNow() {
+ GetShelfLayoutManager()->UpdateAutoHideStateNow();
+ }
+
aura::Window* CreateTestWindow() {
aura::Window* window = new aura::Window(NULL);
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
@@ -228,6 +232,21 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
shelf->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
shelf->launcher_widget()->GetWindowScreenBounds().y());
+
+ // Drag mouse to bottom of screen.
+ generator.PressLeftButton();
+ generator.MoveMouseTo(0, root->bounds().bottom() - 1);
+ UpdateAutoHideStateNow();
+ EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+ generator.ReleaseLeftButton();
+ generator.MoveMouseTo(1, root->bounds().bottom() - 1);
+ UpdateAutoHideStateNow();
+ EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
+ generator.PressLeftButton();
+ generator.MoveMouseTo(1, root->bounds().bottom() - 1);
+ UpdateAutoHideStateNow();
+ EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
}
// Assertions around the lock screen showing.