Commit 4a8cb8e9 authored by sadrul@chromium.org's avatar sadrul@chromium.org

ash: Stop hiding the shelf on user-action after it was shown using gesture drag.

This is effectively a revert of r184013 and r183849.

BUG=227057, 173295

Review URL: https://codereview.chromium.org/13674020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192650 0039d316-1c4b-4281-b951-d872f2087c98
parent eabbfb19
......@@ -950,26 +950,6 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) {
EXPECT_EQ(shelf_hidden.ToString(),
GetShelfWidget()->GetWindowBoundsInScreen().ToString());
// Swipe up yet again to show it.
end.set_y(start.y() + 100);
generator.GestureScrollSequence(end, start,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
// Tap on the shelf itself. This should not change anything.
generator.GestureTapAt(start);
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
// Now, tap on the desktop region (above the shelf). This should hide the
// shelf.
gfx::Point tap = start + gfx::Vector2d(0, -90);
generator.GestureTapAt(tap);
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
// Make the window fullscreen.
widget->SetFullscreen(true);
gfx::Rect bounds_fullscreen = window->bounds();
......
......@@ -19,96 +19,6 @@
#include "ui/gfx/transform.h"
#include "ui/views/widget/widget.h"
namespace {
// A ShelfResetHandler auto-hides the shelf as soon as the user interacts with
// any non-shelf part of the system. The ShelfResetHandler manages its own
// lifetime.
class ShelfResetHandler : public ui::EventHandler,
public ash::internal::ShelfLayoutManager::Observer {
public:
explicit ShelfResetHandler(ash::internal::ShelfLayoutManager* shelf)
: shelf_(shelf) {
shelf_->AddObserver(this);
ash::Shell::GetInstance()->AddPreTargetHandler(this);
}
private:
virtual ~ShelfResetHandler() {
ash::Shell::GetInstance()->RemovePreTargetHandler(this);
shelf_->RemoveObserver(this);
}
void ResetShelfState() {
shelf_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
delete this;
}
bool ShelfIsEventTarget(const ui::Event& event) {
aura::Window* target = static_cast<aura::Window*>(event.target());
views::Widget* widget = shelf_->shelf_widget();
if (widget && widget->GetNativeWindow() == target)
return true;
widget = shelf_->shelf_widget()->status_area_widget();
if (widget && widget->GetNativeWindow() == target)
return true;
return false;
}
void DecideShelfVisibility(const gfx::Point& location) {
// For the rest of the mouse events, ignore if the event happens inside the
// shelf.
views::Widget* widget = shelf_->shelf_widget();
if (widget &&
widget->GetWindowBoundsInScreen().Contains(location)) {
return;
}
widget = shelf_->shelf_widget()->status_area_widget();
if (widget &&
widget->GetWindowBoundsInScreen().Contains(location)) {
return;
}
ResetShelfState();
}
// Overridden from ui::EventHandler:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
if (!ShelfIsEventTarget(*event))
ResetShelfState();
}
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
// Ignore all mouse move events.
if (event->type() == ui::ET_MOUSE_PRESSED ||
event->type() == ui::ET_MOUSE_RELEASED) {
DecideShelfVisibility(event->root_location());
}
}
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
if (!ShelfIsEventTarget(*event))
DecideShelfVisibility(event->root_location());
}
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
if (!ShelfIsEventTarget(*event))
DecideShelfVisibility(event->root_location());
}
// Overridden from ash::internal::ShelfLayoutManager::Observer:
virtual void WillDeleteShelf() OVERRIDE {
delete this;
}
ash::internal::ShelfLayoutManager* shelf_;
DISALLOW_COPY_AND_ASSIGN(ShelfResetHandler);
};
} // namespace
namespace ash {
namespace internal {
......@@ -165,11 +75,7 @@ bool ShelfGestureHandler::ProcessGestureEvent(const ui::GestureEvent& event) {
tray_handler_.reset();
}
ShelfVisibilityState old_state = shelf->visibility_state();
shelf->CompleteGestureDrag(event);
ShelfVisibilityState new_state = shelf->visibility_state();
if (new_state != old_state && new_state == SHELF_VISIBLE)
new ShelfResetHandler(shelf);
return true;
}
......
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